optimize debug retrieval
This commit is contained in:
@@ -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.');
|
||||||
@@ -197,7 +198,8 @@ final class NdjsonHybridRetriever implements RetrieverInterface
|
|||||||
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));
|
||||||
|
|
||||||
@@ -340,7 +342,8 @@ final class NdjsonHybridRetriever implements RetrieverInterface
|
|||||||
float $threshold,
|
float $threshold,
|
||||||
bool $boostScoped,
|
bool $boostScoped,
|
||||||
bool $captureRaw
|
bool $captureRaw
|
||||||
): array {
|
): array
|
||||||
|
{
|
||||||
$rrfScores = [];
|
$rrfScores = [];
|
||||||
$rawScores = [];
|
$rawScores = [];
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user