Ismail Ben Alla

tiny-rag

Ask Your Texts, Images and Sounds

RAG · Nov 2026 · In progress

Ask a library of texts, images and sounds: every model is mine and trained from scratch, except the writer.

Built withPyTorchGradioNumPyHugging Face Datasetspytest

tiny-rag — overview

Overview

tiny-rag answers questions over your own files: texts, PDFs, images and sounds. You can ask with a text, an image or a sound, and each query searches its own index with its own model.

Every model in the loop comes from my tiny-* family: tiny-bert as the encoder, tiny-embedder for the embeddings, tiny-nn-search for the indexes, tiny-reranker for reranking. The writer is Qwen2.5-0.5B-Instruct, run inside tiny-llm. TinyRAG.from_checkpoints() loads the family checkpoints from a shared model store.

It is the from-scratch counterpart of Juridia, my legal RAG built on off-the-shelf tools.

The question

Can I build a full RAG system from my own small from-scratch models, and ask it with a text, an image or a sound?

Key features

How it works

  1. Ingest once

    Files are chunked and embedded per modality by tiny-embedder, then stored in three tiny-nn-search indexes. Images and sounds take their caption from a sibling .txt file.

  2. Search and rerank

    The query is embedded with its own model, searched in its index by keyword, dense or hybrid (RRF), and the top-k is reranked by tiny-reranker.

  3. Answer with sources

    Qwen2.5-0.5B-Instruct, run by tiny-llm, writes the answer from the numbered sources and returns it with the cited sources.

Examples

The pipeline: ingest once into three indexes, then embed, search, rerank and answer, each box a family repo.
The pipeline: ingest once into three indexes, then embed, search, rerank and answer, each box a family repo.
The Gradio app with the demo library loaded: 300 SQuAD dev paragraphs, 48 Flickr30k images and 32 Clotho clips, and the model each modality uses.
The Gradio app with the demo library loaded: 300 SQuAD dev paragraphs, 48 Flickr30k images and 32 Clotho clips, and the model each modality uses.
Real answers from the demo library with BM25 retrieval: the question, Qwen2.5-0.5B's answer, the gold answer and the source it used.
Real answers from the demo library with BM25 retrieval: the question, Qwen2.5-0.5B's answer, the gold answer and the source it used.

Tech stack

What I learned

Limitations

Related projects