Skip to content

Free tags experiment ​

INFO

This page records measurements. It is not required reading: you can use the package without it.

This procedure measures whether the metainformation that every knowledge base already has improves retrieval: the title of a page, the chain of headings of a section, the path of a file, and the front matter that people wrote. No language model writes these tags and none runs at indexing time. The result decides whether duckdb-vectors projects some of them by default, so that a new user gets part of the gain of tagged retrieval with no configuration.

It is also the record of the evaluation: the preconditions, the pre-registered rule, the commands, and the results as they come in. The measure builds on the tag measurement of the evaluation procedure and uses its scripts.

What are the tags and the conditions? ​

The chunkers add three reserved keys to the metadata of each chunk, so a tag field can project them. The user guide gives their fallback order.

KeyValue
document.titleFront matter title, else the first H1, else the file name without extension
document.pathPath relative to the indexed folder, without extension
section.headingsText of the headings of the section, from H1 down, joined with >

Each condition adds a set of tags to the embedded text and to the keyword index (the both placement of evaluate-retrieval).

ConditionTags
Bnone, the baseline
Tdocument.title
Hsection.headings
Pdocument.path
THtitle and headings
Fthe page-level front matter keys of the corpus
THFtitle, headings and F
Csection tags written by a model, measured before, for reference
THCtitle, headings and C

F is defined by one rule, so that it cannot be tuned: every page-level key of the front matter or sidematter of the corpus, except sections. That gives repo, directory, extension and path for the code set, collection and document for LegalBench-RAG, company, doc_type, period and sector for FinanceBench, and topic for the engineering pages.

What do you need? ​

  • pip install duckdb-vectors, and no AWS account: this evaluation calls no model. The analysis script scripts/benchmark_kb_analyze.py needs a clone of this repository.
  • The four corpora prepared as pages under tmp/kb/<corpus>/pages, each with a manifest tmp/kb/<corpus>/.duckdb-vectors.yaml that sets pages: pages and work: ., with their section tags (condition C) and their validation set tmp/kb/<corpus>/validation.json, as in the reproduction procedure. The engineering pages are private, so their figures cannot be checked by anyone else.
  • The frozen splits of the earlier measurement, identified by their digests: code set da768fde2106de04, LegalBench-RAG 3a12ea0599e4425b, FinanceBench a67fb18cc0c6ca02, engineering pages b0389e706464bead. A run that reports another digest is not comparable.
  • The three embedding models through fastembed, downloaded once: minishlab/potion-multilingual-128M (potion-256, the default), sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 (MiniLM-384) and BAAI/bge-small-en-v1.5 (bge-small-384).
  • A committed working tree for the test run. Each result file records the git SHA and whether the tree was dirty, so a test run on a dirty tree is not accepted.
  • A quiet machine for the timing step. Other processes change the time to embed.
  • Time. The MiniLM and bge runs on FinanceBench (27,922 chunks, nine conditions) take hours on a MacBook Pro M1.

What is registered before the test? ​

The conditions, the corpora, the metric and the decision rule are written in a comment of the issue before any test split is scored with the new conditions. The comment is the pre-registration; this section restates it.

  • Metric: Pass@20 in hybrid search, on the primary stratum of each corpus (contextual where it exists, otherwise all queries), compared with B by a paired bootstrap interval of 95% and a sign-flip p-value.
  • One Holm correction over every test of the evaluation: each corpus, model and condition.
  • A gain counts when Holm rejects and the interval is above zero. A loss counts when Holm rejects and the interval is below zero.
  • A tag set becomes a default when, on the test splits, its gain counts on at least three of the four corpora with at least two of the three models, no corpus and no model shows a counted loss, and the time to embed with potion-256 grows by less than 20% against B on every corpus.
  • Otherwise no default changes, and the results are guidance.
  • The test splits were scored once with the earlier conditions. Scoring them again is acceptable because no choice of this evaluation is tuned on them: every choice is made on the development split.

Step 1: explore on the development splits ​

Run every condition on the development split of each corpus and model. --index-dir keeps one index per model and condition, named <model>-<condition>.duckdb. The questions of the dev and test splits differ, but the chunks do not, so a later run on the other split finds every etag in the kept indexes and embeds nothing. The same holds after a failed run: the next run embeds only what is missing. --free-tags adds the conditions T, H, P, TH, and THF and THC from the sets named F and C.

shell
$ duckdb-vectors --manifest tmp/kb/legalbench evaluate-retrieval \
    --embeddings local:minishlab/potion-multilingual-128M --split dev \
    --free-tags --placements both --index-dir tmp/kb/legalbench/index \
    --tags 'F=collection: $.collection;document: $.document' \
    --tags 'C=context: $.retrieval.context' \
    --results tmp/kb/legalbench/results/free-dev-potion.json

The script tmp/run-free-tags.sh dev runs the four corpora with the three models. Print the tables with the analysis script, on development files only:

shell
$ .venv/bin/python -m scripts.benchmark_kb_analyze tmp/kb/*/results/free-dev-*.json \
    --conditions T:both H:both P:both TH:both F:both THF:both C:both THC:both

Nothing in the conditions or in the rule changes because of what this step shows.

Step 2: time the embedding ​

Time to embed is not read from the evaluation runs: the runs share a caching embedder between conditions, which hides the cost of longer texts. With --time-embedding, the script embeds the texts of each condition again with the wrapped model, with no cache, and keeps the best of three runs. Run it with potion-256 on each corpus and with nothing else busy on the machine.

shell
$ duckdb-vectors --manifest tmp/kb/legalbench evaluate-retrieval \
    --embeddings local:minishlab/potion-multilingual-128M --split test \
    --free-tags --placements both --time-embedding \
    --index-dir tmp/kb/legalbench/index \
    --tags 'F=collection: $.collection;document: $.document' \
    --tags 'C=context: $.retrieval.context' \
    --results tmp/kb/legalbench/results/free-test-potion.json

This command is also the test run of potion-256 in step 3, so the timing and the score come from one file.

Step 3: score the test splits once ​

On a committed tree, run the command of step 2 for potion-256, and the same command without --time-embedding and with --embeddings set to MiniLM and bge, for each corpus. Name the files free-test-<model>.json. Run each test once. If a run fails, fix the cause and run it again with the same --index-dir; the result file of a failed run is not kept.

Step 4: apply the decision rule ​

shell
$ .venv/bin/python -m scripts.benchmark_kb_analyze tmp/kb/*/results/free-test-*.json \
    --conditions T:both H:both P:both TH:both F:both THF:both C:both THC:both

The script prints a table per corpus, then one line per condition: default or no default, the number of models with a gain, the number of counted losses, and the growth of the time to embed. Change the default of tag_fields in src/duckdb_vectors/config.py only for a condition that says default.

Where do the numbers come from? ​

  • Code: the commit of each row of the run log, with src/duckdb_vectors/evaluation/ and scripts/benchmark_kb_analyze.py.
  • Data and splits: the corpora and digests of the reproduction procedure.
  • The method and the pre-registration are recorded in the issue that tracks this evaluation.

Next steps ​