Skip to content
Sarvesh's AI Newsletter

Built a Local Multimodal Search Engine with Gemma 4 and Qdrant: A Step-by-Step Build Guide

How I made hours of video, audio, and text searchable by plain language, and how you can rebuild it from scratch, entirely on your own machine

Sarvesh Talele

· 18 min read

Share:

What we’re building (and why)

That single constraint, local first, shaped every decision in this build. It is the reason the architecture looks the way it does, and it’s also why this is a tutorial about two tools doing a lot of work locally: Gemma 4 (served by Ollama) for understanding pixels and audio, and Qdrant for storing and searching vectors.

This guide walks the whole thing from an empty folder to a working search engine, in the order I actually built it:

  1. Set up the environment (uv, FFmpeg, Ollama, models)
  2. Understand the one design decision that makes multimodal search work: describe-then-embed
  3. Install and choose Qdrant, and why I picked it
  4. Design the Qdrant schema for moments, not files (the heart of this tutorial)
  5. Build the describe-then-embed bridge with Gemma 4
  6. Build the ingestion pipeline (how to actually get data in)
  7. Query: per-space search, fusion, MaxSim, rerank
  8. Route the questions retrieval shouldn’t answer (counting, inventory)
  9. Stream the answers, add guardrails, and learn from the performance traps

Let’s go.

Step 0: Prerequisites and environment

You need three things on the machine before running Python:

  1. macOS (Apple Silicon recommended) or Linux
  2. `uv`, the Python package/venv manager this project uses
  3. `ffmpeg`, every video/audio extraction step shells out to it
  4. Ollama ≥ 0.30, the local runtime that serves Gemma 4

On macOS

# Tooling
brew install ffmpeg
curl -LsSf https://astral.sh/uv/install.sh | sh
# Ollama: download from https://ollama.com and launch it (it runs a local server on :11434)

# 1. venv + editable install (+ dev tools)
uv venv --python 3.12
uv pip install -e ".[dev]"

# 2. Pull the models (≈10 GB for gemma4:e4b)
ollama pull gemma4:e4b
ollama pull nomic-embed-text

On Windows

1. Install UV
Open PowerShell as Administrator:
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
uv --version

2. Install FFmpeg - powershell
winget install Gyan.FFmpeg
ffmpeg -version

Restart PowerShell if FFmpeg is not found.

Two models, two jobs:

  • `gemma4:e4b`, the multimodal brain. It reads images and listens to audio natively, and it also drives query-intent analysis, reranking, and the RAG chat. The E in E4B stands for effective parameters: an efficient design that keeps the memory footprint friendly on Apple Silicon while keeping vision and audio in the same model.
  • `nomic-embed-text`, a dedicated text embedder that maps everything into one unified 768-dimensional space.

Don’t have the weights yet? The whole pipeline, ingest, index, search, RAG runs against a deterministic hash-based stub so you can develop offline and in CI:

DEEPSEARCH_USE_STUB=true uv run uvicorn deepsearch.api.main:app — port 8000 “

The “two-model trap” I avoided

The obvious first instinct is to reach for a pipeline with three or four specialist models: one for speech-to-text, one for OCR on the frames, one vision-language model for the screen, and glue to stitch the outputs together. That works, and it’s a maintenance tax you pay forever. Four downloads, four sets of version drift, four failure modes.

Gemma 4 changed that: one model reads images and listens to audio. So the model question was settled early, and the interesting problem moved to retrieval, which is where Qdrant comes in.

Step 1: The one idea that makes multimodal search work: describe, then embed

Before any schema, you have to internalise the single most important design decision in the system. Get this wrong and nothing downstream matters.

Here is the trap, and it’s a good one because it sounds correct:

“Gemma is multimodal, so I’ll embed the video frames into vectors, embed the audio into vectors, embed the text into vectors, store all of them in Qdrant, and at query time embed the user’s question and search across all three spaces. Cross-modal search, solved.”

