Anil777K commited on
Commit
3aaa897
·
verified ·
1 Parent(s): 4e55708

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -19,8 +19,8 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
19
  print("Loading local model...")
20
 
21
  generator = pipeline(
22
- "text2text-generation",
23
- model="google/flan-t5-base",
24
  device_map="auto"
25
  )
26
 
@@ -61,9 +61,11 @@ Answer:
61
 
62
  text = result[0]["generated_text"]
63
 
64
- answer = text.strip()
 
 
 
65
 
66
- # cleanup
67
  answer = answer.split("\n")[0].strip()
68
 
69
  return answer
@@ -207,7 +209,7 @@ Answer:
207
 
208
  if "what year" in q:
209
 
210
- years = re.findall(r'\b(19|20)\d{2}\b', question)
211
 
212
  if years:
213
  return years[0]
 
19
  print("Loading local model...")
20
 
21
  generator = pipeline(
22
+ "text-generation",
23
+ model="TinyLlama/TinyLlama-1.1B-Chat-v1.0",
24
  device_map="auto"
25
  )
26
 
 
61
 
62
  text = result[0]["generated_text"]
63
 
64
+ if "Answer:" in text:
65
+ answer = text.split("Answer:")[-1].strip()
66
+ else:
67
+ answer = text.strip()
68
 
 
69
  answer = answer.split("\n")[0].strip()
70
 
71
  return answer
 
209
 
210
  if "what year" in q:
211
 
212
+ years = re.findall(r'\b(?:19|20)\d{2}\b', question)
213
 
214
  if years:
215
  return years[0]