Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -119,7 +119,7 @@ def answer_question(question):
|
|
119 |
Answer a question using retrieved context and DistilBERT QA (PyTorch).
|
120 |
Retrieves top 2 paragraphs to improve answer accuracy.
|
121 |
If total context exceeds 512 tokens (DistilBERT's max length), it will be truncated automatically.
|
122 |
-
Ensures answers are one line (max 100 chars).
|
123 |
"""
|
124 |
global corpus, embeddings, sources_list
|
125 |
if not corpus or embeddings is None:
|
@@ -144,10 +144,6 @@ def answer_question(question):
|
|
144 |
answer = result['answer']
|
145 |
confidence = result['score']
|
146 |
|
147 |
-
# Check confidence threshold
|
148 |
-
if confidence < 0.3:
|
149 |
-
return f"Unable to answer (confidence {confidence:.2f} below 0.3)."
|
150 |
-
|
151 |
# Truncate answer to one line
|
152 |
answer = truncate_to_one_line(answer)
|
153 |
# Ensure at least one line
|
|
|
119 |
Answer a question using retrieved context and DistilBERT QA (PyTorch).
|
120 |
Retrieves top 2 paragraphs to improve answer accuracy.
|
121 |
If total context exceeds 512 tokens (DistilBERT's max length), it will be truncated automatically.
|
122 |
+
Ensures answers are one line (max 100 chars).
|
123 |
"""
|
124 |
global corpus, embeddings, sources_list
|
125 |
if not corpus or embeddings is None:
|
|
|
144 |
answer = result['answer']
|
145 |
confidence = result['score']
|
146 |
|
|
|
|
|
|
|
|
|
147 |
# Truncate answer to one line
|
148 |
answer = truncate_to_one_line(answer)
|
149 |
# Ensure at least one line
|