Retrieval for Digitized Medieval Manuscripts: Ontology, Hybrid Search, and Long-Tail Governance

    This article tackles a practical problem that libraries, museums, and publishers face when digitizing historical images: why search systems fail to find illustrations like the "Snail House," a medieval miniature of a woman living inside a giant snail shell. It argues that the root cause is rarely a lack of compute or model scale, but rather data that lacks a machine-understandable structure at the source. It then lays out a system-level approach spanning four-layer ontology design, controlled vocabularies, annotation standards, multi-route hybrid retrieval with reciprocal rank fusion, active learning for long-tail coverage, traceability-constrained question answering, and layered evaluation. Readers will find concrete design principles, reference code, and pitfalls to avoid when making atypical historical image material discoverable, interpretable, and trustworthy.

    Introduction: Why the “Snail House” Cannot Be Found

    In the early 14th century, a Benedictine monk compiled classical knowledge into an encyclopedic work of moral interpretation. About half a century later, a court illuminator sketched 56 miniatures for a Middle French translation of it. These miniatures show women in typical headdresses and veils, spinning wool at their doorways and chatting with neighbors, alongside elephant tamers, headless men, Amazon queens, and monsters that spew boiling water.

    One miniature is especially unusual: the heroine’s daily scene is so mundane as to be almost trivial, yet she lives inside a giant snail shell, on an island named “Traponé,” said to lie “near India.” Within her world, real customs, ancient legends, and absurd wonders sit side by side. This way of writing is not rare in the medieval natural-history tradition, but for today’s digital systems it is thoroughly atypical material. The “bog corpse,” the “mechanical fly,” and the “Snail House” can be regarded as three extreme samples of this kind of content.

    Today, images like these enter the digitization platforms of libraries, museums, and publishing houses at a rate of tens of thousands per day. Engineers then run into a concrete problem: when a user types “a house in a snail shell” or “a corpse in a bog,” why can’t the system find that miniature?

    The answer is usually not a shortage of compute or model scale, but data that lacks a machine-understandable structure from the very source. Treating this kind of historical image material, this article presents a system-level method that spans ontology modeling and long-tail mining, hybrid retrieval and answer traceability.

    Problem Analysis: Three Retrieval Dilemmas for Historical Images

    Keyword Distortion: The Index Matches the Literal, Not the Semantic

    Traditional full-text retrieval relies on titles, subject terms, and classification numbers generated by human catalogers. Faced with the “Snail House,” a cataloger typically follows the institution’s existing scheme:

    • The main subject is classified under “snail,” and snails belong to the zoology category;
    • The function of the snail shell as a dwelling is discarded for lack of a corresponding subject term;
    • A fictional place name like “Traponé” very likely has no entry that maps to it at all.

    As a result, users cannot find it under architecture searches, and under the zoology category there is too much noise.

    Semantic Drift: General-Purpose Models Do Not Recognize Medieval Images

    Image vectors taken directly from a general-purpose model are built on contemporary web image-text data. These models have rarely seen parchment backgrounds, gold-leaf decoration, flat color blocks, or stylized figures. This produces two typical errors:

    • Mistaking a snail shell for a seashell, a spiral ornament, or an ordinary mollusk;
    • Reading a human figure in a bog as a battlefield, a patch of mud, or a person simply lying down.

    In addition, medieval images follow stylized conventions—expressing identity or virtue through specific postures and attributes. This iconographic layer of meaning cannot be learned by a general-purpose visual model.

    Annotation Gaps and Semantic Ambiguity

    A subject like the bog corpse is inherently intense in sensory terms, and on some public-facing platforms it triggers content moderation. If moderation rules are mixed with academic cataloging logic, these images are systematically blocked or down-weighted, and the relevant entries never accumulate annotation data.

    Meanwhile, this material is semantically open in its original context: the same figure interests art historians for its iconographic sources, archaeologists for peat-bog preservation conditions, and general readers who simply want “to see something curious.” If only a single flat set of labels is maintained, it will inevitably fail to satisfy any of these audiences.

    The Underlying Solution: A Knowledge Skeleton Built from Ontology and Controlled Vocabularies

    The ceiling on retrieval quality is set by data modeling, not by ranking algorithms.

    A Four-Layer Ontology: Breaking a Miniature into Retrievable Dimensions

    Layer Core question Example dimensions Main source
    Theme What motif is depicted Fictional peoples, strange creatures, moral allegories, exotic customs Catalogers, domain experts
    Object What is in the scene People, animals, buildings, artifacts, tools Visual detection + manual proofreading
    Visual What it looks like Carrier type, technique, color tone, composition features Image feature extraction
    Context Where it comes from, what it relates to Parent work, author, date, patron, related images in the same book Metadata and knowledge graph

    Ontology design must follow three principles:

    1. Concept uniqueness: each concept appears only once, avoiding synonym nodes that split recall;
    2. Controlled depth: keep it generally within 4–5 levels; going deeper causes annotation fatigue and sparse nodes;
    3. Extensibility: reserve extension fields so newly discovered figure types can be added without changing the table schema.

    Controlled Vocabulary: Solving the “Snail House” Problem

    A controlled vocabulary maintains three kinds of relations between standard concepts: equivalence, hierarchy, and association. It maps a user’s colloquial phrasing to a canonical concept, then maps the canonical concept to collection data.

    • Equivalence terms: “snail-shell house,” “snail-shell dwelling,” “the person living in a snail shell” → canonical term “figure dwelling in a mollusk shell”;
    • Hierarchical terms: broader term “dwelling forms,” narrower term “natural shell-type dwellings”;
    • Associative terms: linked to the same-book image “the elephant tamer,” with the relation attribute “belongs to the strange motifs in the same Natural History compilation.”

    Original-language spellings of names and titles may be retained as annotations but are kept out of the main retrieval index. When a user searches “mechanical fly,” the system can also classify it under the broader concept “automata and bionic creations,” incidentally recalling kindred images such as the mechanical lion and the mechanical bird.

    Annotation Standards: Making the “Snail House” Annotatable

    1. {
    2. "image_id": "ms-0001-f12r",
    3. "work": "medieval_natural_history_compilation",
    4. "concept_id": "C-0231",
    5. "concept_label": "figure dwelling in a mollusk shell",
    6. "objects": [
    7. {"type": "human", "role": "spinner", "count": 1},
    8. {"type": "mollusk_shell", "function": "dwelling", "count": 1}
    9. ],
    10. "attributes": {"material": "pigment_on_parchment", "palette": "warm"},
    11. "confidence": 0.92,
    12. "annotators": ["A07", "A12"],
    13. "agreement": 0.88
    14. }

    The accompanying annotation guide should cover three points:

    • Granularity: entities should be described down to “independently describable objects,” not pixel-level regions;
    • Boundaries: rules for judging artistic convention versus real artifacts, such as how to decide when a snail shell is both an animal attribute and a building function;
    • Grading: allow annotators to output a confidence level and notes on uncertainty. Ambiguous samples are handed to a senior expert for arbitration rather than forced into a binary choice.

    Multi-Granularity Indexing: Automatic Propagation of Synonyms and Parent-Child Concepts

    If the controlled vocabulary in Section 3.2 is built as a graph, its three edge types—equivalence, hierarchy, and association—can be converted directly into query-expansion rules at retrieval time. A typical expansion chain looks like this:

    • A user query “snail-shell house” is first mapped through the equivalence relation to canonical concept C-0231;
    • It then spreads along hierarchical edges to the broader concept “dwelling forms” and pulls down its narrower concept “natural shell-type dwellings”;
    • When documents match, the system traces back along their theme tags to recall related same-book images such as “the elephant tamer” and “the monster that spews boiling water”;
    • Expansion depth (generally 1–2 levels) is controlled and expansion-term weights are decayed to prevent recall inflation from introducing too much noise.

    Retrieval Architecture: Multi-Route Recall and Fusion Reranking

    Why a Single Path Is Not Enough

    • Pure keyword search is precise and explainable, but depends on the user’s wording matching the cataloging wording, and is helpless against colloquial descriptions;
    • Pure vector search generalizes well and handles descriptive queries like “the woman living in a snail shell,” but is prone to semantic drift, and long-tail concepts often have vectors that sit close to high-frequency neighbors;
    • Pure structured filtering is exact, but users usually do not know which fields are available to filter on.

    Production systems need to combine them.

    Four Parallel Recall Routes

    1. Structured recall: precise conditions such as date, region, work, and carrier type filter records directly;
    2. Sparse retrieval: build an inverted index over titles, cataloging terms, and expert-written iconographic descriptions, weighted with term frequency–inverse document frequency;
    3. Dense vector recall: compute vectors for the text query and for the images and image captions, then perform approximate nearest-neighbor search within the same semantic space;
    4. Cross-modal recall: use an image-text matching model to score each “query–image” pair, complementing the first three routes.

    Results from all routes are aligned under one numbering scheme, then ranked together by the fusion layer.

    Fusion Ranking: Reciprocal Rank Fusion

    Scores from different routes vary widely in scale and distribution, so a direct weighted sum is unreliable. In engineering, reciprocal rank fusion is common: it uses only rank position and ignores raw scores.

    1. def rrf_fuse(rank_lists, k=60, weights=None):
    2. """Fuse multi-route recall results by reciprocal rank.
    3. rank_lists: [[doc_id, ...], ...], where each sublist is the ranked
    4. result of one recall route
    5. weights: weight for each route; None means equal weights
    6. Returns: [(doc_id, fused_score), ...], sorted by score descending
    7. """
    8. if weights is None:
    9. weights = [1.0] * len(rank_lists)
    10. scores = {}
    11. for ranks, w in zip(rank_lists, weights):
    12. for rank, doc_id in enumerate(ranks, start=1):
    13. scores[doc_id] = scores.get(doc_id, 0.0) + w / (k + rank)
    14. return sorted(scores.items(), key=lambda x: x[1], reverse=True)

    For example:

    • Document A ranks 1st in the keyword route and 100th in the vector route;
    • Document B ranks 10th in both routes;
    • With k=60, A scores 1/61 + 1/160 ≈ 0.0227, while B scores 2/70 ≈ 0.0286.

    As shown, fusion suppresses results that survive on a single lucky route and favors documents endorsed consistently across multiple routes. For material like the Snail House, expert-maintained canonical descriptions keep it stably near the top in sparse retrieval, and after fusion it is less easily drowned out by the large number of visually similar ordinary images. The per-route weights and the parameter k should be determined through the layered evaluation in Section 4.4.

    After Fusion: Reranking and Query Understanding

    Fusion yields a candidate set, but the user sees a final ranking, and two more layers are needed in between.

    Query understanding: identify constraints such as date, subject, and carrier in the query, and split it into a “structured condition + semantic query” pair.

    Reranking: perform fine-grained matching over roughly 50–200 candidates. Fine-grained relevance between text (iconographic descriptions, expert notes) and images can be assessed with a cross-encoder image-text matching model. Multi-objective ranking must also balance relevance, source authority, and diversity to avoid similar scenes from the same work filling an entire page of results.

    Fallback Strategy: What to Do When Image-Text Data Is Incomplete

    Historical images are often “image without text,” with uneven scan quality. A graded degradation strategy can be designed:

    Data state Available features Retrieval strategy
    Image + complete cataloging All Four-route recall + fusion reranking
    Image + basic metadata Metadata + image vectors Structured recall + vector recall
    Only a low-quality thumbnail Image vectors Metadata recall as the main route, vector recall down-weighted
    Not yet cataloged None Enter the processing queue; model pre-annotation followed by manual review

    Note: general cloud services for content understanding and vector retrieval (for example, those offered by Baidu AI Cloud) can serve as one underlying option for the capabilities above. But whichever approach is chosen, ontology design, annotation standards, and the evaluation framework must be controlled by the institution itself. These are the real determinants of retrieval quality and cannot be outsourced.

    Long-Tail Governance: Continuously Teaching the Model the “Snail House”

    Three Sources of the Long Tail

    1. Sample long tail: the “Snail House” may have only single-digit occurrences across the whole collection;
    2. Concept long tail: many concepts barely appear in a general model’s pretraining;
    3. Semantic long tail: the same figure is called different things by different researchers.

    These three sources mean that governance cannot rely on annotation alone, but on the coordinated “annotation + vocabulary + active learning.”

    Active Learning: Covering the Most Long Tail with the Least Annotation

    For sparse concepts like the “Snail House,” random sampling will very likely miss the entire batch. A more effective approach builds a coverage objective over the remaining sample pool: prioritize images that fill a gap in already-annotated category coverage, or that are visually very different from samples already selected.

    1. def cosine(a, b):
    2. dot = sum(x * y for x, y in zip(a, b))
    3. na = sum(x * x for x in a) ** 0.5
    4. nb = sum(x * x for x in b) ** 0.5
    5. return dot / (na * nb) if na and nb else 0.0
    6. def covered_concepts(annotated):
    7. """Set of ontology concepts covered by already-annotated samples."""
    8. covered = set()
    9. for item in annotated:
    10. covered.update(item.get("concept_ids", []))
    11. return covered
    12. def select_diverse_batch(pool, annotated, vecs, batch_size):
    13. """Select a batch of coverage-gap, mutually dissimilar samples for annotation."""
    14. pool = list(pool)
    15. selected, covered = [], covered_concepts(annotated)
    16. while pool and len(selected) < batch_size:
    17. def priority(item):
    18. new_concepts = len(set(item.get("concept_ids", [])) - covered)
    19. # Max similarity to already-annotated and newly-selected samples;
    20. # smaller means more novel
    21. max_sim = max(
    22. [cosine(vecs[item["id"]], vecs[a["id"]]) for a in annotated + selected]
    23. or [0.0]
    24. )
    25. return new_concepts * 2 + (1.0 - max_sim)
    26. best = max(pool, key=priority)
    27. pool.remove(best)
    28. selected.append(best)
    29. covered.update(best.get("concept_ids", []))
    30. return selected

    Concept estimates can be produced jointly by an image classification model and an image-text matching model. Once annotation is done, the new samples flow back into the training set, forming a closed loop.

    Hard-Sample Reflow and Retrieval-Log Feedback

    • Collect queries that rank results far down, that return zero clicks, or that users rewrite;
    • Focus analysis on pages where users “click in and quickly bounce back”;
    • Organize these cases into “query–expected-result” pairs and continuously supplement the evaluation set and training set.

    Log analysis must also filter out noise from evaluation crawlers, internal test traffic, and geolocation scripts.

    Cold Start and Version Management

    When bringing a new subject collection online, a “pre-annotation → human verification → feedback correction” pipeline can quickly form a seed set. Every change to the ontology and vocabulary must be versioned, and the existing evaluation set must be run as a regression, to prevent “fixing the Snail House while breaking the elephant tamer.”

    From Retrieval to Question Answering: Constraining Generation with Traceability

    Retrieval solves “finding”; question answering solves “explaining clearly.” Large language models let researchers ask directly, “Where does the woman in this miniature live?” But the generation step is where errors are easiest to make, for example:

    • Getting the painting’s date, author, or collection background wrong;
    • Producing unsupported detail about subjects like the bog corpse;
    • Presenting the model’s own associations as historical fact.

    Three constraints are therefore required.

    First, every answer must be traceable. Each conclusion in retrieval-augmented generation carries an image ID and a source excerpt, and the front end supports one-click navigation to the original image and cataloging record.

    Second, refuse when confidence is low. When the retrieval score falls below a threshold, or when the question is unrelated to the collection, the system clearly replies “there is currently no reliable basis in the collection” and offers related results, instead of forcing a fabrication.

    Third, handle sensitive content neutrally. For subjects like the bog corpse, use academic description that both meets research needs and complies with content-safety norms.

    Evaluation and Operations: Verifying Results with Numbers

    Without evaluation, retrieval tuning is just a subjective impression.

    A Layered Evaluation Set

    The evaluation set should be built by domain experts and layered by query type:

    • Literal: “Traponé”;
    • Descriptive: “the woman living in a snail shell”;
    • Associative: “a miniature from the same book as the elephant tamer”;
    • Long-tail: “mechanical fly.”

    Each type should have at least 50 entries, and cold-start slices should be tagged by data state—that is, images newly ingested and not yet adequately indexed.

    Core Metrics

    Metric Meaning Focus
    Recall@K The proportion of relevant documents covered in the top-K results Whether long-tail concepts can still be recalled
    nDCG@K Ranking quality that accounts for position and relevance grade Whether the most relevant miniature ranks at the top
    MRR The mean reciprocal rank of the first relevant result Exact-query experience
    Annotation agreement Degree of agreement among annotators, commonly measured with Cohen’s Kappa Whether the standard is clear and executable
    Human relevance grading Experts score each result, e.g., 0–3 The final experience

    Only when statistics are reported by layer and by slice can you see which class of query an optimization actually improved.

    Online Monitoring

    Monitor the following signals:

    • Zero-result rate and first-screen click-through rate;
    • Click-position distribution and query-rewrite rate;
    • Retrieval-pipeline latency.

    Also split statistics by weekday and weekend, so that traffic spikes from batch-scanning tasks are not misread as anomalies.

    Implementation Roadmap and Common Pitfalls

    Phase Reference duration Core tasks Deliverables
    Phase 1: Modeling 4–6 weeks Ontology design, vocabulary refinement, annotation-standard drafting Ontology document, annotation guide, annotation tool
    Phase 2: Baseline 4–8 weeks Structured + sparse retrieval live, evaluation set built First-version retrieval service, evaluation report
    Phase 3: Enhancement Continuous iteration Vector and cross-modal recall, fusion reranking, active-learning loop Multi-route retrieval service, hard-sample reflow mechanism
    Phase 4: Q&A As needed Retrieval-augmented Q&A, traceability display, refusal strategy Q&A assistant, audit log

    There are four common pitfalls:

    1. Deploy the model first, patch the data later: a general model cannot compensate for a missing ontology;
    2. Vector-only thinking: sparse retrieval remains irreplaceable for canonical-name queries;
    3. Labels chosen off the cuff: without an annotation guide and a consistency measure, annotation quality fluctuates with staff turnover;
    4. Ignoring cold start: newly ingested images are completely invisible until an index is built.

    Conclusion

    From the “Snail House” to the “bog corpse” to the “mechanical fly,” these strange images cannot be found today not because they are not strange enough, but because the system has never described them in a way machines can understand. The main thread of this article can be summarized as follows:

    • Use ontology and controlled vocabularies to answer “what is it, and what else can it be called”;
    • Use multi-route recall and fusion reranking to answer “which miniature is most relevant”;
    • Use active learning and hard-sample reflow to answer “how the model comes to know a new long tail”;
    • Use traceability and refusal to answer “is the answer trustworthy”;
    • Use layered evaluation to answer “did it actually get better.”

    When a user types “a house in a snail shell,” the system returns not just a miniature, but its date, its source, related same-book images, and the different interpretations scholars give it. This is the real value of cultural-heritage digitization: making silent material speak.