Instructions to use harims95/hobbylm-embed-140m-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use harims95/hobbylm-embed-140m-mlx with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download harims95/hobbylm-embed-140m-mlx --local-dir hobbylm-embed-140m-mlx
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
HobbyLM-Embed-140M (MLX, float16)
MLX version of harims95/hobbylm-embed-140m for Apple Silicon: the same weights in float16 (the expert router and its selection bias stay float32), producing 512-d, L2-normalised embeddings.
| File | Content |
|---|---|
model.safetensors |
float16 weights (280 MB) |
quant.json |
{"bits": null, "dtype": "float16"} |
hobbylm_mlx.py |
the MLX model and encoder (Apache-2.0) |
config.json, tokenizer.json, tokenizer_config.json, sentence_bert_config.json, config_sentence_transformers.json |
from the main model repo |
Usage
pip install mlx tokenizers numpy huggingface_hub
Tested versions: mlx 0.32.4, tokenizers 0.23.3, numpy 2.5.5, huggingface_hub 2.4.0.
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
Prompts. For search and RAG, encode queries with prompt_name="query" (adds query: ) and documents with
prompt_name="passage" (adds passage: ). For similarity, clustering and classification, use plain text (no prompt_name).
Input length. 512 tokens by default (read from sentence_bert_config.json), which is what MTEB(eng, v2) was measured
at. For long documents (up to 2,048 tokens):
enc = Encoder(path, quant_dir=path, max_seq_length=2048)
Tested
Tested on Apple M4 (macOS 15.5, mlx 0.32.4): float32 matches Sentence Transformers exactly (cosine 1.00000000); float16 lowest cosine 0.99965.
Licence
Apache-2.0 (LICENSE).
Team
Hariharan M. S., Prabhurajhan R.
- Downloads last month
- -
Quantized
Model tree for harims95/hobbylm-embed-140m-mlx
Base model
harims95/hobbylm-embed-140m