optimize texts retrieval
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Intent;
|
||||
|
||||
use App\Knowledge\Retrieval\QueryCleaner;
|
||||
use App\Tag\TagVectorSearchClient;
|
||||
use App\Tag\TagTypes;
|
||||
|
||||
@@ -29,7 +30,7 @@ final class CatalogIntentLite
|
||||
* Minimaler Similarity-Score.
|
||||
* Verhindert Rauschen.
|
||||
*/
|
||||
private const MIN_SCORE = 0.75;
|
||||
private const MIN_SCORE = 0.72;
|
||||
|
||||
/**
|
||||
* Differenz zwischen Top1 und Top2,
|
||||
@@ -39,6 +40,7 @@ final class CatalogIntentLite
|
||||
|
||||
public function __construct(
|
||||
private readonly TagVectorSearchClient $tagVectorClient,
|
||||
private readonly QueryCleaner $queryCleaner,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -52,8 +54,10 @@ final class CatalogIntentLite
|
||||
return null;
|
||||
}
|
||||
|
||||
// 1) Vector-Suche
|
||||
$hits = $this->tagVectorClient->search($prompt, 3);
|
||||
$promptTag = $this->queryCleaner->clean($prompt);
|
||||
|
||||
// 1) Tag-Vector-Suche
|
||||
$hits = $this->tagVectorClient->search($promptTag, 3);
|
||||
|
||||
if ($hits === []) {
|
||||
return null;
|
||||
@@ -62,7 +66,7 @@ final class CatalogIntentLite
|
||||
$best = $hits[0];
|
||||
$bestScore = (float)($best['score'] ?? 0.0);
|
||||
|
||||
// 2) Score-Gate
|
||||
// 2) Score-Tags
|
||||
if ($bestScore < self::MIN_SCORE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user