feat(agent): tune retrieval for decision support
This commit is contained in:
+17
-3
@@ -13,7 +13,7 @@ import numpy as np
|
||||
from .config import Config
|
||||
from .normalize import fts_query
|
||||
from .ollama_client import OllamaClient
|
||||
from .query_planner import SubQuery
|
||||
from .query_planner import SubQuery, decision_support_plan
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -386,8 +386,18 @@ class Retriever:
|
||||
return main + extra
|
||||
|
||||
def search(self, question: str, n_entries: int | None = None) -> list[ChunkResult]:
|
||||
"""Liefert die Top-Kontextblöcke (Hauptretrieval + cross_ref-Erweiterung)."""
|
||||
"""Liefert die Top-Kontextblöcke (Hauptretrieval + cross_ref-Erweiterung).
|
||||
|
||||
Gestaltungsfragen zu zusätzlichen Arbeitnehmerleistungen werden
|
||||
deterministisch in Direktzahlung und Alternativen zerlegt. Das gilt
|
||||
auch für den Offline-Retrieval-Eval, der keinen LLM-Planer aufruft.
|
||||
"""
|
||||
n = n_entries or self.cfg.context_blocks
|
||||
latest_year = str(self._stand_max)[:4]
|
||||
deterministic = decision_support_plan(question, default_year=latest_year)
|
||||
if deterministic:
|
||||
sub_queries, _qtype = deterministic
|
||||
return self.search_multi(sub_queries, n_entries=n)
|
||||
fused, bm_all, dn_all = self._fuse_queries(
|
||||
[SubQuery(text=question)], self.cfg.candidate_pool
|
||||
)
|
||||
@@ -403,7 +413,11 @@ class Retriever:
|
||||
mehreren Sub-Queries mittelgut matchen). Temporal-Intent: kv-
|
||||
Einträge im gefragten Geltungsjahr erhalten temporal_boost."""
|
||||
n = n_entries or self.cfg.context_blocks
|
||||
if len(sub_queries) == 1:
|
||||
if (
|
||||
len(sub_queries) == 1
|
||||
and sub_queries[0].scope is None
|
||||
and sub_queries[0].stand_year is None
|
||||
):
|
||||
return self.search(sub_queries[0].text, n_entries=n)
|
||||
pool = self.cfg.candidate_pool
|
||||
fused_total: dict[int, float] = {}
|
||||
|
||||
Reference in New Issue
Block a user