Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,7 +15,7 @@ with open("textgen_tokenizer.pkl", "rb") as f:
|
|
| 15 |
textgen_tokenizer = pickle.load(f)
|
| 16 |
|
| 17 |
# === Settings ===
|
| 18 |
-
CLASS_LABELS = ['
|
| 19 |
MAX_LEN_CLASSIFIER = 100
|
| 20 |
MAX_LEN_TEXTGEN = 50
|
| 21 |
|
|
@@ -29,7 +29,7 @@ def classify_text(text):
|
|
| 29 |
|
| 30 |
|
| 31 |
# === Text Generation with Top-k Sampling ===
|
| 32 |
-
def generate_text(seed_text, next_words=
|
| 33 |
recent_words = set()
|
| 34 |
for _ in range(next_words):
|
| 35 |
token_list = textgen_tokenizer.texts_to_sequences([seed_text])[0]
|
|
|
|
| 15 |
textgen_tokenizer = pickle.load(f)
|
| 16 |
|
| 17 |
# === Settings ===
|
| 18 |
+
CLASS_LABELS = ['Science', 'Math', 'History'] # Replace with actual labels
|
| 19 |
MAX_LEN_CLASSIFIER = 100
|
| 20 |
MAX_LEN_TEXTGEN = 50
|
| 21 |
|
|
|
|
| 29 |
|
| 30 |
|
| 31 |
# === Text Generation with Top-k Sampling ===
|
| 32 |
+
def generate_text(seed_text, next_words=15, k=10, temperature=0.9):
|
| 33 |
recent_words = set()
|
| 34 |
for _ in range(next_words):
|
| 35 |
token_list = textgen_tokenizer.texts_to_sequences([seed_text])[0]
|