Teaching a Machine to Read Thousand-Year-Old Letters

Sometime around 1103, a traveler sat down to describe an enormous journey — from Libya all the way to India — in a letter written in Judaeo-Arabic (Arabic in Hebrew characters). Nearly a millennium later, that letter survives, one piece among roughly 400,000 fragments recovered from the storeroom of a synagogue in Old Cairo. Collectively, they are called the Cairo Geniza, one of the richest windows we have into daily lives in the medieval Mediterranean: trade, marriage, lawsuits, gossip, and prayers. The Princeton Geniza Project (PGP) exists to make that scattered archive usable — a searchable, cross-referenced catalog of documents physically spread across dozens of libraries on three continents.

It is physically spread across dozens of libraries. A single fragment might be photographed by the library that holds it, transcribed by a scholar somewhere else, and cataloged again in Princeton’s own database — three descriptions of the same object that don’t automatically know about each other. This post describes an effort towards digital Geniza research: data engineering, machine learning, and AI coding tools.

Syncing digital Geniza collections

Today, Geniza resources (fragments and their metadata) are scattered across multiple research institutions. Better collaboration implies advancing Geniza research to reveal more about the medieval era in the Middle East. In effort to synch two of the biggest digital Geniza collections, those of the Cambridge University Library and the Princeton Geniza Lab, our team ingested images and metadata of close to 21,000 Geniza fragments from Cambridge’s database into Princeton’s using IIIF (the International Image Interoperability Framework) v2 standard for sharing copyrighted images. IIIF is a shared standard that lets one institution’s viewer pull full-resolution scans directly from another’s servers — the reason a PGP record can show Cambridge’s photographs without Princeton re-hosting them.

Cambridge Digital Library record for Genizah fragment T-S AS 201.348, showing the fragment image and its metadata
Princeton Geniza Project document details for letter T-S AS 201.348: shelfmark, Judaeo-Arabic language, and description
Princeton Geniza Project image viewer showing T-S AS 201.348 recto, served from Cambridge via IIIF
Princeton Geniza Project record for T-S AS 201.348 with the citation crediting Cambridge University Library

The ingested (right) vs the reference (left) resource as they appear on the respective institutions’ websites

Validating the sync with AI help

Before opening the ingested Geniza data on Princeton Geniza publicly (deploy the synch to production), the consistency and integrity of the ingest (across Princeton and Cambridge) was verified with the help of AI. First, we decided that for a single ingested fragment, if the shelf-mark property matches (what is on Princeton’s vs what is on Cambridge’s), then we judge it was a successful ingest.

After filtering out noise, the 12 records that have different shelf-mark spotted by Claude were of fragments that are parts of joins (a Geniza join is a later realization by Geniza researchers that at least two fragments (sitting on at least two different shelf-mark spots) were one fragment that got separated (e.g. torn) at some time point in the past). So, it may be the case that in a research institution, fragments of a join are identified by a certain shelf-mark that is different from the shelf-mark identifying them in a different institution (assuming they are recognized here and there as a join).

Claude summary of 44 shelfmark problem rows, with a table of the 12 truly different CUDL vs PGP shelfmarks

The 12 “truly different” shelf-marks turned out to be manuscript joins, not errors.

The who, where, and what of the text

In addition to digitization, curation, synching digital metadata across institutions, OCRing, comes the interesting question; that is what’s inside the text — and that’s where applied computational advancement in Natural Language Understanding (NLU) comes in: Named Entity Recognition (NER). NER means reading text and automatically tagging interesting pieces of texts: e.g. people and places. Point it at “Steve Jobs was born in San Francisco, he is the co-founder of Apple” and it returns Steve Jobs (person), San Francisco (location), Apple (organization). Doing that across the corpus then asking, “which documents mention this merchant?” without a human reading every line.

As mentioned in Qu et al (2023), building NER for medieval Arabic and Judaeo-Arabic is not trivial. English gives NER systems free hints — capital letters flagging proper names — but Arabic script has none, so that signal is gone. It’s also agglutinative: one written word can bundle a preposition, an article, and a root, so بالسيارة is “by car” as a single token. The same name can be spelled several ways (which must be normalized), while the absence of short vowels means one spelling can map to several words (the same four letters يعمل can mean “work” or “operate”). And there aren’t many good, annotated datasets or lexicons to learn from. Every one of those makes the model’s job murkier.

The approach here is a standard transfer-learning pipeline. Starting with a pre-trained language model — one that has already read enormous amounts of Arabic and learned the statistics of the language e.g. Antoun et al (2020). Fine-tune it on a smaller, human-annotated and relevant dataset until it can reproduce human labels, evaluate it against annotated text it wasn’t trained on, once the quality assessment of the result is satisfactory, apply it on the unannotated corpus to tag everything else. The labels were kept simple — person, location, and a miscellaneous bucket for dates, currencies, and commodities.

How do you know if the model is any good? Not from “accuracy” alone, the fraction of predictions the model got right — that misleads when what we care about is rare, since – with Accuracy metric – a model can still score well while quietly missing real entities (just because the tags are not as frequent). NER is scored instead with precision (of what was tagged, how much was real?) and recall (of what was real, how much was tagged?), combined into an F1 score that balances the two — the right choice when the costs of false negatives and false positives dominate, as they do when hunting named people in a sparse historical text. The preliminary results are early but encouraging and reveal issues from the uneven scoring of unbalanced tags. On an 1821 letter (PGP 30995, transcribed by Jane Hathaway) the model managed only a weighted F1 around 0.41. On a 1169 diplomatic letter (PGP 40155, transcribed by Geoffrey Khan) it reached about 0.80, nailing the miscellaneous category outright. And on that 1103 India-trip letter (PGP 9690, transliterated by Marina Rustow) it landed around 0.63 — strong on locations. The lesson: the model is only as good as how often a category appears, and a single letter is a demanding test.

NER classification reports for PGP 30995 (F1 0.41), PGP 40155 (F1 0.80), and PGP 9690 (F1 0.63)

Per-document scores on three Medieval letters. Performance swings with how often each entity type appears in the text.

Takeaway

In an interdisciplinary context, establishing a digital foundation with systemic procedures for data sharing and collaboration allows for computational methods to help advance humanities research. Mining for information in ancient text of low-resourced languages is challenging and requires carefully curated and annotated data for training, evaluation, and applying inference of models before they may be deployed into useful state to help address research gaps in the Humanities field of interest.

References

  • Qu, X., Gu, Y., Xia, Q., Li, Z., Wang, Z., & Huai, B. (2023). A survey on Arabic named entity recognition: Past, recent advances, and future trends. IEEE Transactions on Knowledge and Data Engineering, 36(3), 943-959
  • Antoun, W., Baly, F., & Hajj, H. (2020, May). Arabert: Transformer-based model for Arabic language understanding. In Proceedings of the 4th workshop on open-source Arabic corpora and processing tools, with a shared task on offensive language detection (pp. 9-15).
  • [PGPID 40155] Museum of Islamic Art in Cairo, Qaṣr Ibrīm, MIAC 23973.50. Available online through the Princeton Geniza Project at https://geniza.princeton.edu/documents/40155/ (accessed July 13, 2026).
  • [PGPID 9690] Cambridge University Library, Taylor-Schechter, T-S 12.392. Available online through the Princeton Geniza Project at https://geniza.princeton.edu/documents/9690/ (accessed July 13, 2026).
  • [PGPID 30995] Alliance Israélite Universelle, AIU XII.84. Available online through the Princeton Geniza Project at https://geniza.princeton.edu/documents/30995/ (accessed July 13, 2026)
Posted in Uncategorized