Skip to main content

langchain-hobbylm

LangChain wrapper for HobbyLM-Embed, a local English embedding model from Fuel Labs.

The model has 140M total parameters and 36M active (8 of 32 experts per token), produces 512-dimensional vectors, and reads 512 tokens by default (up to 2,048 if you raise the limit). License: Apache-2.0. It scored 62.33 on MTEB(eng, v2), submitted to the official leaderboard.

Training compute was provided by Jarvis Labs.

This package is a draft until it is published to PyPI. Do not pip install langchain-hobbylm from PyPI until Fuel Labs has published it. [TO CONFIRM] repo and PyPI ownership.

Install

pip install langchain-hobbylm

Until the package is on PyPI, install from the local checkout:

pip install -e .

You also need a working sentence-transformers install. Hari tested the model with sentence-transformers 6.3.0 and transformers 5.23.0.

Use it

from langchain_hobbylm import HobbyLMEmbeddings

embeddings = HobbyLMEmbeddings()

query_vector = embeddings.embed_query("How do I load HobbyLM-Embed?")
doc_vectors = embeddings.embed_documents(
    ["HobbyLM-Embed runs locally on your machine."]
)
print(len(query_vector), len(doc_vectors[0]))
# 512 512

512 tokens by default; for long documents use HobbyLMEmbeddings(model_kwargs={"tokenizer_kwargs": {"model_max_length": 2048}})

Pinned to revision ea708cee (full sha ea708cee107818fa0c1871eebd26d82a1e3fb1aa) by default; pass revision= to change it.

embed_query calls encode with prompt_name="query" and embed_documents uses prompt_name="passage". The model adds query: or passage: itself. Pass raw text. Do not also type the prefixes.

trust_remote_code=True is required and is the default. The model uses custom mixture-of-experts code.

Extra normalisation is not applied by default. The model already outputs unit-length vectors (norm 1.0), so cosine equals the dot product. normalize_embeddings=True is harmless if you want to set it.

For classification, clustering or similarity, do not use this wrapper's query/document methods. Encode plain text with Sentence Transformers and no prompt_name:

from sentence_transformers import SentenceTransformer
model = SentenceTransformer("harims95/hobbylm-embed-140m", trust_remote_code=True)
emb = model.encode(["what is an embedding?"])
print(emb.shape)
# (1, 512)

That canonical load snippet was tested by Hari. encode_query and encode_document also work.

Day-one alternative

You do not need this package to use the model in LangChain. The generic route is HuggingFaceEmbeddings from langchain-huggingface:

pip install langchain-huggingface
from langchain_huggingface import HuggingFaceEmbeddings

embeddings = HuggingFaceEmbeddings(
    model_name="harims95/hobbylm-embed-140m",
    model_kwargs={"trust_remote_code": True},
    encode_kwargs={"prompt_name": "passage"},
    query_encode_kwargs={"prompt_name": "query"},
)

See the official Sentence Transformers page.

Model

License

This package is Apache-2.0, matching the model.

Metadata

Release files for langchain-hobbylm 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-hobbylm 0.1.1
File Size Uploaded Provenance Actions
langchain_hobbylm-0.1.1.tar.gz 8.8 kB Without provenance Details for langchain_hobbylm-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-hobbylm 0.1.1
File Interpreter ABI Platform Actions
langchain_hobbylm-0.1.1-py3-none-any.whl Python 3 none any Details for langchain_hobbylm-0.1.1-py3-none-any.whl

Total release size: 17.9 kB

Release files / langchain_hobbylm-0.1.1.tar.gz

Download URL langchain_hobbylm-0.1.1.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
eff034a05185109557abbbcb64e53d575aa46b1945f4121b89db4ad9d584061b
BLAKE2b-256 checksum
How to use checksums
c9bcd47c02adcf7ebeb2fa3892a660170d1c7b5306715c513c2f2d04ad7d09a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / langchain_hobbylm-0.1.1-py3-none-any.whl

Download URL langchain_hobbylm-0.1.1-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
62139e6d61b86c649bd092182c70aec9b3299aa2f48466d9ab402ff561ef6893
BLAKE2b-256 checksum
How to use checksums
8a5af2150f82a8b686063fc6bbda99f1b65f6723469fe410b4ec2bcd3b673600
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for langchain-hobbylm 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page