patpizio commited on
Commit
e8a54d9
·
1 Parent(s): 090b788

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -1
app.py CHANGED
@@ -27,5 +27,28 @@ inputs = tokenizer(
27
  )
28
  input_ids = inputs["input_ids"]#.to("cuda")
29
 
 
 
 
 
 
 
 
 
 
30
  if instruction:
31
- st.write(tokenizer.decode(input_ids[0]))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  )
28
  input_ids = inputs["input_ids"]#.to("cuda")
29
 
30
+ generation_config = GenerationConfig(
31
+ do_sample=True,
32
+ temperature=0.8, # default 0.1
33
+ top_p=0.995, # default 0.75
34
+ top_k=100, # default 80
35
+ repetition_penalty=1.5,
36
+ max_new_tokens=2,
37
+ )
38
+
39
  if instruction:
40
+ with torch.no_grad():
41
+ outputs = model.generate(
42
+ input_ids=input_ids,
43
+ attention_mask=torch.ones_like(input_ids),
44
+ generation_config=generation_config,
45
+ return_dict_in_generate=True,
46
+ output_scores=True
47
+ )
48
+
49
+ output_text = tokenizer.decode(
50
+ outputs['sequences'][0].cuda(),
51
+ skip_special_tokens=False
52
+ ).strip()
53
+
54
+ st.write(output_text)