fix: RAG threshold 0.83 + расширенные паттерны ресурсного поиска
Тест 205 запросов выявил: 1. Порог 0.5 бесполезен (все scores 0.79-0.89) → повышен до 0.83 2. Normative RAG затенял Resources и CAG → теперь параллельно 3. Ресурсный поиск срабатывал на 6 слов → расширен до 30+ паттернов Результат: "рецепт борща" отсекается, "индексы Q1 2026" находится. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+10
-3
@@ -94,7 +94,7 @@ def _search_normative(query: str, top_k: int = 3) -> str:
|
||||
|
||||
results = []
|
||||
for dist, idx in zip(D[0], I[0]):
|
||||
if dist < 0.5: # skip low relevance
|
||||
if dist < 0.83: # e5-base scores cluster 0.79-0.89; 0.83 balances precision/recall
|
||||
continue
|
||||
m = _norm_metadata[idx]
|
||||
results.append(f"[{m['source']}] {m['full_text'][:500]}")
|
||||
@@ -245,9 +245,16 @@ async def stream_claude(
|
||||
|
||||
work_dir = get_work_dir(username, tab_id)
|
||||
|
||||
# Search resources if question looks like a GESN lookup
|
||||
# Search resources if question mentions works/norms/materials
|
||||
resource_context = ""
|
||||
gesn_patterns = ["расценк", "гэсн", "норм", "28-", "01-", "единиц"]
|
||||
gesn_patterns = [
|
||||
"расценк", "гэсн", "норм", "28-", "01-", "единиц",
|
||||
"земляны", "бетон", "монтаж", "насыпь", "балласт", "рельс",
|
||||
"стрелоч", "шпал", "щебен", "щебн", "укладк", "разборк",
|
||||
"кровел", "штукатур", "гидроизоляц", "теплоизоляц", "трубопровод",
|
||||
"кабел", "электромонтаж", "сантехн", "вентиляц", "благоустр",
|
||||
"сварочн", "устройство", "ремонт пути", "всп", "сцб",
|
||||
]
|
||||
if any(p in message.lower() for p in gesn_patterns):
|
||||
resource_context = _search_resources(message)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user