optimize intents
This commit is contained in:
@@ -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)
|
||||
// =========================================================
|
||||
|
||||
Reference in New Issue
Block a user