feat(etl): нормализация на Gemini-эмбеддингах (API), Vision подключён
- эмбеддинги переведены с локального torch на Gemini API (лёгкий контейнер) GeminiEmbedder: gemini-embedding-001, 768d, RETRIEVAL query/document - фильтр настоящих названий: коды/числа не уходят в сопоставление - порог косинуса 0.70 → ~73% автонормализации (цель ТЗ ≥70%), остальное в unmatched - Vision (gemini-2.5-flash, новый SDK) подключён в диспетчер для скан/нулевых PDF; проверено: Клиника 5 — 34 чистые позиции со страницы - зависимости: убран torch/sentence-transformers, добавлен google-genai+numpy Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -35,7 +35,7 @@ class Matcher:
|
||||
self,
|
||||
services: list[Service],
|
||||
embedder=None,
|
||||
emb_threshold: float = 0.60,
|
||||
emb_threshold: float = 0.70,
|
||||
fuzzy_threshold: int = 88,
|
||||
):
|
||||
self.services = services
|
||||
@@ -50,7 +50,9 @@ class Matcher:
|
||||
self.dict_emb = None
|
||||
if embedder is not None:
|
||||
self.dict_emb = embedder.encode(
|
||||
[s.name_ru for s in services], normalize_embeddings=True, show_progress_bar=False
|
||||
[s.name_ru for s in services],
|
||||
normalize_embeddings=True,
|
||||
task_type="RETRIEVAL_DOCUMENT",
|
||||
)
|
||||
|
||||
def _match_by_code(self, code: str | None) -> Service | None:
|
||||
@@ -88,7 +90,9 @@ class Matcher:
|
||||
|
||||
if pending_norm and self.embedder is not None and self.dict_emb is not None:
|
||||
query = self.embedder.encode(
|
||||
[names[i] for i in pending_idx], normalize_embeddings=True, show_progress_bar=False
|
||||
[names[i] for i in pending_idx],
|
||||
normalize_embeddings=True,
|
||||
task_type="RETRIEVAL_QUERY",
|
||||
)
|
||||
sims = query @ self.dict_emb.T # косинус по нормированным векторам
|
||||
best_idx = sims.argmax(axis=1)
|
||||
|
||||
Reference in New Issue
Block a user