bibekyess commited on
Commit
d0f9757
·
1 Parent(s): e376ea5

Updates to give context as the top 2 relevant document chunks

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -57,7 +57,7 @@ def load_model():
57
  # "MBZUAI/LaMini-Flan-T5-783M"
58
 
59
  tokenizer = AutoTokenizer.from_pretrained("Xenova/LaMini-Flan-T5-783M")
60
- model = ORTModelForSeq2SeqLM.from_pretrained("Xenova/LaMini-Flan-T5-783M", subfolder = "onnx", decoder_file_name="decoder_with_past_model.onnx")
61
 
62
  return tokenizer, model
63
 
@@ -100,7 +100,9 @@ if user_input:
100
  else:
101
  tokenizer, model = load_model()
102
  docs = db.similarity_search(user_input)
103
- output = wrap_text_preserve_newlines(str(docs[0]))
 
 
104
  if tag in ["welcome", "thanks", "exit"]:
105
  input = user_input
106
  elif tag in ["BibekBOT-introduction"]:
@@ -114,7 +116,7 @@ if user_input:
114
  end_prompt = "\nPlease make meaningful sentence and try to be descriptive as possible responding with many sentences and ending with proper punctuations. If you think the content doesn't contain good answer to the question, give some polite respones telling them that you do not have specific response to the query and apologize and refer them to contact Bibek directly.\n" # NoQA"
115
  short_response_template = "\nIf your response is very short like 1 or 2 sentence, add a followup sentence like 'Let me know if there's anything else I can help you with. or If there's anything else I can assist with, please don't hesitate to ask. I mean something similar in polite way." # NoQA
116
 
117
- input = task_description_prompt + output + prompt_template + user_input + end_prompt
118
 
119
  input_ids = tokenizer(
120
  input,
 
57
  # "MBZUAI/LaMini-Flan-T5-783M"
58
 
59
  tokenizer = AutoTokenizer.from_pretrained("Xenova/LaMini-Flan-T5-783M")
60
+ model = ORTModelForSeq2SeqLM.from_pretrained("Xenova/LaMini-Flan-T5-783M", subfolder = "onnx")
61
 
62
  return tokenizer, model
63
 
 
100
  else:
101
  tokenizer, model = load_model()
102
  docs = db.similarity_search(user_input)
103
+ output1 = wrap_text_preserve_newlines(str(docs[0]))
104
+ output2 = wrap_text_preserve_newlines(str(docs[1]))
105
+
106
  if tag in ["welcome", "thanks", "exit"]:
107
  input = user_input
108
  elif tag in ["BibekBOT-introduction"]:
 
116
  end_prompt = "\nPlease make meaningful sentence and try to be descriptive as possible responding with many sentences and ending with proper punctuations. If you think the content doesn't contain good answer to the question, give some polite respones telling them that you do not have specific response to the query and apologize and refer them to contact Bibek directly.\n" # NoQA"
117
  short_response_template = "\nIf your response is very short like 1 or 2 sentence, add a followup sentence like 'Let me know if there's anything else I can help you with. or If there's anything else I can assist with, please don't hesitate to ask. I mean something similar in polite way." # NoQA
118
 
119
+ input = task_description_prompt + output1+ "\n" +output2 + prompt_template + user_input + end_prompt
120
 
121
  input_ids = tokenizer(
122
  input,