It does not work. Gemma 4 is a generative decoder. It is not a contrastive dual-encoder like CLIP or ImageBind. Models like CLIP are trained with one specific objective: to push an image and its caption close together in a shared space. Gemma has no such objective. Its internal image activations are optimised for predicting the next token, not for sitting near the text that describes them.

If you index raw frame activations and search them with a text query vector, you’re comparing two things in different coordinate systems. The cosine similarity is close to noise. You’ll get results, and they’ll be confidently wrong.

The fix: stop treating Gemma as an embedder and start treating it as a translator.

  1. Gemma describes each keyframe in a sentence or two.
  2. Gemma (or Whisper, more on that later) transcribes each audio chunk into text.
  3. Captions are already text.

Now every modality is text, and a single dedicated embedder (nomic-embed-text) maps all of it into one unified 768-dimensional space. The user query gets embedded by the same model into the same space. A natural-language query now genuinely retrieves across video, audio, and text, because everything, including the question, lives in one coordinate system.

Image created by Author

Image created by Author

Step 2: Installing Qdrant (and why I chose it)

Illustration

Why Qdrant

I evaluated several vector databases for this architecture, and Qdrant emerged as the optimal choice due to its alignment with local-first, multimodal constraints:

Qdrant Documentation Link: https://qdrant.tech/documentation/

  1. Embedded, Zero-Infrastructure Deployment: The primary constraint is a local-first environment without cloud dependencies. Qdrant’s Python client provides an in-process, disk-backed database — QdrantClient(path=”./qdrant_storage”) — that requires no Docker or daemons. This turns the project into a portable laptop tool.
  2. Seamless Scalability: The application code is agnostic to the database topology. By toggling the DEEPSEARCH_QDRANT_URL environment variable, the same codebase transitions from embedded local storage to a remote Qdrant server, enabling fleet-wide scaling without rewriting the storage logic.
  3. First-Class Named Vectors: Qdrant supports multiple independently searchable vector fields per point. This maps perfectly to our requirement to manage distinct text, video, and audio embedding spaces within a single collection, eliminating the need to synchronise separate indexes.
  4. Native ColBERT-style MaxSim: Late-interaction retrieval is a native concept rather than an implementation challenge, providing efficient multi-vector support out of the box.
  5. Integrated Quantisation and Filtering: Features like INT8 scalar quantisation (to optimise index size in unified memory) and metadata pre-filtering are simple configurations rather than engineering hurdles.

These are simple configurations, not heavy engineering tasks.

There is nothing to install beyond the Python client, which uv pip install -e. already pulled (qdrant-client>=1.12). The store simply opens a folder:

# src/deepsearch/vectorstore/store.py
def _connect(self) -> QdrantClient:
    url = self.settings.qdrant.url.strip()
    if url:                                   # server mode
        log.info(f"Connecting to Qdrant server at {url}")
        return QdrantClient(url=url)
    path = self.settings.qdrant_storage_path  # embedded local mode
    path.mkdir(parents=True, exist_ok=True)
    log.info(f"Using embedded Qdrant (local mode) at {path}")
    return QdrantClient(path=str(path))

With DEEPSEARCH_QDRANT_URL empty (the default), the index lives in ./qdrant_storage. Done. No server.

Option B — Qdrant as a server (when you want the dashboard or scale)

When you outgrow embedded mode, you want the web dashboard, or you want several processes hitting one index, flip to a server with Docker:

docker compose up -d                       # starts qdrant on :6333 (REST) / :6334 (gRPC)
export DEEPSEARCH_QDRANT_URL=http://localhost:6333

The docker-compose.yml is tiny:

services:
  qdrant:
    image: qdrant/qdrant:latest
    container_name: deepsearch-qdrant
    ports:
      - "6333:6333"   # REST / dashboard at http://localhost:6333/dashboard
      - "6334:6334"   # gRPC
    volumes:
      - ./qdrant_storage:/qdrant/storage
    restart: unless-stopped

