Ismail Ben Alla

tiny-embedder

Text, Image and Audio Embeddings from Scratch

Multimodal · Nov 2026 · In progress

Text, images and sounds as vectors: three small embedding models built on my own tiny-bert.

Built withPyTorchNumPyHugging Face DatasetspytestJavaScript

tiny-embedder — overview

Overview

tiny-embedder is three embedding models written from scratch in PyTorch. Each one turns its input into a 256-number, L2-normalised vector, so a dot product is a cosine similarity.

The text model is a bi-encoder for search. The image model puts pictures and captions in one space, like CLIP. The audio model does the same for sounds and music, like CLAP. All three use tiny-bert, my own pre-trained encoder, as the text tower.

It is part of my tiny family: tiny-bert gives the encoder and tokenizer, and tiny-nn-search and tiny-rag load the finished checkpoints from a shared model store.

The question

Can one small pre-trained encoder carry a text search model, a CLIP-style image model and a CLAP-style audio model, all trained from scratch?

Key features

How it works

  1. One encoder, three towers

    The text tower is tiny-bert (6 blocks × 256, RoPE, RMSNorm, SwiGLU). The image and audio towers cut their input into patches and run them through the same kind of tiny-bert blocks.

  2. Find your partner in the batch

    Each query, caption, image or sound must pick its own pair among everything else in the batch. Every other item is a free negative; text also gets one BM25 hard negative.

  3. Realistic, held-out data

    Batches mix MS MARCO, NQ, GooAQ and SQuAD for text, COCO, Flickr30k, Tiny-ImageNet and CIFAR-100 for images, and AudioCaps, Clotho, MusicCaps, FMA and more for audio. Test sets are never sampled.

  4. Benchmark and publish

    One script trains the 6 runs, evaluates everything on held-out tests, writes the tables and plots, and publishes the checkpoints to the family's model store.

Examples

The three embedders: text, pictures and sounds each go through their tower and land in a 256-d vector space.
The three embedders: text, pictures and sounds each go through their tower and land in a 256-d vector space.
The models in detail: which parts start from tiny-bert, which are new, and the contrastive loss over the batch.
The models in detail: which parts start from tiny-bert, which are new, and the contrastive loss over the batch.
Real Flickr30k test pictures from the project page; the model’s top captions will appear next to them after training.
Real Flickr30k test pictures from the project page; the model’s top captions will appear next to them after training.
The sanity check: each tiny tower overfits 16 real validation pairs on the CPU in about a second.
The sanity check: each tiny tower overfits 16 real validation pairs on the CPU in about a second.

Tech stack

What I learned

Limitations

Related projects