Skip to content

~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.

1.5 KB
Raw Blame
#!/usr/bin/env python3
"""Prepare the library UI shard's real MiniLM model before offline tests.

Only this setup process requests public model acquisition. The seed and server
reuse the shared data-volume cache without relaxing their egress policy.
"""

import math
import os


def prepare_embeddings():
    if not os.environ.get("LDR_DATA_DIR"):
        raise ValueError(
            "LDR_DATA_DIR must name the disposable CI data directory"
        )

    from local_deep_research.embeddings.embeddings_config import get_embeddings
    from local_deep_research.utilities.resource_utils import safe_close

    embeddings = get_embeddings(
        provider="sentence_transformers",
        model="all-MiniLM-L6-v2",
        device="cpu",
        settings_snapshot={
            "policy.egress_scope": "public_only",
            "search.tool": "arxiv",
            "embeddings.require_local": False,
        },
    )
    try:
        # Load the actual weights/tokenizer, rather than accepting cache
        # metadata alone as proof that an interrupted download completed.
        vector = embeddings.embed_query("Synthetic library CI readiness check")
        if len(vector) != 384 or not all(math.isfinite(x) for x in vector):
            raise ValueError("The library fixture requires finite 384d vectors")
    finally:
        safe_close(embeddings, "library fixture embeddings")
    print("Library MiniLM embedding cache is ready")


if __name__ == "__main__":
    prepare_embeddings()