Step 3: Designing the Qdrant schema for moments, not files

This is the heart of the build. Two requirements pull against each other here, and how you resolve the tension determines whether timestamps are free or impossible.

Requirement 1: Multivectors (ColBERT-style late interaction)

Qdrant supports an array of vectors per named field, scored with MaxSim, the ColBERT-style late-interaction idea. A single asset (a whole video) can hold, say twenty keyframe vectors, and you score the entire asset by its best-matching frame. This gives fast, high-recall asset-level retrieval: “Which files are even relevant?”

Requirement 2: Accurate playback

You don’t want to know that a file matches. You want the exact offset so the player can seek to the second.

Why they fight

Asset-level MaxSim gives you one score per asset and throws away the sub-vector matched. You lose the timestamp. So you cannot make the multivector point your primary retrieval unit, not if pinpoint playback is the whole point.

The resolution: the fragment is the primary retrieval unit

So I index at two granularities in one collection:

  1. Fragment points (primary). One Qdrant point per keyframe, per audio chunk, per caption line. Each fragment populates exactly one of three named single-vector spaces and carries a payload with the precise offsets. These are what make timestamps free.
  2. Asset-level MaxSim points (secondary). One point per asset holding the array of that asset’s frame/audio vectors, in two multivector spaces, for fast recall.

The three named single-vector spaces and the two multivector spaces:

# src/deepsearch/vectorstore/schema.py
# Fragment-level, temporal targeting, one populated per fragment point.
NAMED_VECTORS = ("text_descriptions", "video_frames", "audio_chunks")

# Asset-level MaxSim multivector spaces (ColBERT-style arrays per asset).
MULTIVECTOR_VECTORS = ("frames_maxsim", "audio_maxsim")

And the fragment data model — note that the payload carries start_s / end_s, which is where second-accurate playback comes from:

@dataclass
class Fragment:
    asset_id: str               # stable id shared by all fragments of one file
    asset_name: str
    file_path: str              # absolute path to the source media on disk
    modality: Modality          # TEXT | VIDEO | AUDIO
    text: str                   # description / transcript / caption (this is what gets embedded)
    start_s: float = 0.0        # fragment start offset within the asset
    end_s: float = 0.0          # fragment end offset within the asset
    duration_s: float = 0.0
    category: str = "uncategorized"
    thumbnail_path: str | None = None
    ingested_at: int = ...
    point_id: str = ...

# Payload fields indexed for fast pre-filtering:
KEYWORD_INDEXES = ("asset_id", "modality", "category")
INTEGER_INDEXES = ("ingested_at",)

Creating the collection (the multivector setup, line by line)

Here is ensure_collection, the one function that declares the whole schema:

# src/deepsearch/vectorstore/store.py
def ensure_collection(self, recreate: bool = False) -> None:
    dim = self._embedding_dim()      # 768 for nomic-embed-text (probed live at startup)
    distance = self._distance()      # Cosine

    # 1) Three single-vector named spaces  , one per modality (fragment level).
    vectors = {
        name: models.VectorParams(size=dim, distance=distance)
        for name in NAMED_VECTORS    # text_descriptions, video_frames, audio_chunks
    }

    # 2) Two MaxSim multivector spaces (ColBERT-style late interaction, asset level).
    for name in MULTIVECTOR_VECTORS:  # frames_maxsim, audio_maxsim
        vectors[name] = models.VectorParams(
            size=dim,
            distance=distance,
            multivector_config=models.MultiVectorConfig(
                comparator=models.MultiVectorComparator.MAX_SIM
            ),
        )

    # 3) Create the collection with INT8 scalar quantization (always in RAM).
    self.client.create_collection(
        collection_name=self.collection,
        vectors_config=vectors,
        quantization_config=self._quantization(),   # scalar INT8, always_ram
    )

    # 4) Payload indexes so Qdrant can PRE-FILTER before the vector search.
    for field in KEYWORD_INDEXES:    # asset_id, modality, category
        self.client.create_payload_index(
            self.collection, field, models.PayloadSchemaType.KEYWORD
        )
    for field in INTEGER_INDEXES:    # ingested_at
        self.client.create_payload_index(
            self.collection, field, models.PayloadSchemaType.INTEGER
        )

