Chris4K commited on
Commit
f395287
·
verified ·
1 Parent(s): dc012ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -109,7 +109,13 @@ def chat_with_model(user_input, chat_history=[]):
109
  )
110
 
111
  outputs = model.generate(input_ids, max_new_tokens=1200, do_sample=True, top_k=50, temperature=0.7)
112
- response = tokenizer.decode(outputs[0], skip_special_tokens=True)
 
 
 
 
 
 
113
 
114
  # End model generation span
115
  generation_span.end(
 
109
  )
110
 
111
  outputs = model.generate(input_ids, max_new_tokens=1200, do_sample=True, top_k=50, temperature=0.7)
112
+ # response = tokenizer.decode(outputs[0], skip_special_tokens=True)
113
+
114
+ # Decode and clean the response to remove unwanted repetitions of "assistant"
115
+ response = self.tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True).strip()
116
+
117
+ # Remove potential repeated assistant text
118
+ response = response.replace("<|assistant|>", "").strip()
119
 
120
  # End model generation span
121
  generation_span.end(