Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -42,8 +42,21 @@ def chat_with_distilgpt2(input_text):
|
|
42 |
# Tokenize the input and convert to tensor
|
43 |
input_ids = tokenizer.encode(full_input, return_tensors="pt").to(device)
|
44 |
|
45 |
-
# Generate the response using the model
|
46 |
-
outputs = model.generate(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
# Decode the model output
|
49 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
|
|
42 |
# Tokenize the input and convert to tensor
|
43 |
input_ids = tokenizer.encode(full_input, return_tensors="pt").to(device)
|
44 |
|
45 |
+
# Generate the response using the model with adjusted parameters
|
46 |
+
outputs = model.generate(
|
47 |
+
input_ids,
|
48 |
+
max_length=input_ids.shape[1] + 100, # Limit total length
|
49 |
+
max_new_tokens=100,
|
50 |
+
num_return_sequences=1,
|
51 |
+
no_repeat_ngram_size=3,
|
52 |
+
repetition_penalty=1.2,
|
53 |
+
temperature=0.7,
|
54 |
+
top_k=50,
|
55 |
+
top_p=0.95,
|
56 |
+
early_stopping=True,
|
57 |
+
pad_token_id=tokenizer.eos_token_id,
|
58 |
+
eos_token_id=tokenizer.eos_token_id
|
59 |
+
)
|
60 |
|
61 |
# Decode the model output
|
62 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|