Four things are happening, and each earns its place:

  1. Named single-vector spaces: the fragment-level spaces a text query searches directly.
  2. MaxSim multivector spaces: declared with MultiVectorConfig(comparator=MAX_SIM). This is the entire multivector setup — same dimension, same distance, plus the MaxSim comparator. That one line is what turns a named field into a ColBERT-style array.
  3. Scalar quantisation: compresses the vectors to INT8 and pins them in RAM (always_ram). This is what lets the database coexist with a multi-gigabyte model inside the same unified memory on a laptop.
  4. Payload indexes: they let Qdrant pre-filter before the vector search runs, so a query like “only videos added in the last thirty days” becomes a cheap keyword + integer filter instead of a full scan.

Writing a fragment point

Each fragment populates exactly one named vector, the one matching its modality:

def upsert_fragments(self, fragments, vectors) -> int:
    points = []
    for frag, vec in zip(fragments, vectors, strict=True):
        points.append(
            models.PointStruct(
                id=frag.point_id,
                vector={frag.modality.value: vec},  # populate ONE named space
                payload=frag.payload(),             # asset_id, file_path, start_s, end_s, …
            )
        )
    if points:
        self.client.upsert(self.collection, points=points, wait=True)
    return len(points)

Writing the asset-level MaxSim point

One point per asset, holding the arrays of frame and audio vectors. The point ID is namespaced so it never collides with a fragment ID:

def upsert_asset_multivectors(self, asset_id, payload, frame_vectors, audio_vectors):
    vec: dict[str, list[list[float]]] = {}
    if frame_vectors:
        vec["frames_maxsim"] = frame_vectors   # array of N frame vectors
    if audio_vectors:
        vec["audio_maxsim"] = audio_vectors    # array of M audio vectors
    if not vec:
        return
    point_id = str(uuid.uuid5(uuid.NAMESPACE_OID, f"asset:{asset_id}"))
    self.client.upsert(
        self.collection,
        points=[models.PointStruct(id=point_id, vector=vec, payload=payload)],
        wait=True,
    )

A sharp edge worth flagging: compute MaxSim client-side in embedded mode

Here’s a gotcha that cost me time. The embedded Qdrant client (the on-disk, no-server mode) does not reliably run native multivector queries. I tried both the 1-D and 2-D query shapes and got internal errors. The portable fix is to compute MaxSim on the client: scroll the asset-level points, take the maximum dot product between the query vector and each stored sub-vector, and rank. Because all vectors are L2-normalised, the dot product is cosine similarity. This runs identically in embedded and server mode:

def search_maxsim(self, vector_name, query_vector, limit, query_filter=None):
    records, _ = self.client.scroll(
        self.collection, scroll_filter=query_filter,
        limit=10_000, with_payload=True, with_vectors=[vector_name],
    )
    scored = []
    for r in records:
        vecs = (r.vector or {}).get(vector_name) if isinstance(r.vector, dict) else None
        if not vecs:
            continue
        best = max(_dot(query_vector, sub) for sub in vecs)   # MaxSim
        scored.append(models.ScoredPoint(id=r.id, version=0, score=best, payload=r.payload))
    scored.sort(key=lambda p: p.score, reverse=True)
    return scored[:limit]

The takeaway for this section: pick your retrieval unit before anything else. Fragments-versus-assets is not a detail; it decides whether timestamps are free or impossible. I get both: fragments for the exact second, an asset-level MaxSim point for fast recall, all in one Qdrant collection.

Step 4: The describe-then-embed bridge (Gemma 4 client)

