Spaces:
Running
on
Zero
Running
on
Zero
Update qa_summary.py
Browse files- qa_summary.py +4 -1
qa_summary.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
2 |
|
3 |
|
4 |
-
def generate_answer(llm_name, texts, query, mode='validate'):
|
5 |
|
6 |
if llm_name == 'solar':
|
7 |
tokenizer = AutoTokenizer.from_pretrained("Upstage/SOLAR-10.7B-Instruct-v1.0", use_fast=True)
|
@@ -38,6 +38,9 @@ def generate_answer(llm_name, texts, query, mode='validate'):
|
|
38 |
conversation = [ {'role': 'user', 'content': f'For the following query and documents, try to answer the given query based on the documents.\nQuery: {query} \nDocuments: {template_texts}.'} ]
|
39 |
elif mode == 'h_summarize':
|
40 |
conversation = [ {'role': 'user', 'content': f'The documents below describe a developing disaster event. Based on these documents, write a brief summary in the form of a paragraph, highlighting the most crucial information. \nDocuments: {template_texts}'} ]
|
|
|
|
|
|
|
41 |
|
42 |
prompt = tokenizer.apply_chat_template(conversation, tokenize=False, add_generation_prompt=True)
|
43 |
inputs = tokenizer(prompt, return_tensors="pt").to(llm_model.device)
|
|
|
1 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
2 |
|
3 |
|
4 |
+
def generate_answer(llm_name, texts, query, queries, mode='validate'):
|
5 |
|
6 |
if llm_name == 'solar':
|
7 |
tokenizer = AutoTokenizer.from_pretrained("Upstage/SOLAR-10.7B-Instruct-v1.0", use_fast=True)
|
|
|
38 |
conversation = [ {'role': 'user', 'content': f'For the following query and documents, try to answer the given query based on the documents.\nQuery: {query} \nDocuments: {template_texts}.'} ]
|
39 |
elif mode == 'h_summarize':
|
40 |
conversation = [ {'role': 'user', 'content': f'The documents below describe a developing disaster event. Based on these documents, write a brief summary in the form of a paragraph, highlighting the most crucial information. \nDocuments: {template_texts}'} ]
|
41 |
+
elif mode == "multi_summarize":
|
42 |
+
conversation = [ {'role': 'user', 'content': f'For the following queries and documents, try to answer the given queries based on the documents.\nQueries: {queries} \nDocuments: {template_texts}.'} ]
|
43 |
+
|
44 |
|
45 |
prompt = tokenizer.apply_chat_template(conversation, tokenize=False, add_generation_prompt=True)
|
46 |
inputs = tokenizer(prompt, return_tensors="pt").to(llm_model.device)
|