Sentence Similarity
sentence-transformers
Safetensors
English
qwen3
feature-extraction
retrieval
matryoshka
text-embeddings-inference
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
Download training/sample.py from Louvain/embed-4b-erb: direct link, hf CLI and curl.
- Browser
- Download file 2.33 kB
-
https://huggingface.co/Louvain/embed-4b-erb/resolve/main/training/sample.py
- Command line
-
hf download hf://Louvain/embed-4b-erb/training/sample.py
-
curl -L -o sample.py https://huggingface.co/Louvain/embed-4b-erb/resolve/main/training/sample.py
2.33 kB
| """ | |
| STEP 1 — THE PASSAGES A WORKSPACE WOULD TEACH ITS EMBEDDER FROM. Documents only: see the guarantee in | |
| `common.py`. Stratified by source with square-root weights (Slack's 285k messages would otherwise drown Confluence's | |
| 5k pages), at most `--per-doc` passages from a document, the rest chosen at random, seeded. | |
| uv run python sample.py --passages 30000 --out $SELF_TUNE_DATA/passages.jsonl [--exclude pool-doc-ids.txt] [--seed 215] | |
| `--exclude` names document ids kept OUT of training (the held-out variant); ids only, never read as text. | |
| """ | |
| import argparse | |
| import json | |
| import math | |
| import random | |
| from common import corpus_documents, load_exclusions, passages, source_of | |
| def main(): | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--passages", type=int, default=30000) | |
| ap.add_argument("--per-doc", type=int, default=2) | |
| ap.add_argument("--min-chars", type=int, default=200) | |
| ap.add_argument("--exclude", default="") | |
| ap.add_argument("--seed", type=int, default=215) | |
| ap.add_argument("--out", required=True) | |
| a = ap.parse_args() | |
| rng = random.Random(a.seed) | |
| excluded = load_exclusions(a.exclude) | |
| docs = {d: p for d, p in corpus_documents().items() if d not in excluded} | |
| by_source = {} | |
| for d, p in docs.items(): | |
| by_source.setdefault(source_of(p), []).append(d) | |
| weights = {s: math.sqrt(len(ids)) for s, ids in by_source.items()} | |
| total = sum(weights.values()) | |
| out, counts = [], {} | |
| for source, ids in sorted(by_source.items()): | |
| want = round(a.passages * weights[source] / total) | |
| rng.shuffle(ids) | |
| got = 0 | |
| for d in ids: | |
| if got >= want: | |
| break | |
| chunks = [c for c in passages(docs[d]) if len(c) >= a.min_chars] | |
| rng.shuffle(chunks) | |
| for i, text in enumerate(chunks[: a.per_doc]): | |
| out.append({"pid": f"{d}#{i}", "doc": d, "source": source, "text": text}) | |
| got += 1 | |
| counts[source] = got | |
| rng.shuffle(out) | |
| with open(a.out, "w", encoding="utf-8") as f: | |
| for row in out: | |
| f.write(json.dumps(row, ensure_ascii=False) + "\n") | |
| print(json.dumps({"passages": len(out), "documents": len({r["doc"] for r in out}), "excluded": len(excluded), "by_source": counts})) | |
| if __name__ == "__main__": | |
| main() | |