Title 01 · Aristotelian AI 02 · Retrieval 03 · Model Checking 04 · Distributed 05 · Temporal 06 · Heritage 07 · Conclusions
PhD Dissertation · Universitat Autònoma de Barcelona · June 5, 2026

Retrieving Document
Images Under
Domain-Specific
Constraints

With applications in the preservation and analysis of historical heritage.

Author
Adrià Molina Rodríguez
Directors
Ramos Terrades · Lladós Canet
Centre
CVC · UAB · Bellaterra
Explore
Chapter 1

The Aristotelian AI Problem

On the three-way tension between discourse, truth, and measure — and why historical documents fundamentally resist large-scale pretraining.

LLMs privilege what sounds persuasive over what is true. Retrieval systems offer evidence without articulating relationships. Evidence itself has been devalued in favour of discourse.
— Introduction, p. 2
The Oldest Quarrel — Plato, Protagoras, c. 380 BC

Persuasion vs. the short, answerable question

The tension this thesis confronts is twenty-four centuries old. In Plato's dialogue, the sophist Protagoras answers in makrologia — long, beautiful speeches that persuade without ever being pinned down. Socrates keeps interrupting to demand brachylogia: short answers, one question at a time, each one checkable. Toggle the two modes and watch what happens to persuasion versus knowledge actually established.

PERSUASION—
KNOWLEDGE ESTABLISHED—

Rhetoric maximises persuasion while establishing almost nothing; dialectic trades eloquence for things you can actually check. The modern chatbot is Protagoras with a server farm.

How We Got to the Triangle — a lineage of the three forces

From the agora to the search bar

Each era leaned on a different corner of the same triangle. Click along the timeline: the sophists sold discourse; dialectic and, later, the scientific record chased truth; the index, the archive, and the search engine industrialised measure; the LLM looped back to discourse at planetary scale. The thesis asks for all three at once.

The Triadic Tension — since Socrates & Protagoras

Discourse, Truth, Measure

Two and a half millennia after Socrates asked the sophist Protagoras for brachylogia — short, specific answers instead of persuasive rhetoric — we have not escaped the same three-way pull. Drag the marker: every information technology sits somewhere inside this triangle. The chatbot leans into discourse; the classic search engine offers measure without relation; the thesis asks whether a system can hold all three at once.

Drag the marker — read where each system falls
An ideal Aristotelian search engine lives near the centre: grounded in measure, honest about truth, fluent enough to relate evidence.
ChatGPT / LLM Classic search engine Printed encyclopedia Aristotelian AI (goal)
The Suppression of Doubt — Fig. 1.1, p. 3

Why the chatbot feels more certain

A search engine leaves you certain that you did not read the thousands of pages it indexed — your doubt stays visible. A conversational model hides its sources behind a single comforting answer; keep asking and your perceived uncertainty falls asymptotically toward zero. Press "Ask again" on each side and watch the doubt behave very differently.

◷ Retrieval system
10,000 sources, visible
perceived doubt86%
Each search reveals more you haven't read. Doubt stays honest.
✦ Conversational model
Sources suppressed
perceived doubt50%
Each answer feels more complete. Doubt is omitted, not resolved.

The "omission bias" of a sophistic AI: it is comforting precisely because it never shows you the long tail of what it left out.

The Blanket of Truth — Introduction, p. 5

A historical truth is only as precise as the sources retrieved

As John Keating put it, truth is like a blanket that always leaves your feet cold — you tug it up to your chin and your feet stick out; pull it down and you shiver at the neck. The blanket of evidence is finite: cover one part of an event and another slips back into the cold. Grab the quilt and drag it over the sleeping figure of "the past" — try to cover all of it at once.

Drag the blanket · double-click to reset
Grab the quilt and pull — covering the head uncovers the feet. The fabric is finite, like the evidence.
Documents May Desire — Fig. 1.2, p. 5

Two depictions of the same expansion