Now make Step 1 real. The model client never pretends to produce retrieval embeddings from pixels; it produces words, which the embedder then turns into vectors.

# src/deepsearch/models/gemma.py
def describe_image(self, image_path) -> str:
    if self.is_stub:
        return f"[stub frame description for {Path(image_path).name}]"
    b64 = _b64_file(image_path)
    resp = self._invoke(
        self._client.generate,
        model=self.settings.models.gemma_model,
        prompt=_FRAME_PROMPT,
        images=[b64],
        options=self._desc_opts(),
        keep_alive=self.settings.models.keep_alive,
        think=False,        # see note below
    )
    return resp["response"].strip()

Two details earn their place:

  1. `think=False`. Gemma 4 is a thinking model. If you let it think while capping the output budget (num_predict), the reasoning tokens eat the budget, and you get an empty answer. I learned that the hard way: ingestion produced zero fragments and crashed on an empty vector. Turning thinking off for description/transcription fixed it.
  2. `keep_alive` (30m). Keeps the weights resident in VRAM between calls so the next one doesn’t reload the model, a big latency win on local Apple Silicon.

The embedding side is just as plain, empty input is guarded, and the dimension is checked, so a misconfigured model fails instead of silently corrupting the index:

def embed_text(self, texts: list[str]) -> list[list[float]]:
    if not texts:
        return []
    out = []
    ka = self.settings.models.keep_alive
    for text in texts:
        prompt = text if text and text.strip() else " "   # never send an empty prompt
        resp = self._invoke(self._client.embeddings,
                            model=self.embed_model_name, prompt=prompt, keep_alive=ka)
        vec = list(resp.get("embedding") or [])
        if len(vec) != self.dim:
            raise ValueError(f"Embedding model returned {len(vec)} dims (expected {self.dim}).")
        out.append(_normalize(vec))   # L2-normalise so dot product == cosine
    return out

Note the _normalise at the end, that’s the invariant the client-side MaxSim relies on.

Step 5: The ingestion pipeline (how to actually ingest)

With the schema and the bridge in place, ingestion is the orchestration that fills the index. For each file:

video  → keyframes (described) + audio chunks (transcribed) + sidecar captions
audio  → audio chunks (transcribed)
image  → single description
text   → timed/untimed segments

Run it

From the CLI:

# Index a single file or a whole folder
uv run deepsearch ingest ./data/media --category meetings

# Or via the Make target
make ingest P=./data/media C=meetings

Or from the UI: open the Ingest tab, drop in video/audio/.srt/.vtt/text, pick a category, click Ingest. The backend streams live progress over Server-Sent Events.

What happens inside ingest_file

self.store.ensure_collection()      # create the schema if needed (idempotent)
asset_id = _asset_id(path)          # stable sha1 of the resolved path
self.store.delete_asset(asset_id)   # re-ingest REPLACES, never duplicates
# ... build fragments per modality ...
fragments = [f for f in fragments if (f.text or "").strip()]  # drop empties (zero-vectors break upsert)
self._embed_and_upsert(fragments, progress)

Keyframes come from scene-boundary detection (PySceneDetect’s content detector), falling back to uniform sampling, capped at max_keyframes (12 by default, fewer Gemma vision calls = much faster ingest). Each keyframe is written as a JPEG (used both as the Gemma input and the UI thumbnail) and tagged with its timestamp.

Audio is normalised to 16 kHz mono WAV via FFmpeg (with optional afftdn denoise), then transcribed — see the performance note below for which transcriber.

Embedding and the dual write happen together in _embed_and_upsert: fragments are embedded in batches, each batch is upserted as fragment points, and the per-modality vectors are accumulated so that, at the end, a single asset-level MaxSim point is written:

