Spaces:
Sleeping
Sleeping
Commit
·
cec952b
1
Parent(s):
7f1b3e7
Update app.py
Browse files
app.py
CHANGED
@@ -11,13 +11,16 @@ from llama_index.llms import LangChainLLM
|
|
11 |
|
12 |
repo_id = 'HuggingFaceH4/zephyr-7b-beta'
|
13 |
|
|
|
|
|
|
|
14 |
def loading_paper(): return 'Loading...'
|
15 |
|
16 |
-
def paper_changes(paper_id):
|
17 |
paper = next(arxiv.Client().results(arxiv.Search(id_list=[paper_id])))
|
18 |
docs = SimpleDirectoryReader(input_files=[paper.download_pdf()]).load_data()
|
19 |
doc = Document(text='\n\n'.join([doc.text for doc in docs]))
|
20 |
-
llm = LangChainLLM(llm=HuggingFaceHub(repo_id=repo_id, model_kwargs={'temperature':
|
21 |
service_context = ServiceContext.from_defaults(llm=llm, embed_model="local:BAAI/bge-small-en-v1.5")
|
22 |
index = VectorStoreIndex.from_documents([doc], service_context=service_context)
|
23 |
global query_engine
|
@@ -50,7 +53,12 @@ with gr.Blocks(theme='WeixuanYuan/Soft_dark') as demo:
|
|
50 |
question = gr.Textbox(label='Question', placeholder='Type your query...')
|
51 |
submit_btn = gr.Button('Submit')
|
52 |
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
54 |
question.submit(add_text, [chatbot, question], [chatbot, question]).then(bot, chatbot, chatbot)
|
55 |
submit_btn.click(add_text, [chatbot, question], [chatbot, question]).then(bot, chatbot, chatbot)
|
56 |
|
|
|
11 |
|
12 |
repo_id = 'HuggingFaceH4/zephyr-7b-beta'
|
13 |
|
14 |
+
MAX_MAX_NEW_TOKENS = 10240
|
15 |
+
DEFAULT_MAX_NEW_TOKENS = 4096
|
16 |
+
|
17 |
def loading_paper(): return 'Loading...'
|
18 |
|
19 |
+
def paper_changes(paper_id, temperature=0.2, max_tokens=4096, top_p=0.9):
|
20 |
paper = next(arxiv.Client().results(arxiv.Search(id_list=[paper_id])))
|
21 |
docs = SimpleDirectoryReader(input_files=[paper.download_pdf()]).load_data()
|
22 |
doc = Document(text='\n\n'.join([doc.text for doc in docs]))
|
23 |
+
llm = LangChainLLM(llm=HuggingFaceHub(repo_id=repo_id, model_kwargs={'temperature': temperature, 'max_tokens': max_tokens, 'top_p': top_p}))
|
24 |
service_context = ServiceContext.from_defaults(llm=llm, embed_model="local:BAAI/bge-small-en-v1.5")
|
25 |
index = VectorStoreIndex.from_documents([doc], service_context=service_context)
|
26 |
global query_engine
|
|
|
53 |
question = gr.Textbox(label='Question', placeholder='Type your query...')
|
54 |
submit_btn = gr.Button('Submit')
|
55 |
|
56 |
+
with gr.Accordion(label='Advanced options', open=False):
|
57 |
+
max_new_tokens = gr.Slider(label='Max New Tokens', minimum=1, maximum=MAX_MAX_NEW_TOKENS, step=1, value=DEFAULT_MAX_NEW_TOKENS)
|
58 |
+
temperature = gr.Slider(label='Temperature', minimum=0.1, maximum=4.0, step=0.1, value=0.1)
|
59 |
+
top_p = gr.Slider(label='Top-P (nucleus sampling)', minimum=0.05, maximum=1.0, step=0.05, value=0.9)
|
60 |
+
|
61 |
+
load_paper.click(paper_changes, inputs=[paper_id, temperature, max_new_tokens, top_p], outputs=[langchain_status], queue=False)
|
62 |
question.submit(add_text, [chatbot, question], [chatbot, question]).then(bot, chatbot, chatbot)
|
63 |
submit_btn.click(add_text, [chatbot, question], [chatbot, question]).then(bot, chatbot, chatbot)
|
64 |
|