|
|
|
""" |
|
Integration test for softmax selection with backend word service. |
|
""" |
|
|
|
import os |
|
|
|
def test_backend_integration(): |
|
"""Test how the backend would use the softmax selection""" |
|
|
|
print("π§ͺ Testing backend integration with softmax selection...") |
|
|
|
|
|
os.environ['SIMILARITY_TEMPERATURE'] = '0.7' |
|
os.environ['USE_SOFTMAX_SELECTION'] = 'true' |
|
|
|
|
|
from thematic_word_generator import UnifiedThematicWordGenerator |
|
|
|
generator = UnifiedThematicWordGenerator() |
|
print("β
Generator created with softmax enabled") |
|
|
|
|
|
print(f"π Configuration:") |
|
print(f" Temperature: {generator.similarity_temperature}") |
|
print(f" Softmax enabled: {generator.use_softmax_selection}") |
|
|
|
|
|
test_temperatures = [0.3, 0.7, 1.0, 1.5] |
|
|
|
print(f"\nπ‘οΈ Testing different temperatures:") |
|
for temp in test_temperatures: |
|
generator.similarity_temperature = temp |
|
if temp == 0.3: |
|
print(f" {temp}: More deterministic (favors high similarity)") |
|
elif temp == 0.7: |
|
print(f" {temp}: Balanced (recommended default)") |
|
elif temp == 1.0: |
|
print(f" {temp}: Standard softmax") |
|
elif temp == 1.5: |
|
print(f" {temp}: More random (flatter distribution)") |
|
|
|
print(f"\nπ Backend usage example:") |
|
print(f" # Set environment variables:") |
|
print(f" export SIMILARITY_TEMPERATURE=0.7") |
|
print(f" export USE_SOFTMAX_SELECTION=true") |
|
print(f" ") |
|
print(f" # Use in backend:") |
|
print(f" generator = UnifiedThematicWordGenerator()") |
|
print(f" words = generator.generate_thematic_words(['animals'], num_words=15)") |
|
print(f" # Words will be selected using softmax-weighted sampling") |
|
|
|
print("β
Backend integration test completed!") |
|
|
|
if __name__ == "__main__": |
|
test_backend_integration() |