fuellabs
HobbyLM-Embed Browse docs

Guides / Fine-tuning

Fine-tune on your own data.

Use your own question-passage pairs to create a separate local model with the public cookbook.

Get the cookbook

Terminal
git clone https://github.com/fuellabs-ai/cookbooks.git
cd cookbooks/fine-tune-on-your-data
pip install sentence-transformers accelerate datasets

The script loads the base model with trust_remote_code=True, pinned to revision ea708cee107818fa0c1871eebd26d82a1e3fb1aa. Keep that pin when adapting the script.

Prepare your pairs

Make a CSV with query and passage columns. Use raw text. The trainer maps those columns to the model's named prompts. Keep a separate held-out set for evaluation.

Run and save

Terminal
python finetune.py --train my_pairs.csv --out my-hobbylm-embed

The script saves a new model folder. Keep the original release unchanged. The recipe uses 512-token inputs.

Check before switching

Follow the cookbook's evaluation instructions with your own held-out questions and corpus. Decide whether to switch based on that check. Fine-tuning does not guarantee an accuracy improvement.

Load your local model

Python
from sentence_transformers import SentenceTransformer

model = SentenceTransformer("my-hobbylm-embed", trust_remote_code=True)
queries = model.encode(["Where is our leave policy?"], prompt_name="query")
passages = model.encode(["The leave policy is in the handbook."], prompt_name="passage")

512 tokens by default and up to 2,048 tokens opt-in. Set model.max_seq_length = 2048 after loading to opt in. Re-embed the whole corpus with the model you use. Keep the original and fine-tuned vectors in separate indexes.