kdevoe commited on
Commit
fb600ee
1 Parent(s): ce16e77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
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(input_ids, max_length=150, num_return_sequences=1, pad_token_id=tokenizer.eos_token_id)
 
 
 
 
 
 
 
 
 
 
 
 
 
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)