The same westward expansion, painted twice. John Gast's American Progress (1872) bathes it in the light of Manifest Destiny; Robert Lindneux's Trail of Tears (1942) shows a people displaced. With only one source as context, the map of history is distorted. Toggle the second source and watch the reconstructed "map of events" correct itself — drawing the map of history is choosing which truths to sample.

SOURCE A · 1872
American Progress
American Progress — John Gast, 1872 (public domain)
Native Americans obscured by an advancing light.
● included
SOURCE B · 1942
Trail of Tears
The Trail of Tears — Robert Lindneux, 1942 (Woolaroc Museum)
R. Lindneux, 1942 · Woolaroc Museum
A multitude marching in melancholy.
○ click to retrieve
RECONSTRUCTED MAP OF EVENTS
With only the triumphal source, the displacement of a whole people is invisible. The map is a landscape of a single partial truth.

What makes a document "historical"? — drag the slider

Document Value Over Time
Drag the time slider inside the chart to explore how a document transitions from primary value to evidential value
A Vessel of Information — Fig. 1.3, p. 8

The anatomy of a document

A document is a record of human activity fixed on a durable medium. The Manual of Archival Science separates it into three layers: the material support that gives it physical body, the record that captures information onto that support, and the information itself — the shapes, words, and people confined within. Hover each layer, then explode the stack to see them apart.

Layer 01 · Material support
The substrate
Papyrus, magnetic film, a sheet of copper — the raw physical body, prior to any acquisition.
Layer 02 · Record
The means of capture
The ink on paper, the light fixed in a photograph, the hammer-strike imprinting a pattern.
Layer 03 · Information
The witness
The signature, the people in the frame, the inscription — the testimony of human activity itself.

In this thesis, both photographs and textual documents count as documents — as long as the context of application is archival.

Three constraints that block standard pretraining — click each

🌍
01
Visual Diversity
✍️
02
Annotation Cost
🔒
03
Data Governance
CLICK A CONSTRAINT ABOVE
The three fundamental reasons why no single foundational model exists for historical document analysis — unlike CLIP, GPT, or DINO which benefit from massive, centralised, freely available data.

Four Research Questions

RQ1 · Controllability
Can a retrieval system be simultaneously grounded, measurable, and comprehensive with respect to a historical collection?
RQ2 · Foundation
Can distributed learning bypass centralisation constraints to act as a proxy for a foundational model?
RQ3 · Temporal Proxy
Is temporal information a proxy for a document's primary value — and can it anchor retrieval queries?
RQ4 · Neural Coherence
Are neural representations temporally coherent? Can a single model encode both semantic category and historical period?

Thesis Structure

03
Controllability & Symbolic Retrieval
Model-checking visual routines + agentic GraphRAG for noisy historical graphs → RQ1
→
04
Model Editing & Distributed Learning
Federated task arithmetic for under-represented scripts and privacy-sensitive archives → RQ2
→
05
Temporally Decomposable Representations
Orthogonal category/year subspaces for composed historical image retrieval → RQ3 & RQ4
→
06
Heritage Applications
Epidemic legislation analysis + Photo-BALL photographic census database
→
Chapter 2

Document, Image &
Information Retrieval

Retrieval is the task of identifying relevant information in a corpus, conditioned on a signal. Before the contributions, the shared vocabulary: queries, ranking, and the long tail that breaks conversational shortcuts.

Conditioning a Corpus — Ch. 2, p. 17

A signal pulls relevance out of a collection

Every retrieval system maps a query-signal onto a ranking of documents. Type a query, or pick one, and watch the corpus reorganise: relevant items rise, the threshold τ draws a line, and the long tail of almost-relevant material trails off below it — the very tail a chatbot quietly hides.

Bars above τ are retrieved. The shaded tail below is what a comprehensive system must still acknowledge as possibly relevant.
Precision & Recall — the eternal trade-off

The two ways to be wrong

Move the threshold above and the two classic measures pull against each other. A loose threshold retrieves everything — high recall, low precision. A strict one is pure but blind to the tail. The thesis argues a historical engine must, above all, acknowledge the absence of false negatives — knowing what it failed to find.

