golyuval commited on
Commit
0ff4a0e
·
verified ·
1 Parent(s): c684264

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +4 -5
handler.py CHANGED
@@ -157,11 +157,10 @@ Note - each answer must be of length <= 400."""
157
  **gen_config
158
  )
159
 
160
- # Decode response
161
- full_response = self.tokenizer.decode(outputs[0], skip_special_tokens=True)
162
-
163
- # Extract only the assistant's response
164
- assistant_response = full_response.split("<|start_header_id|>assistant<|end_header_id|>")[-1].strip()
165
 
166
  # Extract the final answer
167
  extracted_answer = self.extract_answer(assistant_response)
 
157
  **gen_config
158
  )
159
 
160
+ # Decode response - only decode the generated tokens, not the input
161
+ input_length = model_inputs['input_ids'].shape[1]
162
+ generated_tokens = outputs[0][input_length:]
163
+ assistant_response = self.tokenizer.decode(generated_tokens, skip_special_tokens=True).strip()
 
164
 
165
  # Extract the final answer
166
  extracted_answer = self.extract_answer(assistant_response)