Run this model with HF Jobs
Run Louvain/embed-4b-erb on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/Louvain/embed-4b-erb. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Louvain/embed-4b-erb on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use Louvain/embed-4b-erb with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Louvain/embed-4b-erb with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("Louvain/embed-4b-erb") sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
embed-4b-erb
This is Louvain's qwen3-4b-st-B: Qwen/Qwen3-Embedding-4B, self-tuned for retrieval over
one company's documents: the synthetic company corpus of
EnterpriseRAG-Bench (MIT-licensed, per its publisher). It is the embedder behind Louvain's
EnterpriseRAG-Bench runs.
- Base model: Qwen/Qwen3-Embedding-4B. Its model page gives its licence as "apache-2.0".
- Licence: Apache-2.0, the same as the base. See
LICENSE. - Changes from the base: a LoRA adapter (rank 64), trained as described below and merged into the base weights. No architecture change.
- Width: 2,560 dimensions. Also trained Matryoshka at 768, and served at 768.
Training data
- Source: synthetic questions over the corpus's own passages, and nothing else. Each sampled passage got two
questions, written by
qwen/qwen3-235b-a22b-2507from that passage alone. One asks what a colleague would ask that the passage answers. The other asks for the same thing without the document's words. - Hard negatives: mined per question from BM25 and from Qwen3-Embedding-0.6B's nearest neighbours (the base 0.6B). 57,407 (question, passage, negatives) triples.
- Held out: 11,925 documents were removed from training entirely: every document in the two evaluation pools (the 9,429-document pool scored below, and a second, 3,511-document pool). "Held out" means those documents and only those. The training passages were sampled from the whole corpus apart from it, so documents that answer other benchmark questions may be among them, as documents.
- No benchmark data: none of the benchmark's questions, answers or gold labels is in the training data in any form. The model has seen the corpus's documents, which is what self-tuning on a workspace means, but never the questions asked about them.
Training
- Objective: contrastive (InfoNCE) with in-batch and hard negatives, temperature 0.05.
- Matryoshka: also trained on the first 768 dimensions.
- Settings: LoRA rank 64 on the base, learning rate 1e-4, batch 32, one epoch (1,794 steps), seed 215.
- Lengths: queries up to 96 tokens, passages up to 384 tokens.
- Compute: 10,292 s on one A100 80 GB.
- Scripts:
training/holds the scripts that made it (pipeline.shruns them in order) andself-tune.json, the run's recorded settings. The training triples are not included: they contain the corpus's text. Neither is the held-out id list.
Use
Queries carry an instruction prefix; documents carry none. Pooling is the last token, left-padded, and vectors are L2-normalised. To serve at 768, keep the first 768 dimensions and normalise again.
Instruct: Given a question about a company's work, retrieve the passages that answer it
Query: <the question>
The sentence-transformers configuration here already sets that query prompt and last-token pooling:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("Louvain/embed-4b-erb", truncate_dim=768)
q = model.encode(["When does the Acme contract renew?"], prompt_name="query", normalize_embeddings=True)
d = model.encode(["Acme renewal: the contract renews on 1 March..."], normalize_embeddings=True)
print(model.similarity(q, d))
With plain transformers: tokenize with left padding, take the hidden state at each row's last attended token,
L2-normalise, and optionally cut to 768 and normalise again. Load it in float32 on transformers 5.17.0, the version
that saved it and the one Louvain serves it on. The config also states rope_theta (1,000,000) at the top level beside
rope_parameters, because a loader that misses the nested value falls back to 10,000 and embeds measurably wrong
(cosine 0.94โ0.97 to the right vectors) without any error.
Integrity: model.safetensors sha256 771b1d5b1419e49b588febfc655e469e27ebd3d72031a5a00624f711cade530b. Every
file's digest is in SHA256SUMS.
On Louvain's open engine, its embedding sidecar (apps/nlp/embed.py, torch backend) serves this checkpoint
directory with:
LOUVAIN_EMBEDDING_BACKEND=torch
LOUVAIN_EMBEDDING_TORCH_MODEL=<checkpoint dir>
LOUVAIN_EMBEDDING_MODEL_DIR=<checkpoint dir>
LOUVAIN_EMBEDDING_POOLING=last
LOUVAIN_EMBEDDING_MATRYOSHKA=true
LOUVAIN_EMBEDDING_DIM=768
LOUVAIN_EMBEDDING_QUERY_INSTRUCTION="Instruct: Given a question about a company's work, retrieve the passages that answer it\nQuery: "
Its GPU image (apps/nlp/Dockerfile.gpu) bakes this repository at a pinned commit and refuses to build unless
model.safetensors has the digest above; the command is in that file's header.
Measured retrieval
The evaluation pool is 50 EnterpriseRAG-Bench development questions, used for evaluation only (25 "semantic", 25 others), over 9,429 documents (89,311 passages). Every document in the pool was held out of training. The table counts questions with a gold document at rank 1 / โค5 / โค10 / โค18:
| Model | Semantic (n=25) | Others (n=25) |
|---|---|---|
| Qwen3-Embedding-4B (base) | 1 / 6 / 7 / 12 | 11 / 16 / 18 / 19 |
| qwen3-4b-st-B, full width | 9 / 16 / 17 / 22 | 15 / 20 / 21 / 21 |
| qwen3-4b-st-B, 768 dimensions | 7 / 16 / 18 / 23 | 14 / 20 / 20 / 21 |
These are retrieval numbers for the embedder alone, not a benchmark score. Louvain's judged benchmark runs add BM25, fusion, a reranker and a reader on top.
On the benchmark itself (100 development questions, judged with the benchmark's own evaluator, corrected scoring): using the engine's default embedder, bge-base-en-v1.5, in this model's place scored 1.21 points lower. That is one run against one run, and two identical runs of one configuration differ by about 1.5 points, so the difference is within the noise of a single pair.
Intended use and limits
- Intended use: dense retrieval of passages for English questions about company documents, on the corpus it was tuned on.
- It was tuned on one benchmark's corpus (a synthetic technology company), and the improvement above is shown on that corpus only. No claim is made for any other corpus; it has not been evaluated on any.
- The pipeline-level result above is not evidence of a gain; it is within noise.
- It is a 4-billion-parameter model (8 GB of weights); run it on a GPU. CPU use is untested here.
- English only, as tuned. The base model's other languages are untested here.
- Passages were trained at up to 384 tokens. Longer inputs work, as with the base, but were not tuned.
- Downloads last month
- 58