—
Precision
—
Recall
—
F1
—
Missed (FN)
Retrieval-augmented chatbots cannot count relationships, constrain literals and ranges, or acknowledge the false negatives they never retrieved — they have no measure of what they should have found.
— motivation for RQ1
Chapter 3 · RQ1

Controllability & Symbolic Retrieval

What if instead of asking "how similar?" we asked "does this satisfy these logical conditions?" A formal model-checking framework applied to visual search.

Click each stage of the pipeline

📝
Query
Natural language
🔗
Parse
SPO triplets
⚙️
Synthesise
Visual routines
✅
Verify
Execute on images
📊
Rank
Partial truth score
Query Stage
A natural language query arrives: "A desk with two computer monitors, two mice, a cup and a keyboard on it."
This is the system specification — exactly like a formal requirement in software model-checking. The retrieval goal is to find images that logically satisfy this specification, not merely images that look vaguely similar.
A Visual Routine, Executed — Figs. 3.8–3.11

Checking a claim against an image, line by line

The query (man, riding, horse) compiles to a small program — a visual grammar. Instead of asking "how similar?", the routine executes: it locates objects, tests spatial predicates, and where the world contradicts the specification it records doubt rather than forcing a match. Step through the routine, or press play.

01
Parse
02
Detect
03
Spatial
04
Relate
05
Score

Doubt is a feature: a partial match is ranked, not discarded — and the system can state exactly which predicate failed.

Live Retrieval Space — click to place a query, scroll wheel changes threshold τ

Click to move the query point q*. Each dot is a document; colour shows verification status. Scroll to adjust the retrieval threshold τ.

Model Checking — match the query graph against a candidate image

Query: "A desk with two monitors, two mice, a cup and a keyboard."
QUERY GRAPH (specification)
CANDIDATE IMAGE + DETECTIONS
TRUTH SCORE
—
VERDICT — the system states why
ReRankScore = (K − i) × (verified / total) — partial matches are ranked, never silently dropped.

GraphRAG on Noisy Historical Records

The second contribution uses word spotting to make Cypher graph queries robust against HTR errors. When a model reads Savadell instead of Sabadell, exact matching fails completely — word spotting expands literals to clusters of near-spellings.

Type a place or name — watch HTR corrupt it, then word spotting recover it
try: Sabadell · Bartomeu · Terrassa
① TRUE LITERAL
Sabadell
② HTR READS
③ WORD-SPOTTING CLUSTER
Graph Inference, End to End — Fig. 3.14

From a sentence to a verified answer over a noisy graph

A request becomes a Cypher query over a genealogical graph built from handwritten parish records. The model decides which literals are too fragile for exact matching — names and places mangled by HTR — and wraps those in a word-spotting expansion, so the query runs over the expanded graph without losing its grounding. Step through it.

Request: "Find me a carpenter who married a fisherman in the city of Sabadell."
01
Request
02
Cypher
03
Expand
04
Infer
05
Execute

"Pepa Bueno" is retrieved even though her town was transcribed "Sebadell" — exact matching would have returned nothing.

The PHOC Fingerprint — Pyramidal Histogram of Characters

How a word becomes a position-aware fingerprint

Word spotting compares words by a descriptor, not by their literal characters. The PHOC records which letters occur and, recursively, where — the whole word, then halves, then thirds. Two OCR variants of the same word land close together in this space. Type a word and watch its pyramid build.

try: justicia · sanidad · colera
Level 1 sees the whole word; deeper levels split it, so two words that share letters but not order are pulled apart.
HTR Accuracy Slider — watch retrieval recall change
Recall improves dramatically with word spotting, especially at lower HTR accuracy levels

COCO Benchmark — Recall Results

