Instructions to use harims95/hobbylm-embed-140m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use harims95/hobbylm-embed-140m with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("harims95/hobbylm-embed-140m", trust_remote_code=True) 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
HobbyLM-Embed-140M
An English text-embedding model built on a sparse mixture-of-experts encoder, trained from scratch: 140M total parameters, 36M active per token (excluding embeddings), 512-dimensional dense embeddings for search, RAG, similarity, clustering and classification.
HobbyLM by Fuel Labs
Hugging Face's automatic "Use this model" snippets are not validated for HobbyLM-Embed. Use the snippets on this page, which were tested as written.
Highlights
- Trained from scratch. The encoder started from random weights and was pretrained on 50B tokens. It was not adapted from BERT, ModernBERT or any other existing encoder.
- Sparse inside, dense outside. Each token runs through 8 of 32 experts in every MoE layer, with 36M parameters active per token, excluding the embedding table. The output is an ordinary dense 512-d vector that works with any vector database.
- Officially on MTEB. 62.33 on MTEB(eng, v2), all 41 tasks, scored through the loader merged into the
mtebpackage. - Reads long documents. 512 tokens by default; set it to 2,048 and long-document search improves from 36.1 to 49.3 nDCG@10 on LongEmbed.
- Runs where you are. Sentence Transformers on CPU or GPU, LangChain, LlamaIndex and Chroma, llama.cpp (GGUF), Ollama, and MLX on Apple Silicon.
- Apache-2.0. Weights, model code and tools.
Model list
| Model | Format | Location | Notes |
|---|---|---|---|
| HobbyLM-Embed-140M | safetensors (float32) | harims95/hobbylm-embed-140m | Reference model. Sentence Transformers, LangChain, LlamaIndex, Chroma |
| HobbyLM-Embed-140M GGUF | GGUF F16 (335 MB), Q8_0 (179 MB) | harims95/hobbylm-embed-140m-gguf | llama.cpp with our helper script: mean cosine 0.99997 (F16) / 0.9994 (Q8_0) vs the reference |
| HobbyLM-Embed-140M MLX | MLX float16 (280 MB) | harims95/hobbylm-embed-140m-mlx | Apple Silicon. Tested on Apple M4: float16 lowest cosine 0.99965 vs the reference |
| Demo | Hugging Face Space | harims95/hobbylm-embed-140m-demo | Try it in the browser: ticket routing, duplicates, messy search, long documents |
| Ollama | GGUF Q8_0 | hariharanms95/hobbylm-embed-140m |
Close to, but not identical with, the reference (see the Ollama note) |
| Code and examples | Python | fuellabs-ai/hobbylm-embed-140m | Model code, examples, GGUF tools, MLX port, offline tests |
Retrieval needs prompts:
query:for queries andpassage:for documents. Use the same setup for indexing and searching, and don't mix vectors from different runtimes (for example Ollama and Sentence Transformers) in one index.
Model information
| Item | Value |
|---|---|
| Total parameters | 139,982,848 |
| Embedding parameters | 25,755,648 |
| Active per token (excl. embeddings, MTEB convention) | 36,370,432 |
| Active per token (incl. embeddings) | 62,126,080 |
| Output | dense 512-dimensional vector, L2-normalised |
| Input length | 512 tokens by default; up to 2,048 tested |
| Language | English |
| Tokenizer | GPT-2 byte-level BPE (vocabulary 50,304 padded); one end-of-text token appended |
| Weights | float32 safetensors |
| Licence | Apache-2.0 |
| Architecture component | Setting |
|---|---|
| Layers | 12, pre-norm RMSNorm |
| Width | 512 |
| Attention | bidirectional, grouped-query (8 query / 2 key-value heads of size 64), QK-norm, RoPE |
| Layer 0 feed-forward | dense SwiGLU, hidden 1,536 |
| Layers 1β11 feed-forward | sparse MoE: 32 SwiGLU experts (hidden 192), top-8 per token, no shared expert |
| Router | float32 sigmoid scores, auxiliary-loss-free balancing bias (used for selection only), dropless |
| Pooling | mean over tokens, excluding padding and the final end-of-text token; then L2 normalisation |
Introduction
Most small embedding models are adapted from an existing encoder. We wanted to build one end to end: the architecture, the pretraining, every embedding stage and the evaluation. HobbyLM-Embed takes the sparse mixture-of-experts design of the HobbyLM model family, makes its attention bidirectional, and trains it from random weights into a general-purpose English embedding model.
The encoder has 140M total parameters, with 36M active per token excluding embeddings, and produces a 512-dimensional dense vector. It is meant to be practical: it runs on a laptop CPU, plugs into the common RAG frameworks, and has GGUF, Ollama and MLX versions for running locally.
Evaluation results
MTEB(eng, v2)
All 41 tasks, scored with mteb 2.27.18 through the official loader, fp32, 512-token inputs, model revision ff263c85. Both the model entry and the results are merged into MTEB.
| Metric | Score |
|---|---|
| Mean (Task), 41 tasks | 62.33 |
| Mean (TaskType) | 57.62 |
| Classification (8 tasks) | 78.43 |
| Pair classification (3) | 79.21 |
| Semantic textual similarity (9) | 79.06 |
| Retrieval (10) | 50.24 |
| Clustering (8) | 45.15 |
| Reranking (2) | 43.93 |
| Summarization (1) | 27.29 |
All 41 tasks
| Task | Type | Main metric | Score |
|---|---|---|---|
| AmazonCounterfactualClassification | Classification | accuracy | 90.79 |
| Banking77Classification | Classification | accuracy | 79.63 |
| ImdbClassification | Classification | accuracy | 87.61 |
| MTOPDomainClassification | Classification | accuracy | 93.53 |
| MassiveIntentClassification | Classification | accuracy | 68.54 |
| MassiveScenarioClassification | Classification | accuracy | 75.72 |
| ToxicConversationsClassification | Classification | accuracy | 67.92 |
| TweetSentimentExtractionClassification | Classification | accuracy | 63.73 |
| SprintDuplicateQuestions | PairClassification | max_ap | 92.24 |
| TwitterSemEval2015 | PairClassification | max_ap | 61.93 |
| TwitterURLCorpus | PairClassification | max_ap | 83.46 |
| BIOSSES | STS | cosine_spearman | 85.42 |
| SICK-R | STS | cosine_spearman | 72.30 |
| STS12 | STS | cosine_spearman | 75.95 |
| STS13 | STS | cosine_spearman | 82.71 |
| STS14 | STS | cosine_spearman | 77.05 |
| STS15 | STS | cosine_spearman | 85.60 |
| STS17 | STS | cosine_spearman | 86.89 |
| STS22.v2 | STS | cosine_spearman | 63.35 |
| STSBenchmark | STS | cosine_spearman | 82.30 |
| ArguAna | Retrieval | ndcg_at_10 | 52.03 |
| CQADupstackGamingRetrieval | Retrieval | ndcg_at_10 | 55.20 |
| CQADupstackUnixRetrieval | Retrieval | ndcg_at_10 | 39.93 |
| ClimateFEVERHardNegatives | Retrieval | ndcg_at_10 | 30.77 |
| FEVERHardNegatives | Retrieval | ndcg_at_10 | 83.09 |
| FiQA2018 | Retrieval | ndcg_at_10 | 38.14 |
| HotpotQAHardNegatives | Retrieval | ndcg_at_10 | 60.74 |
| SCIDOCS | Retrieval | ndcg_at_10 | 17.54 |
| TRECCOVID | Retrieval | ndcg_at_10 | 67.39 |
| Touche2020Retrieval.v3 | Retrieval | ndcg_at_10 | 57.61 |
| ArXivHierarchicalClusteringP2P | Clustering | v_measure | 60.04 |
| ArXivHierarchicalClusteringS2S | Clustering | v_measure | 55.11 |
| BiorxivClusteringP2P.v2 | Clustering | v_measure | 41.48 |
| MedrxivClusteringP2P.v2 | Clustering | v_measure | 36.36 |
| MedrxivClusteringS2S.v2 | Clustering | v_measure | 34.88 |
| StackExchangeClustering.v2 | Clustering | v_measure | 55.30 |
| StackExchangeClusteringP2P.v2 | Clustering | v_measure | 39.43 |
| TwentyNewsgroupsClustering.v2 | Clustering | v_measure | 38.64 |
| AskUbuntuDupQuestions | Reranking | map_at_1000 | 58.91 |
| MindSmallReranking | Reranking | max_over_subqueries_map_at_1000 | 28.94 |
| SummEvalSummarization.v2 | Summarization | cosine_spearman | 27.29 |
How to read these numbers
- Retrieval tasks use
query:/passage:prompts; every other task uses plain text. - Fine-tuning used the training splits of some MTEB tasks (never their test splits), and some training text comes from the same source corpora as some MTEB tasks. All of these are declared in the model's MTEB entry: 26 of 41 tasks, so MTEB lists the model as 36% zero-shot.
- The final checkpoint was selected using MTEB scores.
- Treat the benchmark mean as optimistic for domains the model has not seen, and evaluate on your own data.
Active-parameter comparison
Among models with β€40M active parameters on MTEB(eng, v2) (active parameters exclude embeddings), HobbyLM-Embed-140M scores 62.33 Mean (Task). This is an active-parameter comparison; HobbyLM-Embed has 140M total parameters.
The cohort includes models with at most 600M total parameters, known total and non-embedding active counts, and complete results across all 41 English v2 tasks. Scores use the published MTEB result revisions with the registered revision preferred. Officially on MTEB; the model card reports 36% zero-shot for HobbyLM-Embed.
Models compared, exact parameter counts and public sources.
Long documents
The model reads up to 2,048 tokens when you raise the input length (see Quickstart). On LongEmbed's four real long-document retrieval tasks:
| LongEmbed task (nDCG@10) | 512 | 1,024 | 2,048 |
|---|---|---|---|
| NarrativeQA | 16.15 | 16.54 | 18.16 |
| QMSum | 21.60 | 27.94 | 32.10 |
| 2WikiMultihopQA | 48.09 | 55.14 | 62.30 |
| SummScreenFD | 58.41 | 74.16 | 84.77 |
| Average | 36.06 | 43.44 | 49.33 |
- On synthetic tests where one fact is hidden in a 2,048-token document, accuracy@1 rises from 22% to 96% (passkey) and from 24% to 82% (needle). At 512 the model only sees facts in the first 512 tokens.
- On MTEB(eng, v2) the 40-task mean is unchanged at 2,048 (63.16 β 63.14), but similarity between long news articles (STS22) drops by 1.7 points. That is why 512 stays the default and 2,048 is a one-line option for long-document search.
- The final fine-tuning stage used inputs of at most 256 tokens; lengths beyond 2,048 are not tested.
Training recipe
Four stages, each starting from the previous one's weights. Data sources are described by type; mixtures, preparation details and training code are not released.
| Stage | What it teaches | Data |
|---|---|---|
| 1. Masked-token pretraining | Language, from random weights (50B tokens, sequences up to 1,024) | Filtered web text, educational and scientific documents, Wikipedia, StackExchange, synthetic questionβanswer text and code; deduplicated and decontaminated against the MTEB(eng, v2) test sets |
| 2. Contrastive pair training | What "related" means (about 20M pairs) | Public questionβanswer, titleβbody, paraphrase and citation pairs |
| 3. Distillation (short) | Light alignment to larger embedding models | Teacher-scored public texts |
| 4. Supervised fine-tuning | Task skills, with teacher-mined hard negatives | Public labelled data for retrieval, NLI, paraphrase, classification and clustering, including MTEB training splits; synthetic training triplets |
What mattered most:
- Measuring correctly. Scoring in fp32 and averaging clustering over several seeds removed noise that was larger than the effects we were testing.
- Matching training and use. Short prompts the model saw in training help; long unseen instructions hurt a mean-pooled model.
- Choosing data by measurement. Testing pair sources one at a time showed that some popular sources made out-of-domain retrieval worse.
Quickstart
Sentence Transformers
pip install -U sentence-transformers
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("harims95/hobbylm-embed-140m", revision="ea708cee107818fa0c1871eebd26d82a1e3fb1aa",
trust_remote_code=True)
queries = ["how do vaccines work?"]
passages = [
"Vaccines train the immune system to recognise a pathogen without causing the disease.",
"The Eiffel Tower was completed in 1889.",
]
q = model.encode_query(queries) # adds "query: "
p = model.encode_document(passages) # adds "passage: "
print(q.shape) # (1, 512)
print(model.similarity(q, p)) # tensor([[0.6537, 0.2375]])
trust_remote_code=Trueis required: the MoE encoder is custom code shipped in this repo.encode_query/encode_document(orprompt_name="query"/"passage") add the prompts. Typing them yourself gives the same vector; never do both.- For similarity, clustering and classification, use plain
model.encode(texts). - Embeddings are L2-normalised, so cosine similarity equals the dot product.
Long documents (up to 2,048 tokens)
model.max_seq_length = 2048
Use it for long-document search (contracts, transcripts, reports). Longer inputs are slower to encode; chunk anything longer than 2,048 tokens.
LangChain, LlamaIndex and Chroma
Every snippet below was run exactly as written on CPU, each in a new virtual environment with an empty Hugging Face
cache, with the model pinned to revision ea708cee107818fa0c1871eebd26d82a1e3fb1aa. langchain-hobbylm, LlamaIndex and
Chroma give the same vectors as Sentence Transformers (cosine 1.000000 on 2 prompted queries and 2 prompted passages,
and on a 5,098-token passage at 2,048 tokens); langchain-huggingface does for single-line text (see its note). As
everywhere, queries need query: and documents need passage: . The LlamaIndex and Chroma snippets use these texts
(the LangChain snippets define them inline):
QUERIES = ["how do vaccines work?", "what is the capital of france"]
PASSAGES = ["Vaccines train the immune system to recognise a pathogen without causing the disease.",
"Paris is the capital and largest city of France."]
LangChain
Recommended: langchain-hobbylm 0.1.1. It sets the query / passage
prompts and pins the model revision for you. Tested 23 Nov 2026 (Linux, Python 3.12.16, new venv, empty Hugging Face
cache): langchain-hobbylm 0.1.1, langchain-core 1.8.4, sentence-transformers 6.3.0, transformers 5.24.0, torch 2.15.0, huggingface-hub 2.4.0, numpy 2.5.5.
pip install langchain-hobbylm
from langchain_core.vectorstores import InMemoryVectorStore
from langchain_hobbylm import HobbyLMEmbeddings
embeddings = HobbyLMEmbeddings(revision="ea708cee107818fa0c1871eebd26d82a1e3fb1aa")
queries = ["how do vaccines work?", "what is the capital of france"]
passages = ["Vaccines train the immune system to recognise a pathogen without causing the disease.",
"Paris is the capital and largest city of France."]
q = [embeddings.embed_query(t) for t in queries] # "query: " prompt
p = embeddings.embed_documents(passages) # "passage: " prompt
print("dims", len(q[0]), "norms", [round(sum(x * x for x in v) ** 0.5, 4) for v in q + p])
store = InMemoryVectorStore.from_texts(passages, embedding=embeddings)
for t in queries:
print(t, "->", store.similarity_search(t, k=1)[0].page_content)
Output (real run):
dims 512 norms [1.0, 1.0, 1.0, 1.0]
how do vaccines work? -> Vaccines train the immune system to recognise a pathogen without causing the disease.
what is the capital of france -> Paris is the capital and largest city of France.
The vectors are identical to Sentence Transformers (cosine 1.000000 on both queries and both passages), with no
"new version ... malicious code" warning. Long documents: HobbyLMEmbeddings(revision="ea708cee107818fa0c1871eebd26d82a1e3fb1aa", model_kwargs={"tokenizer_kwargs": {"model_max_length": 2048}})
(tested on a 5,098-token passage: 512-d, norm 1.0, cosine 1.000000 vs Sentence Transformers with max_seq_length = 2048).
Alternative: langchain-huggingface. Tested the same way: langchain-huggingface 1.2.3, langchain-core 1.8.4, sentence-transformers 6.3.0, transformers 5.24.0, torch 2.15.0, huggingface-hub 1.33.0, numpy 2.5.5.
pip install langchain-huggingface sentence-transformers
from langchain_core.vectorstores import InMemoryVectorStore
from langchain_huggingface import HuggingFaceEmbeddings
embeddings = HuggingFaceEmbeddings(
model_name="harims95/hobbylm-embed-140m",
model_kwargs={"trust_remote_code": True, "revision": "ea708cee107818fa0c1871eebd26d82a1e3fb1aa"},
query_encode_kwargs={"prompt_name": "query"},
encode_kwargs={"prompt_name": "passage"},
)
queries = ["how do vaccines work?", "what is the capital of france"]
passages = ["Vaccines train the immune system to recognise a pathogen without causing the disease.",
"Paris is the capital and largest city of France."]
q = [embeddings.embed_query(t) for t in queries]
p = embeddings.embed_documents(passages)
print("dims", len(q[0]), "norms", [round(sum(x * x for x in v) ** 0.5, 4) for v in q + p])
store = InMemoryVectorStore.from_texts(passages, embedding=embeddings)
for t in queries:
print(t, "->", store.similarity_search(t, k=1)[0].page_content)
Output (real run):
dims 512 norms [1.0, 1.0, 1.0, 1.0]
how do vaccines work? -> Vaccines train the immune system to recognise a pathogen without causing the disease.
what is the capital of france -> Paris is the capital and largest city of France.
langchain-huggingface replaces line breaks with spaces before encoding, so multi-line documents get slightly different vectors than Sentence Transformers (cosine about 0.97 on our long test). Use langchain-hobbylm for identical vectors.
Long documents: add "tokenizer_kwargs": {"model_max_length": 2048} to model_kwargs (the setting takes effect: on
the text it actually encodes, with line breaks replaced, the vector is identical to Sentence Transformers at 2,048
tokens).
LlamaIndex
Tested 23 Nov 2026 in a new venv with an empty Hugging Face cache: llama-index-embeddings-huggingface 0.9.0,
llama-index-core 0.14.26, sentence-transformers 6.3.0, transformers 5.24.0, torch 2.15.0, huggingface_hub 2.4.0, numpy 2.5.5, Python 3.12, CPU. LlamaIndex sets its own prompts, so the model's prompts go in query_instruction
(queries) and text_instruction (documents). The revision is pinned, so no "new version ... malicious code" warning appears.
pip install llama-index-embeddings-huggingface
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
embed = HuggingFaceEmbedding(model_name="harims95/hobbylm-embed-140m",
revision="ea708cee107818fa0c1871eebd26d82a1e3fb1aa",
trust_remote_code=True, device="cpu",
query_instruction="query: ", text_instruction="passage: ")
q = [embed.get_query_embedding(t) for t in QUERIES]
p = embed.get_text_embedding_batch(PASSAGES)
print("dims", len(q[0]), "norms", [round(sum(x * x for x in v) ** 0.5, 4) for v in q + p])
for t, v in zip(QUERIES, q):
scores = [sum(a * b for a, b in zip(v, d)) for d in p]
print(t, "->", PASSAGES[scores.index(max(scores))])
Output (real run):
dims 512 norms [1.0, 1.0, 1.0, 1.0]
how do vaccines work? -> Vaccines train the immune system to recognise a pathogen without causing the disease.
what is the capital of france -> Paris is the capital and largest city of France.
The vectors are identical to Sentence Transformers (cosine 1.000000 on both queries and both passages).
Long documents: add max_length=2048 to HuggingFaceEmbedding(...) (tested the same way on a 5,098-token passage:
512-d, norm 1.0, cosine 1.000000 vs Sentence Transformers with max_seq_length = 2048).
Chroma
Tested 23 Nov 2026 in a new venv with an empty Hugging Face cache: chromadb 1.5.9, sentence-transformers 6.3.0, transformers 5.24.0, torch 2.15.0, huggingface_hub 2.4.0, numpy 2.5.5, Python 3.12, CPU. Chroma's embedding
function has no query/document setting, so the prompts are added to the texts: query: for queries and passage:
for documents. The revision is pinned, so no "new version ... malicious code" warning appears.
pip install chromadb sentence-transformers
import chromadb
from chromadb.utils.embedding_functions import SentenceTransformerEmbeddingFunction
ef = SentenceTransformerEmbeddingFunction(model_name="harims95/hobbylm-embed-140m",
revision="ea708cee107818fa0c1871eebd26d82a1e3fb1aa",
trust_remote_code=True, device="cpu")
q = ef(["query: " + t for t in QUERIES])
p = ef(["passage: " + t for t in PASSAGES])
print("dims", len(q[0]), "norms", [round(float((v * v).sum()) ** 0.5, 4) for v in q + p])
# end to end: in-memory collection, cosine space
col = chromadb.Client().create_collection("demo", embedding_function=ef, metadata={"hnsw:space": "cosine"})
col.add(ids=["vaccines", "paris"], documents=["passage: " + t for t in PASSAGES])
res = col.query(query_texts=["query: " + t for t in QUERIES], n_results=1)
print("top result per query:", res["ids"])
Output (real run):
dims 512 norms [1.0, 1.0, 1.0, 1.0]
top result per query: [['vaccines'], ['paris']]
The vectors are identical to Sentence Transformers (cosine 1.000000 on both queries and both passages).
Long documents: add tokenizer_kwargs={"model_max_length": 2048} to SentenceTransformerEmbeddingFunction(...) (tested
the same way on a 5,098-token passage: 512-d, norm 1.0, cosine 1.000000 vs Sentence Transformers with
max_seq_length = 2048). Chroma keeps one loaded model per model_name in a Python process, so create the 2,048 version
in a new process, not after a 512 one.
device="cpu" can be dropped on a CPU-only machine or changed to "cuda".
llama.cpp (GGUF)
1. Build llama.cpp (release v1.0.0, CPU)
git clone --depth 1 --branch v1.0.0 https://github.com/ggml-org/llama.cpp
cd llama.cpp
cmake -B build -DCMAKE_BUILD_TYPE=Release -DGGML_NATIVE=ON -DLLAMA_CURL=OFF -DLLAMA_BUILD_TESTS=OFF
cmake --build build -j 14 --target llama-embedding llama-quantize
Output (last lines):
[100%] Built target llama-common
[100%] Built target llama-embedding
[100%] Built target llama-quantize
2. Get the GGUF and the helper
pip install -U huggingface_hub
hf download harims95/hobbylm-embed-140m-gguf hobbylm-embed-140m-f16.gguf hobbylm-embed-140m-q8_0.gguf hobbylm_llamacpp_embed.py --local-dir .
sha256sum hobbylm-embed-140m-f16.gguf hobbylm-embed-140m-q8_0.gguf hobbylm_llamacpp_embed.py
Output:
7ecb311d06ac5f20e560dbf3ca2f92cd5a364ab7326cee7381f8abad90f77339 *hobbylm-embed-140m-f16.gguf
e192e27ce562a2e19e8980afcb1729b1a53ec1eee284be6ac3039cfea923a957 *hobbylm-embed-140m-q8_0.gguf
d8dd27990663dbe9a60e12f64e989f2bf70c4cff4cc7c00a6760930838454414 *hobbylm_llamacpp_embed.py
If the first download fails, retry. Step 3 uses the F16 file; for Q8_0, pass --model hobbylm-embed-140m-q8_0.gguf.
3. Embed texts
The helper needs only Python 3 (standard library). It runs llama-embedding --pooling none and pools the way the model
was trained: the mean of the text tokens, excluding the final end-of-text token, then L2 normalisation.
printf "what is the capital of france\n" > queries.txt
printf "Paris is the capital and largest city of France.\nThe mitochondria is the powerhouse of the cell.\n" > passages.txt
B=./llama.cpp/build/bin/llama-embedding
python3 hobbylm_llamacpp_embed.py --bin $B --model hobbylm-embed-140m-f16.gguf --mode query queries.txt > q.jsonl
python3 hobbylm_llamacpp_embed.py --bin $B --model hobbylm-embed-140m-f16.gguf --mode passage passages.txt > p.jsonl
cut -c1-120 q.jsonl
python3 -c "
import json
q=[json.loads(l) for l in open('q.jsonl')]; p=[json.loads(l) for l in open('p.jsonl')]
for d in p: print(round(sum(a*b for a,b in zip(q[0]['embedding'], d['embedding'])),4), d['text'])
"
Output:
{"text": "what is the capital of france", "embedding": [0.0119629, -0.0288813, -0.0404069, -0.0176782, 0.0519803, 0.0387
0.7309 Paris is the capital and largest city of France.
0.378 The mitochondria is the powerhouse of the cell.
--mode query/--mode passagefor retrieval;--mode nonefor similarity, classification and clustering.- One text per line; texts are stripped. The GGUF files are tested at 512 tokens; their context limit is 1,024 tokens. For long documents (up to 2,048 tokens) use Sentence Transformers with
model.max_seq_length = 2048. llama.cpp does not truncate, so shorten longer texts yourself.
llama.cpp's built-in mean pooling includes the end-of-text token, so use the helper script for exact embeddings.
Ollama
ollama pull hariharanms95/hobbylm-embed-140m
curl http://localhost:11434/api/embed -d '{
"model": "hariharanms95/hobbylm-embed-140m",
"input": ["query: how do vaccines work?",
"passage: Vaccines train the immune system to recognise a pathogen without causing the disease."]
}'
The response holds one 512-d, L2-normalised vector per input under "embeddings". As with the other runtimes, prefix retrieval queries with query: and documents with passage: , and use plain text for similarity, clustering and classification. The model runs with num_ctx 512.
Ollama's pooling includes the final end-of-text token, so its vectors are close to but not identical with the reference model: on normal sentences cosine is about 0.99 and task scores stay within Β±0.4, but very short texts (one or two words) differ most (cosine about 0.92β0.97). Don't mix Ollama vectors with exact vectors in one index.
MLX (Apple Silicon)
pip install mlx tokenizers numpy huggingface_hub
import sys
from huggingface_hub import snapshot_download
path = snapshot_download("harims95/hobbylm-embed-140m-mlx")
sys.path.insert(0, path)
from hobbylm_mlx import Encoder
enc = Encoder(path, quant_dir=path)
q = enc.encode(["what is the capital of france"], prompt_name="query")
p = enc.encode(["Paris is the capital and largest city of France."], prompt_name="passage")
print(q @ p.T) # vectors are L2-normalised: this is cosine similarity
Long documents (up to 2,048 tokens):
enc = Encoder(path, quant_dir=path, max_seq_length=2048)
Compatibility
| Runtime | Status |
|---|---|
| Sentence Transformers | β tested (reference) |
| langchain-hobbylm / LlamaIndex / Chroma | β tested, identical vectors |
| langchain-huggingface | β tested; line breaks become spaces, so multi-line texts differ slightly |
| llama.cpp (GGUF F16 / Q8_0) | β tested with our helper script |
| Ollama | β tested, close but not identical |
| MLX (Apple Silicon, float16) | β tested on Apple M4 |
| Hugging Face Transformers | see the examples in the GitHub repo |
| LM Studio | not supported yet |
Limitations and disclaimer
- English only. The GPT-2 tokenizer is also inefficient for code and non-English text.
- Prompts matter. Retrieval needs
query:/passage:; mixing prompted and unprompted vectors in one index degrades results. - Input length. 512 tokens by default; up to 2,048 tested on LongEmbed; longer inputs are slower and nothing beyond 2,048 is tested.
- Custom code. Loading requires
trust_remote_code=True. The reference implementation runs experts in a loop, so batching texts together is much faster than encoding them one at a time. - Benchmark context. The MTEB score includes tasks whose training splits were used, and the checkpoint was selected on MTEB. Evaluate on your own data before relying on it.
- No guarantees. Embeddings can reflect biases in public web and labelled data. The model is provided as is, without warranty.
License
| Item | Licence |
|---|---|
| Model weights | Apache-2.0 |
Model code (modeling_hobbylm.py, configs) |
Apache-2.0 |
| GGUF tools and helper script | MIT |
| MLX port | Apache-2.0 |
Training data notes
The model was trained on public datasets and on text generated by openly licensed models. Training data is not redistributed with this model, and third-party data remains under its own licences.
Credits
Built at Fuel Labs by Hariharan M. S. and Prabhurajhan R.
The architecture was designed by Harish Santhanalakshmi Ganesan for the HobbyLM model family (arXiv:2610.34582).
We thank Jarvis Labs for providing the compute for this work.
Citation
@misc{hobbylmembed2026,
title = {HobbyLM-Embed: Training a Sparse Mixture-of-Experts Text Embedding Model from Scratch},
author = {Hariharan M. S. and Prabhurajhan R.},
year = {2026},
url = {https://huggingface.co/harims95/hobbylm-embed-140m}
}
- Downloads last month
- 104