Spaces:
Runtime error
Runtime error
Upload chatbot/retriever.py with huggingface_hub
Browse files- chatbot/retriever.py +9 -12
chatbot/retriever.py
CHANGED
|
@@ -1,9 +1,4 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Retriever wrapping the embedding pipeline.
|
| 3 |
-
|
| 4 |
-
Loads MedEmbed + Qdrant client once and exposes a simple `retrieve(query)` interface.
|
| 5 |
-
Filters out low-value sections (References, Application) that pollute results.
|
| 6 |
-
"""
|
| 7 |
|
| 8 |
import sys
|
| 9 |
import time
|
|
@@ -158,12 +153,14 @@ class PolicyRetriever:
|
|
| 158 |
page_end=p.get("page_end", 0),
|
| 159 |
))
|
| 160 |
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
|
|
|
|
|
|
| 165 |
for r in results:
|
| 166 |
-
|
| 167 |
-
r.score += COVERAGE_BOOST
|
| 168 |
|
|
|
|
| 169 |
return results
|
|
|
|
| 1 |
+
"""Policy retrieval via MedEmbed embeddings and Qdrant vector search."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
import sys
|
| 4 |
import time
|
|
|
|
| 153 |
page_end=p.get("page_end", 0),
|
| 154 |
))
|
| 155 |
|
| 156 |
+
SECTION_BOOST = {
|
| 157 |
+
"Coverage Rationale": 0.04,
|
| 158 |
+
"Coverage Summary": 0.03,
|
| 159 |
+
"Benefit Considerations": 0.01,
|
| 160 |
+
"Documentation Requirements": 0.01,
|
| 161 |
+
}
|
| 162 |
for r in results:
|
| 163 |
+
r.score += SECTION_BOOST.get(r.section, 0.0)
|
|
|
|
| 164 |
|
| 165 |
+
results.sort(key=lambda r: r.score, reverse=True)
|
| 166 |
return results
|