Nav772 commited on
Commit
211979b
·
verified ·
1 Parent(s): a72e2e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -15,20 +15,20 @@ from transformers import pipeline
15
 
16
  class BasicAgent:
17
  def __init__(self):
18
- print("FLAN-T5-BASE Local Agent initialized.")
19
 
20
  self.pipeline = pipeline(
21
  "text2text-generation",
22
- model="google/flan-t5-base",
23
- tokenizer="google/flan-t5-base",
24
- device=-1 # use CPU
25
  )
26
 
27
  def __call__(self, question: str) -> str:
28
  print(f"Agent received question (first 50 chars): {question[:50]}...")
29
 
30
  try:
31
- prompt = f"Answer the following question:\n{question.strip()}"
32
  result = self.pipeline(prompt, max_new_tokens=128, temperature=0.5)
33
  answer = result[0]["generated_text"]
34
  return answer.strip()
 
15
 
16
  class BasicAgent:
17
  def __init__(self):
18
+ print("FLAN-ALPACA-BASE Local Agent initialized.")
19
 
20
  self.pipeline = pipeline(
21
  "text2text-generation",
22
+ model="declare-lab/flan-alpaca-base",
23
+ tokenizer="declare-lab/flan-alpaca-base",
24
+ device=-1 # CPU
25
  )
26
 
27
  def __call__(self, question: str) -> str:
28
  print(f"Agent received question (first 50 chars): {question[:50]}...")
29
 
30
  try:
31
+ prompt = f"### Instruction:\n{question.strip()}\n\n### Response:"
32
  result = self.pipeline(prompt, max_new_tokens=128, temperature=0.5)
33
  answer = result[0]["generated_text"]
34
  return answer.strip()