naot97 commited on
Commit
736e5b7
1 Parent(s): 7885fc0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -94,9 +94,21 @@ def evaluate(
94
  num_beams=num_beams,
95
  **kwargs,
96
  )
97
- with torch.cuda.amp.autocast():
98
- output_tokens = model.generate(**inputs, generation_config=generation_config)
99
- output = tokenizer.decode(output_tokens[0], skip_special_tokens=True)
 
 
 
 
 
 
 
 
 
 
 
 
100
  return output[len(input_ids):]
101
 
102
 
 
94
  num_beams=num_beams,
95
  **kwargs,
96
  )
97
+ # with torch.cuda.amp.autocast():
98
+ # output_tokens = model.generate(**inputs, generation_config=generation_config)
99
+ # output = tokenizer.decode(output_tokens[0], skip_special_tokens=True)
100
+
101
+ with torch.no_grad():
102
+ generation_output = model.generate(
103
+ input_ids=input_ids,
104
+ generation_config=generation_config,
105
+ return_dict_in_generate=True,
106
+ output_scores=True,
107
+ max_new_tokens=max_new_tokens,
108
+ )
109
+ s = generation_output.sequences[0]
110
+ output = tokenizer.decode(s, skip_special_tokens=True)
111
+
112
  return output[len(input_ids):]
113
 
114