haxerwddle commited on
Commit
7d958d0
·
1 Parent(s): 75d35ec

prompt model change

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -40,13 +40,17 @@ chat_model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-base")
40
 
41
  def explain_recycling(class_label):
42
  prompt = f"""
43
- Give short recycling instructions for the item {class_label}."""
 
 
 
44
  inputs = tokenizer(prompt, return_tensors="pt").input_ids
45
 
46
  outputs = chat_model.generate(
47
  inputs,
48
- max_length=180,
49
- do_sample=False
 
50
  )
51
 
52
  return tokenizer.decode(outputs[0], skip_special_tokens=True)
 
40
 
41
  def explain_recycling(class_label):
42
  prompt = f"""
43
+ Give short recycling instructions for the item {class_label}.
44
+ Rules:
45
+ - NEVER repeat any sentence.
46
+ - NEVER restate the same phrase more than once."""
47
  inputs = tokenizer(prompt, return_tensors="pt").input_ids
48
 
49
  outputs = chat_model.generate(
50
  inputs,
51
+ max_length=80,
52
+ do_sample=False,
53
+ repetition_penalty=2.0,
54
  )
55
 
56
  return tokenizer.decode(outputs[0], skip_special_tokens=True)