def _embed_and_upsert(self, fragments, progress):
    frame_vecs, audio_vecs, asset_payload = [], [], None
    for group in _batched(fragments, self.settings.ingestion.batch_size):
        vectors = self.model.embed_text([f.text for f in group])
        self.store.upsert_fragments(group, vectors)          # fragment points
        for frag, vec in zip(group, vectors, strict=True):
            asset_payload = asset_payload or {... "kind": "asset"}
            if frag.modality is Modality.VIDEO:   frame_vecs.append(vec)
            elif frag.modality is Modality.AUDIO: audio_vecs.append(vec)
    if asset_payload and (frame_vecs or audio_vecs):
        self.store.upsert_asset_multivectors(           # ONE asset-level MaxSim point
            asset_payload["asset_id"], asset_payload, frame_vecs, audio_vecs
        )

Verify it landed

uv run deepsearch stats
# assets=1 fragments=37 by_modality={'video_frames': 12, 'audio_chunks': 24, 'text_descriptions': 1}

Step 6: Querying: per-space search, fusion, MaxSim, rerank

A search runs: safety filter → intent → embed → per-space prefetch → fuse → (optional) rerank → timestamped hits.

# src/deepsearch/query/search.py
qvec = self.model.embed_query(query)
flt = build_filter(categories, modalities, ingested_after)   # payload pre-filter

# Only query spaces with non-trivial weight (saves work for focused intents).
spaces = [s for s in NAMED_VECTORS if weights.get(s, 0.0) > 0.01] or list(NAMED_VECTORS)
per_space = {
    space: self.store.search_named(space, qvec, cfg.prefetch_limit, flt)
    for space in spaces
}

strategy = "weighted" if weights_override is not None else cfg.fusion
fused = fusion_mod.fuse(per_space, strategy, weights)

top = fused[: cfg.rerank_top_n] if cfg.rerank else fused[: cfg.top_k]
if cfg.rerank and len(top) > 1:
    top = rerank(query, top, cfg.rerank_top_n)
hits = [self._to_hit(h) for h in top][: cfg.top_k]

Fusion is a client-side decision, not a Qdrant feature

A lot of write-ups imply you can hand Qdrant a weight per named vector and let it blend the spaces. You can’t. Qdrant fuses candidate lists you define (via its Query API, prefetch, and RRF/DBSF); the weighting across named spaces happens in your code. So the engine searches each weighted space, then fuses:

  1. RRF (Reciprocal Rank Fusion) is the default, rank-based and scale-free, so it doesn’t care that the three spaces produce scores on different scales.
  2. Weighted kicks in when the user drags the weight sliders. That was a real bug at first: the weights existed, but the default RRF ignored them, so the sliders did nothing until the engine learned to honour an explicit override (strategy = “weighted” if weights_override is None).

One honest tradeoff: rerank is slow

The Gemma rerank is a listwise prompt, and on a local 4-billion-effective-parameter model, a single rerank call can run for tens of seconds. So rerank and the LLM intent step are off by default for fast local search; you flip them on per request when quality matters more than latency. RRF on its own is already strong.

Step 7: Route the questions retrieval shouldn’t answer

Some questions are not retrieval questions, and knowing which to route away from the model is half of making a grounded assistant feel trustworthy.

Counting. “How many times is finance mentioned?” must never be a model guess; it will round, hedge, and miss occurrences outside the top results. So counting is deterministic: scan every fragment, count exact substring matches, and report the number with timestamps. No model in the loop.

def _count(self, term: str) -> dict:
    needle = term.lower()
    total, sources, per_asset = 0, [], {}
    for p in self.store.all_fragments():
        n = (p.get("text") or "").lower().count(needle)
        if n:
            total += n
            per_asset[p["asset_name"]] = per_asset.get(p["asset_name"], 0) + n
            sources.append(Source(...))
    # ... report total + timestamps ...

Inventory. “What types of files do I have?” is answered straight from the asset list, counted once per asset, with no sources, because no single fragment answers a library-wide question.

Step 8: Stream the answer, then lock it down

Streaming, because waiting in silence feels broken

