pivovalera2012 commited on
Commit
33d8076
1 Parent(s): eb684a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -16,7 +16,17 @@ tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
16
 
17
 
18
  def generate_text(prompt):
19
- return 'Привет'
 
 
 
 
 
 
 
 
 
 
20
 
21
 
22
  demo = gr.Interface(
 
16
 
17
 
18
  def generate_text(prompt):
19
+ encoding = tokenizer(prompt, return_tensors="pt").to(device)
20
+ with torch.no_grad():
21
+ outputs = model_trained.generate(
22
+ input_ids = encoding.input_ids,
23
+ attention_mask = encoding.attention_mask,
24
+ generation_config = generation_config
25
+ )
26
+
27
+ answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
28
+ answer = answer.split(':')
29
+ return answer[1]
30
 
31
 
32
  demo = gr.Interface(