haxerwddle commited on
Commit
8156c42
·
1 Parent(s): e93c8ed

prompt model change

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -52,6 +52,18 @@ pipe = pipeline(
52
  max_new_tokens=200
53
  )
54
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  def explain_recycling(label):
57
  system_msg = {
@@ -85,7 +97,8 @@ def explain_recycling(label):
85
  do_sample=False # deterministic to avoid repeating instructions
86
  )
87
 
88
- return outputs[0]["generated_text"]
 
89
 
90
 
91
  # ------------------ PIPELINE ------------------
 
52
  max_new_tokens=200
53
  )
54
 
55
+ def clean_chat_output(full_text):
56
+ # Split at the last assistant tag (TinyLlama uses <|assistant|>)
57
+ if "<|assistant|>" in full_text:
58
+ full_text = full_text.split("<|assistant|>")[-1]
59
+
60
+ # Remove any leftover "Item:" echoes
61
+ lines = full_text.strip().split("\n")
62
+ if lines[0].lower().startswith("item:"):
63
+ lines = lines[1:]
64
+
65
+ return "\n".join(lines).strip()
66
+
67
 
68
  def explain_recycling(label):
69
  system_msg = {
 
97
  do_sample=False # deterministic to avoid repeating instructions
98
  )
99
 
100
+ raw = outputs[0]["generated_text"]
101
+ return clean_chat_output(raw)
102
 
103
 
104
  # ------------------ PIPELINE ------------------