mayf commited on
Commit
6e9535c
·
verified ·
1 Parent(s): 59a3d03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -38,10 +38,7 @@ def load_flant5_pipeline():
38
  return pipeline(
39
  "text2text-generation",
40
  model=seq_model,
41
- tokenizer=seq_tok,
42
- max_new_tokens=300,
43
- do_sample=True,
44
- temperature=0.7
45
  )
46
 
47
  LABEL_MAP = {
@@ -117,7 +114,7 @@ def main():
117
  progress.text("Generating detailed recommendations...")
118
  if max_label in ["Very Negative", "Negative", "Neutral"]:
119
  prompt = f"""
120
- You are a senior product quality and customer experience specialist at an e-commerce food retailer.
121
 
122
  Customer Review:
123
  "{review}"
@@ -126,7 +123,16 @@ Instructions: Analyze the feedback and provide three distinct, actionable improv
126
 
127
  Output only the three numbered recommendations (1–3), each with its title, detailed explanation, steps, and impact measure.
128
  """
129
- response = generation_pipeline(prompt)
 
 
 
 
 
 
 
 
 
130
  detailed = response[0]["generated_text"]
131
  st.markdown(detailed)
132
  else:
@@ -139,4 +145,3 @@ Output only the three numbered recommendations (1–3), each with its title, det
139
 
140
  if __name__ == "__main__":
141
  main()
142
-
 
38
  return pipeline(
39
  "text2text-generation",
40
  model=seq_model,
41
+ tokenizer=seq_tok
 
 
 
42
  )
43
 
44
  LABEL_MAP = {
 
114
  progress.text("Generating detailed recommendations...")
115
  if max_label in ["Very Negative", "Negative", "Neutral"]:
116
  prompt = f"""
117
+ You are a product quality and customer experience specialist at an e-commerce food retailer.
118
 
119
  Customer Review:
120
  "{review}"
 
123
 
124
  Output only the three numbered recommendations (1–3), each with its title, detailed explanation, steps, and impact measure.
125
  """
126
+ # Ensure longer outputs by specifying generation parameters
127
+ response = generation_pipeline(
128
+ prompt,
129
+ max_new_tokens=300,
130
+ min_length=200,
131
+ do_sample=True,
132
+ temperature=0.7,
133
+ top_p=0.9,
134
+ no_repeat_ngram_size=2
135
+ )
136
  detailed = response[0]["generated_text"]
137
  st.markdown(detailed)
138
  else:
 
145
 
146
  if __name__ == "__main__":
147
  main()