The interface is a chat: FastAPI backend, Next.js frontend, answer streamed token-by-token. A chat that freezes for forty seconds and dumps a wall of text feels broken even when it’s working; a chat that types feels alive. Retrieval and deterministic routing happen first, then the LLM tokens flow as Server-Sent Events, then a final event carries the sources:

@app.post("/api/ask/stream")
def ask_stream(req: schemas.AskRequest) -> StreamingResponse:
    _require_live_backend()
    history = [{"role": m.role, "content": m.content} for m in req.history]

    def sse():
        for kind, data in get_rag().stream(req.question, history):
            if kind == "token":
                yield f"data: {json.dumps({'type': 'token', 'data': data})}\n\n"
            else:
                yield f"data: {json.dumps({'type': 'sources', 'data': serialize(data)})}\n\n"

    return StreamingResponse(sse(), media_type="text/event-stream",
                             headers={"Cache-Control": "no-cache", "X-Accel-Buffering": "no"})

One subtle production note. The Next.js dev proxy must point at 127.0.0.1, not localhost. Node resolves localhost to IPv6 first, the Python server binds IPv4 only, and your logs fill with connection refused, while the browser looks fine.

Guardrails: the system would be unsafe without them

Three guardrails earn their keep:

  1. A prompt-injection pre-filter runs on the query before any vector lookup, so a query trying to hijack the instructions never reaches the model.
  2. A description sanitiser scrubs what Gemma generates, because a video can contain adversarial on-screen text that the model would otherwise transcribe and later obey.
  3. An ingest semaphore serialises heavy jobs, so uploading three long videos queues them instead of thrashing the GPU.

Step 9: The long-video problem, and what actually fixed it

A fifty-seven-minute lecture took more than ten minutes to index. Unacceptable, and the profiler told a clear story in ten seconds. Keyframes were capped at twelve, so vision was cheap. Audio was the killer: thirty-second chunks over fifty-seven minutes is ~137 chunks, each a separate Gemma audio call, run one after another.

Two changes fixed it:

  1. Concurrency. Describe/transcribe calls now run through a thread pool; Ollama serves parallel requests for roughly 3× throughput.
  2. A dedicated speech model. Audio transcription has moved to faster-whisper, which transcribes in a single fast pass rather than one model call per chunk. In a real lecture, it ran at ~14× real time, so 57 minutes of audio finished in a few minutes. Because Whisper runs on the CPU, it overlaps with Gemma vision on the GPU.

The purity of “Gemma does everything” bent a little here, and that’s fine: a dedicated speech model is the right tool for an hour of audio. The Gemma audio path stays available behind a config flag (audio_backend: gemma) for anyone who wants it.

What I’d tell another engineer before they start

  • Pick your retrieval unit before anything else. Fragments versus assets is not a detail; it decides whether timestamps are free or impossible. In Qdrant, I got both in one collection.
  • Don’t assume a generative model gives you a metric space. It doesn’t. Describe, then embed the bridge.
  • Route the questions that have exact answers away from the LLM. Counting and inventory belong to plain code.
  • Measure before you optimize. I was certain the bottleneck was scene detection. It was audio, and the profiler said so in ten seconds.
  • Let your storage layer be the easy part. Qdrant’s embedded-to-server continuum, named vectors, native MaxSim, payload filtering, and quantisation meant the database was the one thing I never had to fight. Choose tools that let you keep your attention on the hard problem.

The whole thing runs on a laptop, indexes an hour of footage in a few minutes, answers in plain language, and lands you on the exact second. No cloud, no keys, no data leaving the machine. That was the entire point.

Clone it, point it at your own messy folder, and ask it something only you can ask.

GitHub

GitHub - sarveshtalele/deep-search-in-media-library-using-gemma-4-and-qdrant-multivectors: Cross-modal natural-language search over local video, audio & text - powered by Gemma 4 and Qdrant multivectors.


Originally published on Medium.

Share:

More articles

Back to Sarvesh's AI Newsletter
Search everything on the site