Spaces:
Paused
Paused
derek-thomas commited on
Commit ·
0d73887
1
Parent(s): 9a37e5b
Turning HyDe on!
Browse files1 unmodified line23456717 unmodified lines2526272829303112 unmodified lines44454647484950515253545568 unmodified lines1241251261271281291301311321331341351361371 unmodified linesubprocess.run(["pip", "install", "--upgrade", "transformers[torch,sentencepiece]==4.34.1"])import loggingfrom pathlib import Pathfrom time import perf_counter17 unmodified linestemplate_html = env.get_template('template_html.j2')# Examplesexamples = ['What is the capital of China, I think its Shanghai?','Why is the sky blue?','Who won the mens world cup in 2014?', ]12 unmodified lines# Retrieve documents relevant to querydocument_start = perf_counter()if hyde:complete_output = ""generator = generate(f"Write a wikipedia article intro paragraph to answer this query: {query}", history)for output_chunk in generator:complete_output += output_chunkdocuments = qd_retriever.retrieve(query, top_k=top_k)document_time = document_start - perf_counter()logger.warning(f'Finished Retrieving documents in {round(document_time, 2)} seconds...')# Create Prompt68 unmodified lineshyde_prompt_html = gr.HTML()# Turn off interactivity while generating if you clickhyde_txt_msg = hyde_txt_btn.click(add_text, [hyde_chatbot, hyde_txt], [hyde_chatbot, hyde_txt], queue=False).then(bot, hyde_chatbot, [hyde_chatbot, hyde_prompt_html])# Turn it back onhyde_txt_msg.then(lambda: gr.Textbox(interactive=True), None, [hyde_txt], queue=False)# Turn off interactivity while generating if you hit enterhyde_txt_msg = hyde_txt.submit(add_text, [hyde_chatbot, hyde_txt], [hyde_chatbot, hyde_txt], queue=False).then(bot, hyde_chatbot, [hyde_chatbot, hyde_prompt_html])# Turn it back onhyde_txt_msg.then(lambda: gr.Textbox(interactive=True), None, [hyde_txt], queue=False)1 unmodified line234567817 unmodified lines2627282930313212 unmodified lines4546474849505152535455565758596068 unmodified lines1291301311321331341351361371381391401411421 unmodified linesubprocess.run(["pip", "install", "--upgrade", "transformers[torch,sentencepiece]==4.34.1"])from functools import partialimport loggingfrom pathlib import Pathfrom time import perf_counter17 unmodified linestemplate_html = env.get_template('template_html.j2')# Examplesexamples = ['What is the capital of China?','Why is the sky blue?','Who won the mens world cup in 2014?', ]12 unmodified lines# Retrieve documents relevant to querydocument_start = perf_counter()if hyde:hyde_document = ""generator = generate(f"Write a wikipedia article intro paragraph to answer this query: {query}", history)for output_chunk in generator:hyde_document = output_chunklogger.warning(hyde_document)documents = qd_retriever.retrieve(hyde_document, top_k=top_k)else:documents = qd_retriever.retrieve(query, top_k=top_k)document_time = perf_counter() - document_startlogger.warning(f'Finished Retrieving documents in {round(document_time, 2)} seconds...')# Create Prompt68 unmodified lineshyde_prompt_html = gr.HTML()# Turn off interactivity while generating if you clickhyde_txt_msg = hyde_txt_btn.click(add_text, [hyde_chatbot, hyde_txt], [hyde_chatbot, hyde_txt], queue=False).then(partial(bot, hyde=True), [hyde_chatbot], [hyde_chatbot, hyde_prompt_html])# Turn it back onhyde_txt_msg.then(lambda: gr.Textbox(interactive=True), None, [hyde_txt], queue=False)# Turn off interactivity while generating if you hit enterhyde_txt_msg = hyde_txt.submit(add_text, [hyde_chatbot, hyde_txt], [hyde_chatbot, hyde_txt], queue=False).then(partial(bot, hyde=True), [hyde_chatbot], [hyde_chatbot, hyde_prompt_html])# Turn it back onhyde_txt_msg.then(lambda: gr.Textbox(interactive=True), None, [hyde_txt], queue=False)
app.py+12-7