Sentence Similarity
sentence-transformers
Safetensors
baa-embedding-reranker
retrieval
embeddings
reranker
cross-encoder
rag
Instructions to use baa-ai/Merino-Mini with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use baa-ai/Merino-Mini with sentence-transformers:
from sentence_transformers import CrossEncoder model = CrossEncoder("baa-ai/Merino-Mini") query = "Which planet is known as the Red Planet?" passages = [ "Venus is often called Earth's twin because of its similar size and proximity.", "Mars, known for its reddish appearance, is often referred to as the Red Planet.", "Jupiter, the largest planet in our solar system, has a prominent red spot.", "Saturn, famous for its rings, is sometimes mistaken for the Red Planet." ] scores = model.predict([(query, passage) for passage in passages]) print(scores) - Notebooks
- Google Colab
- Kaggle
| license: other | |
| license_name: baa-proprietary | |
| library_name: sentence-transformers | |
| tags: | |
| - retrieval | |
| - embeddings | |
| - reranker | |
| - cross-encoder | |
| - rag | |
| - sentence-similarity | |
| pipeline_tag: sentence-similarity | |
| # baa.ai Β· Merino-Mini | |
| **One model that does both halves of RAG retrieval β bi-encoder embedding *and* cross-encoder reranking β over a single shared word-embedding table.** A 384-dimensional English model, ~44M parameters, by BAA AI (Black Sheep AI). | |
| ## Get the optimal model for *your* data | |
| Merino-Mini is a strong, cost-efficient **default**. But the best embedder + reranker is **corpus-specific** β the ideal choice depends on your documents and your notion of relevance. **baa.ai offers exclusive tooling that identifies the optimal embedding and reranking models for your specific data**, so you ship the smallest models that maximize document recovery on your corpus. For a tailored recommendation, **reach out to baa.ai**. | |
| ## What it is | |
| A two-role retrieval model over a **shared input word-embedding matrix** (stored once). The bi-encoder embedder and a compact 6-layer cross-encoder reranker are built on the same `MiniLM-L6-H384-uncased` backbone, so their word-embedding table is stored a single time and injected into the reranker at load β a smaller download at **no measured quality loss**, with no retraining. | |
| - **Embed role:** bi-encoder, 384-d, L2-normalized. Prepend `"Represent this sentence for searching relevant passages: "` to queries. | |
| - **Rerank role:** cross-encoder, single relevance logit per (query, document) pair. | |
| - **Router:** call `.embed(...)` or `.rerank(...)`. | |
| ## Usage | |
| ```python | |
| from modeling_baa import BaaEmbeddingReranker # included in this repo | |
| m = BaaEmbeddingReranker("baa-ai/Merino-Mini") | |
| qv = m.embed(["how does a cross-encoder reranker work?"], is_query=True)[0] | |
| dv = m.embed(["a cross-encoder scores a (query, document) pair jointly", | |
| "bi-encoders embed query and document separately for fast retrieval"]) | |
| ranked = m.rerank("how does a cross-encoder reranker work?", | |
| ["a cross-encoder scores a (query, document) pair jointly", | |
| "the mitochondria is the powerhouse of the cell"]) | |
| # -> [(doc, score), ...] sorted best-first | |
| ``` | |
| ## Specs | |
| | | | | |
| |---|---| | |
| | Embedding dim | 384 | | |
| | Parameters | ~44M (embedder + reranker, shared word-embedding table) | | |
| | Languages | English | | |
| | Max sequence length | 512 | | |
| | Hardware | CPU / edge / GPU | | |
| ## License & attribution | |
| - **BAA Contributions** (shared-embedding architecture, router/loader code, packaging, weights, docs) are **proprietary to BAA AI (Black Sheep AI)** β see `LICENSE`. | |
| - Incorporates the `MiniLM-L6-H384-uncased` backbone under the **MIT License** β see `LICENSE-minilm.txt`. | |
| Β© 2026 BAA AI (Black Sheep AI) β baa.ai. Provided "as is" without warranty. | |
| ## Certification & corpus fit (2026-07) | |
| **Position Balance (PB): 0.17** β PB measures how findable a chunk is through its *second* fact when two | |
| facts share one embedding (second-fact / first-fact top-1 retrieval on an adversarial 1,300-chunk audit; | |
| fleet range 0.16β0.69). Compact deployment tier: use with strictly atomic chunking (one claim per embedded chunk) and parent-document retrieval. | |
| **4-bit quantization: certified lossless under distractor stress.** Paired contested-region robustness | |
| (gold document injected into pools of up to 100 near-topical distractors, n=300 queries, bootstrap CIs) | |
| is statistically indistinguishable from fp16 β an axis standard hit@k benchmarks do not measure. | |
| **Chunking prescription:** embed one atomic claim per chunk and lead with its key entity; retrieve small, | |
| return the parent section for context. Basis: single-vector embeddings preserve ~one independent fact per | |
| chunk regardless of encoder family (measured across 12 encoders). | |