Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,12 +25,17 @@ labels = [
|
|
| 25 |
"education", "engineering", "entertainment", "environment",
|
| 26 |
"fashion", "finance", "food commerce", "general",
|
| 27 |
"gaming", "healthcare", "history", "html",
|
| 28 |
-
"information technology", "
|
| 29 |
"literature", "machine learning", "marketing", "medicine",
|
| 30 |
-
"music", "
|
| 31 |
-
"politics", "poetry", "programming", "real estate", "retail",
|
| 32 |
"robotics", "slang", "social media", "speech", "sports",
|
| 33 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
]
|
| 35 |
|
| 36 |
@lru_cache(maxsize=1)
|
|
@@ -58,6 +63,11 @@ def detect_context(input_text, top_n=3):
|
|
| 58 |
# Compute cosine similarities
|
| 59 |
similarities = cosine_similarity(input_embedding, label_embeddings)[0]
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
# Apply softmax to convert similarities to probabilities
|
| 62 |
probabilities = softmax(similarities)
|
| 63 |
|
|
|
|
| 25 |
"education", "engineering", "entertainment", "environment",
|
| 26 |
"fashion", "finance", "food commerce", "general",
|
| 27 |
"gaming", "healthcare", "history", "html",
|
| 28 |
+
"information technology", "keywords", "legal",
|
| 29 |
"literature", "machine learning", "marketing", "medicine",
|
| 30 |
+
"music", "philosophy", "physics", "politics", "programming", "real estate", "retail",
|
|
|
|
| 31 |
"robotics", "slang", "social media", "speech", "sports",
|
| 32 |
+
"technical", "theater", "tourism", "travel"
|
| 33 |
+
]
|
| 34 |
+
|
| 35 |
+
styles = [
|
| 36 |
+
"formal", "positive", "negative", "poetic", "polite", "subtle", "casual", "neutral",
|
| 37 |
+
"informal", "pompous", "sustained", "rude", "sustained",
|
| 38 |
+
"sophisticated", "playful", "serious", "friendly"
|
| 39 |
]
|
| 40 |
|
| 41 |
@lru_cache(maxsize=1)
|
|
|
|
| 63 |
# Compute cosine similarities
|
| 64 |
similarities = cosine_similarity(input_embedding, label_embeddings)[0]
|
| 65 |
|
| 66 |
+
# Debugging: Print all labels and their similarity scores
|
| 67 |
+
print("Debug: Similarity scores for all labels:")
|
| 68 |
+
for label, score in zip(labels, similarities):
|
| 69 |
+
print(f"{label}: {score:.4f}")
|
| 70 |
+
|
| 71 |
# Apply softmax to convert similarities to probabilities
|
| 72 |
probabilities = softmax(similarities)
|
| 73 |
|