Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -75,14 +75,21 @@ def string_similarity_index(original_text, comparison_text, threshold=0.6):
|
|
| 75 |
|
| 76 |
# Function to generate an AI title
|
| 77 |
def generate_ai_title():
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
# Function to check user's answer and update score
|
| 88 |
def check_answer(user_choice, real_index, score):
|
|
|
|
| 75 |
|
| 76 |
# Function to generate an AI title
|
| 77 |
def generate_ai_title():
|
| 78 |
+
while True:
|
| 79 |
+
inputs = tokenizer(["<|startoftext|>"]*1, return_tensors="pt")
|
| 80 |
+
outputs = model.generate(**inputs, max_new_tokens=48, use_cache=True, temperature=0.85, do_sample=True)
|
| 81 |
+
generated_title = (tokenizer.batch_decode(outputs)[0])[15:-13].strip()
|
| 82 |
+
|
| 83 |
+
# Check for similarity with existing titles
|
| 84 |
+
is_unique = True
|
| 85 |
+
for title in dhar_mann_titles:
|
| 86 |
+
title = title.strip() # Remove any extra whitespace characters like newlines
|
| 87 |
+
if string_similarity_index(generated_title, title):
|
| 88 |
+
is_unique = False
|
| 89 |
+
break
|
| 90 |
+
|
| 91 |
+
if is_unique:
|
| 92 |
+
return generated_title
|
| 93 |
|
| 94 |
# Function to check user's answer and update score
|
| 95 |
def check_answer(user_choice, real_index, score):
|