All articles

Search

Hybrid transcript search with SQLite

Find exact quotes and paraphrases in a recording with SQLite FTS5, local embeddings, and reciprocal rank fusion. Try the example and inspect the rankings.

An optical loupe magnifying one frame on a strip of film
In this article

Use SQLite FTS5 to find the words a speaker actually said, and an embedding index to find passages that express a similar idea. Give both indexes the same passage IDs so you can combine results and return to the right timestamp in the recording.

Index timecoded passages

Searching for “raised prices” and asking why a subscription got more expensive are two different jobs. The first needs an exact phrase under the tokenizer’s rules. The second could be answered by someone saying that the old fee didn’t cover costs, with none of the query’s key words. One transcript can support both.

Store passages with an ID, recording ID, speaker, start and end times, and text. For precise lookup, index individual sentences with FTS5. For a production semantic index, try passages that hold a whole turn or a few related sentences. Keep IDs for the underlying sentences so you can align the results. The example below uses the same five passages for both indexes to make the rankings easy to inspect.

Tie both indexes to the transcript revision. If a correction changes the transcript, refresh the affected text index entries and embeddings together. Return a timestamp and the original words with each result.

Worked example

We ran both searches on five fictional passages. Select the paraphrase to see exact phrase search return zero results and meaning search place the passage about subscription costs first at 23:16.

Compare the rankings

  1. 08:12The supplier raised prices twice before we changed packaging.
  2. 12:48We raised prices in May after switching to weekly deliveries.

Rankings from a local run on five fictional passages.

Switch back to “raised prices.” Both the supplier and the interviewee said those words. The meaning search ranks the interviewee first. Combining the two lists produces a tie between those passages, resolved in this example by passage ID. A speaker filter would help answer whose price changed.

To reproduce the example, use Python with SQLite FTS5, NumPy, ONNX Runtime, and Tokenizers. Pass a multilingual E5 small model directory with tokenizer.json and onnx/model_quantized.onnx. The script prints the fixture and all three rankings. Download the example script.

Combine ranks

The raw scores on the two lists live on different scales. Reciprocal rank fusion adds a contribution based on each passage’s position in each list. At rank r, that contribution is 1 / (k + r), with ranks starting at one and absent passages contributing zero. The original RRF study used k = 60. Treat candidate depth and k as settings to check on your own queries. Cormack, Clarke, and Büttcher, SIGIR 2009.

Python · Fuse ranked passage IDs
from collections import defaultdict

def fuse(*rankings, k=60):
    scores = defaultdict(float)
    for ranking in rankings:
        for rank, passage_id in enumerate(ranking, start=1):
            scores[passage_id] += 1 / (k + rank)
    return sorted(scores, key=lambda pid: (-scores[pid], pid))

Use exact phrase search when the reader explicitly requests a quote. Use the combined results for exploratory questions. Show the quote and its surrounding context so a reader can distinguish a relevant match from a plausible one.

Evaluate on real queries

The five-passage run illustrates the behavior of each method. To evaluate a larger index, collect queries that look like real editing work and label their expected timestamps before comparing methods.

  • Exact quotes and names. Include uncommon spellings and transcription errors. Check that literal search behaves predictably.
  • Paraphrases and follow-ups. Include answers given later in the recording, repeated phrases from different speakers, and questions with no answer.
  • Cost and quality. Record whether the correct span appears in the top results, how far down it lands, and how long lookup takes. Keep test queries separate from tuning queries.

ClipMill exposes timestamped recording search through its CLI and MCP server. This worked example uses rank fusion to show how the approaches interact. The ClipMill recording search guide shows how to query recordings in the app.

References