MethodEasy Rec@10Hard Rec@10Zero-Shot
CLIP ViT-B.892.565✓ yes
CLIP ViT-H.973.674✓ yes
SigLIP 400M.892.696✓ yes
BEIT-3 (fine-tuned).973.870✗ no
Ours (base).784.739✓ yes
Ours + BEIT-3.980.913✗ no

On the Hard split — compositionality, counting, text recognition — the model-checking approach shows its clearest advantage over pure embedding methods.

Chapter 4 · RQ2

Model Editing & Distributed Learning

When data cannot be centralised — because of privacy, governance, or cultural heritage law — can federated model averaging still create a generalist foundation?

Federation Simulation — click an archive to train it, then click "Aggregate"

Click any archive node to train it locally. When enough are trained, click the central CVC node to aggregate weights.

Task Arithmetic — drag models to compose weights

Drag the model nodes to see how weight averaging creates a generalist model. The merged model outperforms any individual expert on out-of-distribution data.

Accuracy on Unseen Scripts — Centralised vs Distributed

Centralised Distributed (ours)
The Borg Cipher — 0% → 50.5% accuracy

Decoding what no single archive could

The 18th-century Borg cipher defeats a centrally pretrained model entirely — 0% character accuracy, because no training corpus ever contained its invented glyphs. Add federated experts: each archive contributes a sliver of weight, and the merged model begins to read symbols none of them individually knew. Drag to recruit archives and watch the ciphertext resolve.

char accuracy 0.0%
27
Datasets
0→50%
Borg Cipher
×1.62
Best Gain
3
Task Types
Chapter 5 · RQ3 & RQ4

Temporally Decomposable
Image Representations

Separating what an object is from when it existed — and using that orthogonal decomposition to compose entirely novel retrieval queries.

Three Composed Retrieval Modes — click to explore

🏷️ + 📅
MODE A
Label + Label
"Cars from 1956"
🖼️ + 📅
MODE B
Image + Label
"This jacket in 1989"
🖼️ + 🖼️
MODE C
Image + Image
"Cars contemporary to this photo"
SELECT A MODE
Click a mode above to see the vector arithmetic and what it enables.
The Swapping Trick — Figs. 5.3–5.4, p. 118

Separate what from when — then transplant time

A single embedding tangles an object's category with its era. The training pipeline pulls them apart: a proxy loss builds year-agnostic category clusters, subtracting the category mean µᶜ centres every cluster into one shared temporal subspace, and the leftover residual is the era itself. The swapping trick then translates that residual onto another object — letting you ask "this jacket, as it would look in 1950," a query no label could phrase. Step through the decomposition.

a
Entangled
b
Subtract µᶜ
c
Residual = era
d
Transplant

Because the two subspaces are orthogonal by construction, a 1940 car and a 1990 car stay semantically linked — proven via mutual information, not merely hoped for.

Embedding Space — compose a query interactively

The embedding space shows category clusters (horizontal) and year structure (vertical). The query vector q = µᶜ + µʸ is shown in gold.

Date Precision@10 — TDIR vs CLIP

MethodLabel+LabelImage+LabelImage+Image
CLIP Arithmetic.115.076.102
CLIP Prompting.105.079.081
ConvNeXt + TDIR.824.664.393
ViT + TDIR.863.708.429

CLIP's temporal signal is present but not compositionally accessible. TDIR is over 8× more precise in date retrieval because the orthogonal decomposition is learned explicitly.

Chapter 6

Computer-Vision Aided Heritage Databases

Two case studies: legislative responses to 19th-century epidemics, and the invisible female labour force revealed through historical photography.

Photo-BALL Database (1870–2020) — click a decade

Click any decade to explore the photographic evidence of that period. The database detects age, gender, date, and occupation from historical photographs.
The Invisible Workforce — Photo-BALL, an illustrative reading

Developing the people the tallies left in totals

Aggregate occupational statistics describe people in coarse sums; a photograph shows individuals. Photo-BALL detects and counts the subjects of a large dated image collection, so the visual record can surface a presence that summary tables flatten. Drag to "develop" this illustrative factory floor: as the print emerges, detections tag each worker, and the women a headline total would fold away glow gold.

