optimize intents

This commit is contained in:
team2
2026-02-27 07:12:36 +01:00
parent 26ee95cadd
commit 2713da1afb
2 changed files with 155 additions and 18 deletions

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Knowledge\Retrieval;
use App\Entity\ModelGenerationConfig;
use App\Intent\IntentLite;
use App\Knowledge\ChunkManager;
use App\Knowledge\QueryCleaner;
use App\Repository\ModelGenerationConfigRepository;
@@ -25,12 +26,15 @@ final class NdjsonHybridRetriever implements RetrieverInterface
private const TAG_SCORE_BONUS = 0.08;
public function __construct(
private readonly NdjsonChunkLookup $lookup,
private readonly VectorSearchClient $vectorClient,
private readonly TagRoutingService $tagRouting,
private readonly NdjsonChunkLookup $lookup,
private readonly VectorSearchClient $vectorClient,
private readonly TagRoutingService $tagRouting,
private readonly ModelGenerationConfigRepository $configRepository,
private readonly QueryCleaner $queryCleaner,
) {}
private readonly QueryCleaner $queryCleaner,
private readonly IntentLite $intentLite
)
{
}
public function retrieve(string $prompt): array
{
@@ -54,7 +58,7 @@ final class NdjsonHybridRetriever implements RetrieverInterface
$vectorTopKBase = max(1, min($config->getRetrievalVectorTopK(), self::HARD_MAX_VECTORK));
// Wichtig: List-Detection bleibt auf Originalprompt (sonst entfernst du "zeige/liste" etc.)
$isListQuery = $this->isListQuery($prompt);
$isListQuery = $this->intentLite->isListQuery($prompt);
// -------------------------------------------------
// CLEAN QUERY (nur für Retrieval: Tags + Vector)
@@ -81,7 +85,7 @@ final class NdjsonHybridRetriever implements RetrieverInterface
// List mode: höhere Abdeckung, um mehr Dokumente zu ranken
if ($isListQuery) {
$topK = max($vectorTopKBase * 3, 80);
$topK = (int)round($vectorTopKBase * 2.5);
}
$topK = max(1, min($topK, self::HARD_MAX_VECTORK));
@@ -194,17 +198,6 @@ final class NdjsonHybridRetriever implements RetrieverInterface
// LIST QUERY DETECTION
// =========================================================
private function isListQuery(string $prompt): bool
{
$prompt = mb_strtolower($prompt);
return str_contains($prompt, 'liste')
|| str_contains($prompt, 'zeige')
|| str_contains($prompt, 'nenn')
|| str_contains($prompt, 'welche')
|| preg_match('/\b\d+\b/', $prompt) === 1;
}
// =========================================================
// DOCUMENT RANKING (Adjusted Scores incl. Tag Bonus)
// =========================================================