RalphThings commited on
Commit
e7af338
·
verified ·
1 Parent(s): 38bf178

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -9
app.py CHANGED
@@ -34,16 +34,11 @@ class BasicAgent:
34
  # Run the model
35
  out = self.generator(
36
  prompt,
37
- max_length=len(prompt.split()) + 20, # short answer
38
- num_return_sequences=1,
39
- pad_token_id=self.generator.tokenizer.eos_token_id
40
  )
41
- # Extract the portion after "A:"
42
- text = out[0]["generated_text"]
43
- # split on the last "\nA:" or just on "A:" if needed
44
- answer = text.split("\nA:")[-1].strip()
45
- # final cleanup: no newlines, no trailing punctuation
46
- return answer.replace("\n", " ").strip()
47
 
48
  def run_and_submit_all( profile: gr.OAuthProfile | None):
49
  """
 
34
  # Run the model
35
  out = self.generator(
36
  prompt,
37
+ max_new_tokens=16, # leave room for the answer
38
+ return_full_text=False
 
39
  )
40
+ answer = out[0]["generated_text"].strip()
41
+ return answer
 
 
 
 
42
 
43
  def run_and_submit_all( profile: gr.OAuthProfile | None):
44
  """