izh97 commited on
Commit
9602507
·
verified ·
1 Parent(s): 37a0a60

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -5
app.py CHANGED
@@ -27,12 +27,8 @@ def ask(text):
27
  device_map="cuda")
28
 
29
  inputs = tokenizer.apply_chat_template(text, tokenize=True, add_generation_prompt=True, return_tensors="pt").to("cuda")
30
-
31
- input_length = inputs.input_ids.shape[1]
32
  outputs = model.generate(**inputs, generation_config=generation_config,
33
  return_dict_in_generate=True)
34
-
35
- tokens = outputs.sequences[0, input_length:]
36
- return tokenizer.decode(tokens)
37
  iface = gr.Interface(fn=ask, inputs="text", outputs="text")
38
  iface.launch()
 
27
  device_map="cuda")
28
 
29
  inputs = tokenizer.apply_chat_template(text, tokenize=True, add_generation_prompt=True, return_tensors="pt").to("cuda")
 
 
30
  outputs = model.generate(**inputs, generation_config=generation_config,
31
  return_dict_in_generate=True)
32
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
 
 
33
  iface = gr.Interface(fn=ask, inputs="text", outputs="text")
34
  iface.launch()