Official census counts: — women Photo-BALL detects: — women

Photo-BALL ran 7.2M object detections across 1M+ dated images — the scale at which dispersed photographs become a quantifiable, queryable record. (Figures above are illustrative of the method.)

Subjects Detected Over Time — an illustrative reading of the visual record

Click a decade above. These curves illustrate how counting detected subjects across a dated photo collection can surface demographic signals directly from images. Figures are illustrative of the method.

Epidemic Legislation Analysis

Word spotting on two centuries of Spanish official journals reveals how epidemic cycles — yellow fever, the 1820 plague in Mallorca, the great cholera waves of 1833–1885, and the 1918 influenza — drove the construction of the modern liberal state. Legislative language around sanidad, cuarentena, cordón sanitario spikes precisely at epidemic inflection points.

Legislative frequency of public-health terms over epidemic cycles. Click a spike to read the legislative context.
The EPI-Database — 700,000 pages of the Gaceta de Madrid

Which words trend with an epidemic?

Word spotting traced ~1.2 billion word instances across two centuries of Spanish official journals. To find vocabulary genuinely tied to cholera, each candidate word's yearly frequency is compared against the anchor "cólera" by histogram intersection — a score from 0 (never co-occurs) to 1 (perfectly in step). Pick a candidate and watch the two curves overlap.

A Contagion, Tracked in Print — Fig. CHRONO1, cholera 1817–1834

India → Europe → Spain, fifteen years in the gazette

By measuring the log Z-score — the spike in mentions of a place above its own historical baseline — the gazette reveals how Spain learned of cholera long before it arrived. The disease is reported in India in 1818, becomes a European preoccupation by 1830, and reaches the peninsula in 1833. Step through the three stages and read what the administration knew.

1818
India
1830
Europe
1833
Spain
From Description to Prescription — Fig. 5, state-building

Each epidemic left the state more legislative

Categorising two centuries of language as description (narrating the outbreak) versus measure (prescribing action) reveals the modern liberal state being built one crisis at a time. Scrub through the years: during an outbreak description spikes, but the baseline share of prescriptive "measure" language ratchets up and never fully recedes.

Green = measure (prescriptive) · sand = description. The dashed line is the secular trend toward prescription.
700k
Gaceta Pages
1.2B
Word Instances
~3wk
Recognise→Act Lag
×3.4
Cholera Descr. Odds
1M+
Images (DEW)
7.2M
Object Detections
586
Object Categories
150yr
Photo-BALL Span
Chapter 7

Conclusions

Four research questions, four answers. A technical framework for Aristotelian AI in historical document retrieval.

RQ1 → ANSWERED
Grounded & Measurable
Model-checking with visual routines provides traceable, verifiable retrieval. Each result is anchored to logical predicates — not opaque similarity scores. The system can explicitly state why an image was rejected.
RQ2 → ANSWERED
A Distributed Foundation
Task Arithmetic / FedAvg consistently outperforms centralised pretraining in low-resource and out-of-distribution regimes. The Borg cipher goes from 0% to 50.5% accuracy. Data never leaves its archive.
RQ3 → ANSWERED
Date as Archival Proxy
TDIR enables date-sensitive composed queries that mirror archivist reasoning. An 8× improvement over CLIP in date precision confirms that temporal structure must be explicitly learned, not hoped for.
RQ4 → ANSWERED
Temporally Coherent Embeddings
The swapping trick enforces orthogonal category/year subspaces as an emergent property of joint optimisation — formally proven via mutual information. Cars from 1940 and 1990 stay semantically linked.

The ideal search engine for historical archives is not a text generator. It is a measurable, relational, comprehensive system — one that counts relationships, constrains literals, acknowledges the absence of false negatives, and preserves the doubt that makes historical inquiry honest.

"Allò que val és la consciència de no ser res si no s'és poble"
Vicent Andrés Estellés (1924–1993) — opening epigraph of this thesis