Pijush2023 commited on
Commit
cd230ad
·
verified ·
1 Parent(s): b34a3f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -89,12 +89,12 @@ embeddings = OpenAIEmbeddings(api_key=os.environ['OPENAI_API_KEY'])
89
  # Initialize the models
90
  def initialize_phi_model():
91
  model = AutoModelForCausalLM.from_pretrained(
92
- "microsoft/Phi-3.5-MoE-instruct",
93
  device_map="cuda",
94
  torch_dtype="auto",
95
  trust_remote_code=True,
96
  )
97
- tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3.5-MoE-instruct")
98
  return pipeline("text-generation", model=model, tokenizer=tokenizer)
99
 
100
  def initialize_gpt_model():
@@ -392,10 +392,8 @@ chain_neo4j = (
392
  # Short Prompt Template for Phi-3.5 Proprietary Model
393
 
394
  phi_short_template = f"""
395
- As an expert on Birmingham, Alabama, I will provide concise, accurate, and informative responses to your queries. Given the sunny weather today, {current_date}, feel free to ask me anything you need to know about the city.
396
-
397
  Provide only the direct answer to the question without any follow-up questions.
398
-
399
  {{context}}
400
  Question: {{question}}
401
  Answer:
@@ -456,7 +454,7 @@ def generate_answer(message, choice, retrieval_mode, selected_model):
456
  logging.debug(f"Phi-3.5 Prompt: {prompt}")
457
 
458
  response = selected_model(prompt, **{
459
- "max_new_tokens": 128, # Increased to handle longer responses
460
  "return_full_text": False,
461
  "temperature": 0.7, # Adjusted to avoid cutting off
462
  "do_sample": True, # Allow sampling to increase response diversity
 
89
  # Initialize the models
90
  def initialize_phi_model():
91
  model = AutoModelForCausalLM.from_pretrained(
92
+ "microsoft/Phi-3.5-mini-instruct",
93
  device_map="cuda",
94
  torch_dtype="auto",
95
  trust_remote_code=True,
96
  )
97
+ tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3.5-mini-instruct")
98
  return pipeline("text-generation", model=model, tokenizer=tokenizer)
99
 
100
  def initialize_gpt_model():
 
392
  # Short Prompt Template for Phi-3.5 Proprietary Model
393
 
394
  phi_short_template = f"""
395
+ As an expert on Birmingham, Alabama, I will provide concise, accurate, and informative responses to your queries based on 256 token limit . Given the sunny weather today, {current_date}, feel free to ask me anything you need to know about the city.
 
396
  Provide only the direct answer to the question without any follow-up questions.
 
397
  {{context}}
398
  Question: {{question}}
399
  Answer:
 
454
  logging.debug(f"Phi-3.5 Prompt: {prompt}")
455
 
456
  response = selected_model(prompt, **{
457
+ "max_new_tokens": 256, # Increased to handle longer responses
458
  "return_full_text": False,
459
  "temperature": 0.7, # Adjusted to avoid cutting off
460
  "do_sample": True, # Allow sampling to increase response diversity