Skip to main content

Add your description here

Project description

Embed Lab (embed_lab)

Embed Lab is a small Python tool that scaffolds a repeatable workspace for fine-tuning information retrieval (IR) embedding models. It gives you a clean project layout, runnable experiment files, and an “inventory” layer where you centralize reusable training/evaluation code instead of rewriting it per experiment.

The goal is consistency: one place to define datasets, preprocessing, training, evaluation, and plotting, and many small experiment scripts that compose those building blocks.

Why we created this

Fine-tuning IR embedding models tends to drift into ad-hoc notebooks and one-off scripts: inconsistent data loading, hard-to-reproduce runs, and experiments that are difficult to compare. Embed Lab exists to:

  • Centralize the core pipeline (datasets, preprocessing, training, evaluation) in inventory/
  • Keep experiments as small, explicit Python files in experiments/
  • Make results reproducible by writing artifacts to results/<experiment_name>/
  • Reduce setup time by generating a working template with emb init

Although the starter template ships with a Sentence-Transformers (SBERT) example, the structure is intended to generalize to other training stacks and tasks.

What you get

Running emb init generates a “lab” folder with:

  • inventory/: reusable modules (datasets, preprocess, train, evaluate, plotting)
  • experiments/: runnable experiment scripts (exp_01_baseline.py, etc.)
  • data/: JSONL splits (train/dev/gold) with a tiny sample dataset
  • results/: where all run artifacts are written (git-ignored)

This separation is deliberate: inventory/ changes slowly, experiments/ grows over time as your research log.

Install

Embed Lab is designed to be used with uv, but it works with any environment manager.

uv add embed-lab

Confirm the CLI is available:

emb --help

Quickstart

Create a new lab in the current directory:

emb init .

Install the example pipeline dependencies (the generated template uses these):

uv add sentence-transformers datasets plotly

Run the baseline experiment:

uv run experiments/exp_01_baseline.py

You should see artifacts under:

  • results/exp_01_baseline/final/ (saved model)
  • results/exp_01_baseline/eval/ (metrics + evaluator CSV)
  • results/exp_01_baseline/plots/ (interactive HTML charts)

How it works

Embed Lab itself is a CLI that writes a curated project skeleton to disk. The generated code is intentionally simple and editable, so teams can “own” their lab and adapt it.

The default workflow looks like:

  1. Load examples from data/*.jsonl
  2. Preprocess (optionally)
  3. Train and save a model
  4. Evaluate on a gold split
  5. Plot training curves and metrics

A minimal example of the generated experiment entrypoint:

from pathlib import Path

from inventory.datasets import load_splits
from inventory.preprocess import preprocess
from inventory.train import train

def main() -> None:
    run_dir = Path("results") / "exp_01_baseline"
    train_raw, dev_raw, gold_raw = load_splits(Path("data"))
    train_dir = train(preprocess(train_raw), preprocess(dev_raw), run_dir)

if __name__ == "__main__":
    main()

Project status and roadmap

Embed Lab is intentionally small today: it scaffolds a working lab and stays out of your way. The long-term plan is to make the CLI smarter and the templates more diverse.

Planned directions:

  • Data validation helpers in the CLI: duplicate detection across splits, overlap/leak checks, schema validation, basic stats
  • Multiple templates: pairwise contrastive, in-batch negatives (e.g., MultipleNegativesRankingLoss), hard-negative mining layouts, cross-encoder reranking experiments
  • Extensible template registry: add templates without touching core CLI logic
  • Better run metadata: automatic run manifests (model, loss, hyperparams, git commit, dataset hash)

If you want to contribute, these are great entry points.

Contributing

Contributions are welcome: templates, CLI improvements, docs, and bug fixes.

Suggested contribution workflow:

  1. Fork the repo
  2. Create a feature branch
  3. Add tests or a small reproducible example if applicable
  4. Open a PR with a clear description and rationale

Design preferences:

  • Keep code minimal and readable
  • Favor type annotations
  • Avoid adding heavy dependencies to the core package (templates can require extras)

Development notes

This repo is packaged as embed_lab and exposes the emb command via:

  • emb = "embed_lab.cli:app"

The CLI is built with Typer, and templates are stored as strings in embed_lab/templates.py. The emb init command writes those templates into the target directory if files don’t already exist.

Repository layout

  • src/embed_lab/cli.py: Typer CLI entrypoint
  • src/embed_lab/templates.py: template content written by emb init
  • pyproject.toml: packaging + emb script definition

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_vx-0.5.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_vx-0.5.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file python_vx-0.5.0.tar.gz.

File metadata

  • Download URL: python_vx-0.5.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for python_vx-0.5.0.tar.gz
Algorithm Hash digest
SHA256 c23b2d21697950d87c7fa7f21acf9ee3d2d785280e79c910b39225c56b666334
MD5 48c820f14e548db1979d0fb070da19f7
BLAKE2b-256 faba056456850bb24283d82d1d976e77b84c85bedd9fc210ac92e72cdb86a93f

See more details on using hashes here.

File details

Details for the file python_vx-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: python_vx-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for python_vx-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d39f6dca5fee17b46f890fa8feef4af8044492e2c2c76b3e8e39ca02315aa5d
MD5 0b0e23cf54b3eaffd8195f91afea86ae
BLAKE2b-256 fe50c25affba2df4d6f597cb10a91076cace45ebe08224ddcc53dfd4f214430f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page