~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
"""Curated Sentence Transformer model identities.
The model key is the stable value stored in user settings and collection
metadata. Only newly introduced keys may pin a different Hugging Face artifact:
legacy keys must keep their historic floating-revision semantics because
collection metadata does not yet persist an artifact revision.
Pinned ``revision`` values are immutable Hugging Face commit hashes
that identify the exact model artifact bytes fetched at download time.
"""
from dataclasses import dataclass
from types import MappingProxyType
from typing import Mapping
from ..constants import (
DEFAULT_LOCAL_SEARCH_MODEL as DEFAULT_SENTENCE_TRANSFORMER_MODEL,
)
@dataclass(frozen=True)
class SentenceTransformerModelSpec:
"""Artifact policy and display metadata for a curated model."""
repository: str
revision: str | None
dimensions: int
description: str
max_seq_length: int
# Require behavior-changing metadata before an offline load. Missing
# Transformer or tokenizer configuration can silently change truncation
# or tokenizer selection without raising a missing-weight error.
required_cache_files: tuple[str, ...] = (
"config.json",
"modules.json",
"1_Pooling/config.json",
"tokenizer_config.json",
"sentence_bert_config.json",
)
# Tokenizer vocabulary, as groups of which at least one file must be
# cached. Without it the offline constructor does not fail: it builds a
# placeholder tokenizer from the special tokens alone and embeds every
# text as the same few ids, which the missing-weight repair never sees.
# Legacy WordPiece/MPNet repositories publish both the fast
# ``tokenizer.json`` and the slow ``vocab.txt``; either one alone rebuilds
# the same tokenizer, so a cache holding only one of them still loads.
required_cache_file_alternatives: tuple[tuple[str, ...], ...] = (
("tokenizer.json", "vocab.txt"),
)
def display_metadata(self) -> dict[str, int | str]:
"""Return the legacy metadata shape consumed by provider APIs."""
return {
"dimensions": self.dimensions,
"description": self.description,
"max_seq_length": self.max_seq_length,
}
SENTENCE_TRANSFORMER_MODELS: Mapping[str, SentenceTransformerModelSpec] = (
MappingProxyType(
{
DEFAULT_SENTENCE_TRANSFORMER_MODEL: SentenceTransformerModelSpec(
repository=DEFAULT_SENTENCE_TRANSFORMER_MODEL,
revision="e7f32e3c00f91d699e8c43b53106206bcc72bb22", # DevSkim: ignore DS173237 - pinned public Hugging Face commit SHA, not a secret
dimensions=768,
description=(
"Recommended default with higher-quality English and "
"long-context document retrieval."
),
max_seq_length=8192,
# This pinned artifact has no sentence_bert_config.json;
# its token limit is inferred from model and tokenizer config.
required_cache_files=(
"config.json",
"modules.json",
"1_Pooling/config.json",
"tokenizer_config.json",
),
# ModernBERT ships a BPE ``tokenizer.json`` and no vocab.txt.
required_cache_file_alternatives=(("tokenizer.json",),),
),
"all-MiniLM-L6-v2": SentenceTransformerModelSpec(
repository="sentence-transformers/all-MiniLM-L6-v2",
revision=None,
dimensions=384,
description="Fast, lightweight model. Good for general use.",
max_seq_length=256,
),
"all-mpnet-base-v2": SentenceTransformerModelSpec(
repository="sentence-transformers/all-mpnet-base-v2",
revision=None,
dimensions=768,
description="Higher quality, slower. Best accuracy.",
max_seq_length=384,
),
"multi-qa-MiniLM-L6-cos-v1": SentenceTransformerModelSpec(
repository=("sentence-transformers/multi-qa-MiniLM-L6-cos-v1"),
revision=None,
dimensions=384,
description="Optimized for question-answering tasks.",
max_seq_length=512,
),
"paraphrase-multilingual-MiniLM-L12-v2": (
SentenceTransformerModelSpec(
repository=(
"sentence-transformers/"
"paraphrase-multilingual-MiniLM-L12-v2"
),
revision=None,
dimensions=384,
description="Supports multiple languages.",
max_seq_length=128,
# An XLM-R SentencePiece tokenizer, not WordPiece: there
# is no vocab.txt fallback, so require ``tokenizer.json``.
required_cache_file_alternatives=(("tokenizer.json",),),
)
),
}
)
)
def get_sentence_transformer_model_spec(
model_name: str,
) -> SentenceTransformerModelSpec | None:
"""Resolve either a stable catalog key or its full repository name."""
spec = SENTENCE_TRANSFORMER_MODELS.get(model_name)
if spec is not None:
return spec
return next(
(
candidate
for candidate in SENTENCE_TRANSFORMER_MODELS.values()
if candidate.repository == model_name
),
None,
)