optimize debug retrieval

This commit is contained in:
team2
2026-03-01 20:27:43 +01:00
parent 4a619cd6a8
commit 7b6d8f7269
3 changed files with 18 additions and 14 deletions

View File

@@ -16,7 +16,7 @@ use App\Vector\VectorSearchClient;
final class NdjsonHybridRetriever implements RetrieverInterface final class NdjsonHybridRetriever implements RetrieverInterface
{ {
private const VECTOR_SCORE_THRESHOLD = 0.72; private const VECTOR_SCORE_THRESHOLD = 0.82;
// Guardrails // Guardrails
private const HARD_MAX_CHUNKS = 90; private const HARD_MAX_CHUNKS = 90;
@@ -45,7 +45,8 @@ final class NdjsonHybridRetriever implements RetrieverInterface
private readonly CatalogIntentLite $catalogIntent, private readonly CatalogIntentLite $catalogIntent,
private readonly IntentRouteResolver $routeResolver, private readonly IntentRouteResolver $routeResolver,
private readonly EntityCatalogService $entityCatalogService private readonly EntityCatalogService $entityCatalogService
) { )
{
} }
// ========================================================= // =========================================================
@@ -123,9 +124,9 @@ final class NdjsonHybridRetriever implements RetrieverInterface
* text:string * text:string
* }> * }>
*/ */
public function retrieveDebug(string $prompt): array public function retrieveDebug(string $prompt, ?ModelGenerationConfig $config = null): array
{ {
$config = $this->configRepository->findActiveForModel(); $config = $config ?? $this->configRepository->findActiveForModel();
if ($config === null) { if ($config === null) {
throw new \RuntimeException('No active ModelGenerationConfig found.'); throw new \RuntimeException('No active ModelGenerationConfig found.');
@@ -193,11 +194,12 @@ final class NdjsonHybridRetriever implements RetrieverInterface
* } * }
*/ */
private function runCore( private function runCore(
string $prompt, string $prompt,
ModelGenerationConfig $config, ModelGenerationConfig $config,
bool $withScores, bool $withScores,
string $salesIntent string $salesIntent
): array { ): array
{
$limit = max(1, min($config->getRetrievalMaxChunks(), self::HARD_MAX_CHUNKS)); $limit = max(1, min($config->getRetrievalMaxChunks(), self::HARD_MAX_CHUNKS));
$vectorTopKBase = max(1, min($config->getRetrievalVectorTopK(), self::HARD_MAX_VECTORK)); $vectorTopKBase = max(1, min($config->getRetrievalVectorTopK(), self::HARD_MAX_VECTORK));
@@ -338,9 +340,10 @@ final class NdjsonHybridRetriever implements RetrieverInterface
array $globalHits, array $globalHits,
array $scopedHits, array $scopedHits,
float $threshold, float $threshold,
bool $boostScoped, bool $boostScoped,
bool $captureRaw bool $captureRaw
): array { ): array
{
$rrfScores = []; $rrfScores = [];
$rawScores = []; $rawScores = [];

View File

@@ -74,7 +74,7 @@ final class ModelGenerationConfigAdminService
return []; return [];
} }
return $this->retriever->retrieveDebug($prompt); return $this->retriever->retrieveDebug($prompt,$config);
} }
private function requireString(mixed $value, string $field): string private function requireString(mixed $value, string $field): string

View File

@@ -89,10 +89,11 @@
href="{{ path('admin_document_show', { id: chunk.document_id }) }}"> href="{{ path('admin_document_show', { id: chunk.document_id }) }}">
{{ chunk.document_id }} {{ chunk.document_id }}
</a></span> | </a></span> |
<span><strong>raw_score:</strong> {{ chunk.raw_score|number_format(6, '.', '') }}</span>
|
<span><strong>rrf_score:</strong> {{ chunk.rrf_score|number_format(6, '.', '') }}</span> <span><strong>rrf_score:</strong> {{ chunk.rrf_score|number_format(6, '.', '') }}</span>
| |
<span><strong>raw_score:</strong> {{ chunk.raw_score|number_format(6, '.', '') }}</span>
|
<span><strong>threshold:</strong> {{ chunk.threshold }}</span> | <span><strong>threshold:</strong> {{ chunk.threshold }}</span> |
<span><strong>intent:</strong> {{ chunk.intent }}</span> | <span><strong>intent:</strong> {{ chunk.intent }}</span> |
<span> <span>