Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -44,7 +44,7 @@ def retrieve_relevant_doc(query):
|
|
44 |
def generate_response(query):
|
45 |
relevant_doc = retrieve_relevant_doc(query)
|
46 |
if len(relevant_doc) > 512: # Truncate long documents
|
47 |
-
relevant_doc = summarizer(relevant_doc, max_length=
|
48 |
|
49 |
input_text = f"Document: {relevant_doc}\n\nQuestion: {query}\n\nAnswer:"
|
50 |
inputs = llama_tokenizer(input_text, return_tensors="pt").to(device)
|
@@ -54,7 +54,7 @@ def generate_response(query):
|
|
54 |
outputs = llama_model.generate(
|
55 |
inputs["input_ids"],
|
56 |
attention_mask=inputs["attention_mask"],
|
57 |
-
max_length=
|
58 |
pad_token_id=pad_token_id
|
59 |
)
|
60 |
|
|
|
44 |
def generate_response(query):
|
45 |
relevant_doc = retrieve_relevant_doc(query)
|
46 |
if len(relevant_doc) > 512: # Truncate long documents
|
47 |
+
relevant_doc = summarizer(relevant_doc, max_length=4096, min_length=50, do_sample=False)[0]['summary_text']
|
48 |
|
49 |
input_text = f"Document: {relevant_doc}\n\nQuestion: {query}\n\nAnswer:"
|
50 |
inputs = llama_tokenizer(input_text, return_tensors="pt").to(device)
|
|
|
54 |
outputs = llama_model.generate(
|
55 |
inputs["input_ids"],
|
56 |
attention_mask=inputs["attention_mask"],
|
57 |
+
max_length=512,
|
58 |
pad_token_id=pad_token_id
|
59 |
)
|
60 |
|