Spaces:
Running
Running
Updated mistral model to Mistral-7B-Instruct-v0.3
Browse files
app.py
CHANGED
@@ -12,7 +12,7 @@ from utils import get_md_text_abstract, search_cleaner, get_arxiv_live_search
|
|
12 |
|
13 |
retrieve_results = 10
|
14 |
show_examples = False
|
15 |
-
llm_models_to_choose = ['mistralai/Mixtral-8x7B-Instruct-v0.1','mistralai/Mistral-7B-Instruct-v0.
|
16 |
|
17 |
token = os.getenv("HF_TOKEN")
|
18 |
|
@@ -82,7 +82,7 @@ def rag_cleaner(inp):
|
|
82 |
date = inp['document_metadata']['_time']
|
83 |
return f"{rank}. <b> {title} </b> \n Date : {date} \n Abstract: {content}"
|
84 |
|
85 |
-
def get_prompt_text(question, context, formatted = True, llm_model_picked = 'mistralai/Mistral-7B-Instruct-v0.
|
86 |
if formatted:
|
87 |
sys_instruction = f"Context:\n {context} \n Given the following scientific paper abstracts, take a deep breath and lets think step by step to answer the question. Cite the titles of your sources when answering, do not cite links or dates."
|
88 |
message = f"Question: {question}"
|
@@ -110,7 +110,7 @@ with gr.Blocks(theme = gr.themes.Soft()) as demo:
|
|
110 |
|
111 |
with gr.Accordion("Advanced Settings", open=False):
|
112 |
with gr.Row(equal_height = True):
|
113 |
-
llm_model = gr.Dropdown(choices = llm_models_to_choose, value = 'mistralai/Mistral-7B-Instruct-v0.
|
114 |
llm_results = gr.Slider(minimum=4, maximum=10, value=5, step=1, interactive=True, label="Top n results as context")
|
115 |
database_src = gr.Dropdown(choices = database_choices, value = index_info, label = 'Search Source')
|
116 |
stream_results = gr.Checkbox(value = True, label = "Stream output", visible = False)
|
@@ -119,7 +119,7 @@ with gr.Blocks(theme = gr.themes.Soft()) as demo:
|
|
119 |
input = gr.Textbox(show_label = False, visible = False)
|
120 |
gr_md = gr.Markdown(mark_text + md_text_initial)
|
121 |
|
122 |
-
def update_with_rag_md(message, llm_results_use = 5, database_choice = index_info, llm_model_picked = 'mistralai/Mistral-7B-Instruct-v0.
|
123 |
prompt_text_from_data = ""
|
124 |
database_to_use = database_choice
|
125 |
if database_choice == index_info:
|
@@ -151,7 +151,7 @@ with gr.Blocks(theme = gr.themes.Soft()) as demo:
|
|
151 |
prompt = get_prompt_text(message, prompt_text_from_data, llm_model_picked = llm_model_picked)
|
152 |
return md_text_updated, prompt
|
153 |
|
154 |
-
def ask_llm(prompt, llm_model_picked = 'mistralai/Mistral-7B-Instruct-v0.
|
155 |
model_disabled_text = "LLM Model is disabled"
|
156 |
output = ""
|
157 |
|
|
|
12 |
|
13 |
retrieve_results = 10
|
14 |
show_examples = False
|
15 |
+
llm_models_to_choose = ['mistralai/Mixtral-8x7B-Instruct-v0.1','mistralai/Mistral-7B-Instruct-v0.3', 'google/gemma-2-2b-it', 'None']
|
16 |
|
17 |
token = os.getenv("HF_TOKEN")
|
18 |
|
|
|
82 |
date = inp['document_metadata']['_time']
|
83 |
return f"{rank}. <b> {title} </b> \n Date : {date} \n Abstract: {content}"
|
84 |
|
85 |
+
def get_prompt_text(question, context, formatted = True, llm_model_picked = 'mistralai/Mistral-7B-Instruct-v0.3'):
|
86 |
if formatted:
|
87 |
sys_instruction = f"Context:\n {context} \n Given the following scientific paper abstracts, take a deep breath and lets think step by step to answer the question. Cite the titles of your sources when answering, do not cite links or dates."
|
88 |
message = f"Question: {question}"
|
|
|
110 |
|
111 |
with gr.Accordion("Advanced Settings", open=False):
|
112 |
with gr.Row(equal_height = True):
|
113 |
+
llm_model = gr.Dropdown(choices = llm_models_to_choose, value = 'mistralai/Mistral-7B-Instruct-v0.3', label = 'LLM Model')
|
114 |
llm_results = gr.Slider(minimum=4, maximum=10, value=5, step=1, interactive=True, label="Top n results as context")
|
115 |
database_src = gr.Dropdown(choices = database_choices, value = index_info, label = 'Search Source')
|
116 |
stream_results = gr.Checkbox(value = True, label = "Stream output", visible = False)
|
|
|
119 |
input = gr.Textbox(show_label = False, visible = False)
|
120 |
gr_md = gr.Markdown(mark_text + md_text_initial)
|
121 |
|
122 |
+
def update_with_rag_md(message, llm_results_use = 5, database_choice = index_info, llm_model_picked = 'mistralai/Mistral-7B-Instruct-v0.3'):
|
123 |
prompt_text_from_data = ""
|
124 |
database_to_use = database_choice
|
125 |
if database_choice == index_info:
|
|
|
151 |
prompt = get_prompt_text(message, prompt_text_from_data, llm_model_picked = llm_model_picked)
|
152 |
return md_text_updated, prompt
|
153 |
|
154 |
+
def ask_llm(prompt, llm_model_picked = 'mistralai/Mistral-7B-Instruct-v0.3', stream_outputs = False):
|
155 |
model_disabled_text = "LLM Model is disabled"
|
156 |
output = ""
|
157 |
|