MARCmin · Shelf-taught AI
Most AI progress has meant bigger models, trained on more text, running on bigger hardware. This site argues for the opposite bet: find the smallest model that can improve itself by reading, and give it the map libraries have spent a century building.
Small models, big stacks. MARCmin: MARC, the format library catalogs are written in, plus min, the smallest model that can read them well enough to learn.
Frontier models try to hold what they know in their weights. That takes data centers to train and run, and the knowledge freezes on the day training ends.[1]
Catalog records, subject headings and classification organize recorded knowledge into a structure a machine can navigate. Most AI search ignores it.
A model that finds the right book and reads the right passage answers from sources it can cite. Its knowledge grows as the collection grows, without retraining.[2, 3]
The question is not how big a model you can afford. It is how small a model can be and still read well enough to learn.[4]
Before the chapters · Fits your library
Nothing here asks a library to change its systems. MARCmin reads the records your system already exports, builds its own search index beside them, and can run without an internet connection.
Most library systems store and export MARC21 records. Decades of cataloging live in that format, and libraries share records in it every day. Even the Library of Congress, which now catalogs in BIBFRAME, converts its records to MARC to share them.[5]
BIBFRAME, the linked-data successor, is arriving slowly, and vendors now support hybrid setups.[6] If your catalog moves, only the serializer changes. The index and model stay.
It reads a regular MARC export, the same kind libraries send to discovery layers and union catalogs. It never writes back.
Circulation, holds and cataloging carry on unchanged. A nightly or weekly export keeps it current, and only changed records need re-encoding. Switch it off and nothing breaks.
Once the catalog is encoded, search needs no connection. The index, a small embedding model and the question all live on one machine. 100,000 records take about 38 MB as 8-bit vectors (Chapter 2).
That suits a branch with weak internet, a bookmobile or a kiosk. Patron questions never leave the building, as library privacy guidance asks.[7, 8]
What it doesn't do
Chapter 1 · A readable map
Before a small model can use the catalog as its map, the map has to be readable. Embedding models were trained on prose. A MARC21 record is tags, indicators, subfield codes and fixed-position codes, with the meaning tucked in between. A pre-encoder is whatever you put between the two. This page lets you try three kinds on real-looking records and then decide whether you need one.
Three kinds of pre-encoder, from cheapest to most expensive:
1. Serializer. Rules that turn a record into labeled, readable text: "Title: …", "Subjects: …", with codes like spa spelled out as "Spanish". How structured data is turned into text measurably changes model results.[9]
2. Field-aware encoding. Separate vectors for title, author, subjects and summary, weighted at query time.
3. Domain-tuned encoder. An embedding model fine-tuned on bibliographic data and real library queries. Small tuned models have beaten large hosted ones on metadata search and subject headings.[10, 11]
Pick a record and switch the rules on one at a time. Each rule removes something the model would otherwise have to read past, or adds words a person would actually type. The token estimate uses about four characters per token.
Each row is one record. The line runs from its raw MARC size to its pre-encoded size under the rules above. Click a row to open that record.
Or paste one record in mnemonic format:
The same query runs over fifteen sample records through four pipelines. Each preset query has one record a librarian would call the right answer; the pill shows where that record lands.
"Semantic" here is a small hand-built concept dictionary standing in for an embedding model, so everything runs in your browser. Real embedding models cope with messy input far better than this, but raw MARC still costs them: more tokens per record, and vectors diluted by codes. Keyword search breaks in a more visible way: in raw MARC the first word of each subfield is glued to its code ($aCooking), so it never matches.
One vector per record mixes the title with a long summary and a pile of subjects. Field-aware encoding keeps a vector per field and weights them for each query. Known-item searches ("books by Okafor", a remembered title) want title and author weight. Topical searches want subjects and summary.
Fine-tuning teaches an embedding model library jargon: controlled vocabulary, abbreviations and the gap between how catalogers describe a book and how patrons ask for it. It is the most powerful option and the one most libraries should do last, because a serializer with lookup tables closes much of the same gap for almost nothing.
| Catalog says | Patron types | Cheaper fix first |
|---|---|---|
Fund raising. | fundraising | Most embedding models handle this already; check before fixing |
Clothing and dress $x Repairing. | how to fix torn jeans | Readable subject strings and the 520 summary; an off-the-shelf model usually bridges the rest |
$v Juvenile fiction. | kids' story | Expand 008/22 audience and add "Audience: children" |
008/35-37 spa | in Spanish | Code lookup table in the serializer |
$4 nrt | narrated by | Relator code table |
LC class QK or Dewey 581 | plants, botany | Add the class caption from a schedule lookup |
| A local subject or collection name | whatever your community calls it | This is where fine-tuning earns its cost |
Thousands of real query and record pairs, from search logs with clicks or checkouts, plus a held-out set to measure against.
Training runs, then re-embedding the whole catalog every time the model changes. It also leaves you maintaining a model of your own.
You've measured that a well-serialized record with a good off-the-shelf model still misses, at a scale where those misses matter.
Your template becomes part of the index. Change a label or a rule and every stored vector is out of date. Version the serializer, store the version with each vector, and re-embed in batches.
Character encoding. Older records may be in MARC-8, not UTF-8 (leader position 09 is blank instead of a). Convert before serializing or diacritics turn into garbage.
Local fields. 9XX fields, item data and holdings vary by library. Decide which carry meaning for searchers and leave out the rest.
Sparse records. Minimal-level and older records often have no summary (520). For those, subject headings and an expanded format line are all the meaning there is, which makes the serializer matter more, not less.
When you can skip it. If search stays keyword-only in your ILS or discovery layer, those already index MARC by field. If you only hand an LLM a handful of records, it can read MARC directly, though a serializer still saves tokens.
Answer four questions. The pyramid shows the retrieval tier, from the simplest approach at the bottom to the heaviest at the top; the verdicts say which pre-encoders are worth it.
Chapter 2
On a Raspberry Pi, a library kiosk or an old laptop, a small language model spends much of its time reading the prompt before it writes a word. Its context window is short, and it never learned to read MARC. Here the pre-encoder does the understanding up front, once, so the device doesn't have to.
The compact template below keeps only what helps a small model match and answer: title, author, subjects, a shortened summary, format, language and year. It puts the meaningful fields first, because whatever comes last is what gets cut.
| Template | Tokens per record | Records that fit | Time to read 5 records |
|---|
Reading speed varies widely by device, model size and runtime; time a prompt on your own hardware and enter it. Token counts use four characters per token, which likely flatters raw MARC: codes, digits and diacritics split into more tokens than plain English.
Vectors only, before index overhead. Smaller formats lose some accuracy; 8-bit usually loses little, and 1-bit works best as a fast first pass with a re-check on the top results. With that re-check, 1-bit vectors keep about 96% of retrieval quality.[12] Keyword search (for example SQLite's built-in full-text index) needs no vectors at all and is the cheapest place to start.
1. Pre-encode and embed the whole catalog once, on a bigger machine. The device only embeds the patron's question.
2. Use the compact template, meaning first.
3. Start with keyword search; add 8-bit vectors only if people search by topic in their own words.
4. Give the small model only the top 3 to 5 records.
Chapter 4
Reading before answering improves one answer. To improve over time, the system keeps what it learned as short notes, each tied to the passage it came from. The next question on the topic starts from those notes instead of from scratch. Nothing about the model itself has to change.[16, 17]
Note 0142
Claim: Beaches lose sand when dams trap river
sediment, not only from rising seas.
Source: Rising water, ch. 3, pp. 61-64
Checked: passage supports the claim
Used in: 3 answers
Status: active
Three rules keep notes from drifting.
1. Every note links to a specific passage.
2. Every note is checked against its passage before it is reused. In one agent study, storing every self-written record dropped accuracy to 13%, against 38.5% with strict filtering.[18]
3. When sources disagree, notes are flagged or retired, not silently overwritten.
The example note and its source are invented for illustration.
The honest limit: reading takes some comprehension. Below a certain size, a model picks the wrong passage or misreads the right one, and no amount of library structure fixes that.[15] Finding that floor is one of the main results this research is after.
Each question below can be answered with an experiment, and each has a result worth publishing whichever way it comes out.
| Question | Hypothesis | Measured by |
|---|---|---|
| 1. Readable map. Does pre-encoding MARC improve retrieval? | Yes for every model, more for small ones | Recall@10, nDCG@10 on a judged test set, against the Library of Congress embedded catalog as the benchmark[19] |
| 2. Navigation. Does browsing subject structure find better sources than similarity alone? | Combining both beats either alone on topical questions | Source relevance judged by catalogers; path length |
| 3. Notes. Do checked, cited notes improve answers over time? | Yes with checking; without it, quality drifts | Expert-scored answers on a fixed question set, repeated over time |
| 4. Minimum viable model. How small can a model be and still match a large model answering from memory? | Much smaller than expected, above a comprehension floor | Answer quality per watt, per dollar and per second, across model sizes |
Small models can't read reliably at any size cheap enough to matter. Navigation adds cost without finding better sources. Notes drift even with checking. Any of these is a useful finding.
Retrieval already lets far smaller models match larger ones on knowledge tasks, especially for less popular facts.[1, 2, 3] Libraries have started applying AI to their catalogs. The Library of Congress embedded about 20 million records in 2026, and new benchmarks test subject-heading assignment.[19, 11, 20] None of these yet measures patron search over MARC across model sizes. That is the gap this project fills, in the spirit of the "collections as data" movement.[21]
Phase 1, about 4 months: build an open test set of real MARC records and real questions with expert judgments, and run the pre-encoder study. The benchmark to match or beat is the Library of Congress embedded catalog.[19] This site's Chapter 1 tools become its demo, rerun on real data.
Phase 2, about 6 to 9 months: start from the Library of Congress embeddings and build the navigating agent, testing it at several model sizes, reading from public-domain and licensed full text.
Phase 3, about 6 months: add the notes loop and run the minimum-viable-model comparison across model sizes and hardware.
Looking for: a partner library for catalog data and questions, catalogers to judge results, and faculty in information science who work on retrieval or digital libraries.
The full plan is in the research proposal, and ways to help are on the Get involved page.
A minimal serializer in Python with pymarc (version 5 or later). It reads UTF-8 and older MARC-8 files alike. Extend the label and code tables to match your own catalog.
Tested with pymarc 5.4 on Library of Congress records and on a MARC-8 test record.
import re
from pymarc import MARCReader
LABELS = {
"245": "Title", "100": "Author", "700": "Contributor",
"264": "Published", "300": "Description", "490": "Series",
"650": "Subject", "651": "Place", "655": "Genre",
"520": "Summary", "504": "Note", "546": "Language note",
}
LANG = {"eng": "English", "spa": "Spanish", "fre": "French",
"chi": "Chinese", "vie": "Vietnamese", "kor": "Korean"}
SKIP = {"0", "1", "2", "4", "6", "8"} # URIs, sources, relator codes, linkage
ABBR = {r"\bp\.": "pages", r"\bill\.": "illustrations",
r"\bcol\.": "color", r"\bed\.": "edition"}
def clean(value):
for pattern, word in ABBR.items():
value = re.sub(pattern, word, value)
return value.strip().rstrip(" /:;,=").rstrip(".")
def field_text(field):
if field.tag == "245": # title and subtitle; skip $c, authors come from 1XX/7XX
parts = [clean(sf.value) for sf in field.subfields if sf.code in "abnp"]
return ": ".join(p for p in parts if p)
roles = [clean(sf.value) for sf in field.subfields if sf.code == "e"]
parts = [clean(sf.value) for sf in field.subfields
if sf.code not in SKIP and sf.code != "e"]
sep = " — " if field.tag.startswith("6") else " "
text = sep.join(p for p in parts if p)
return f"{text} ({', '.join(roles)})" if roles else text
def pre_encode(record):
lines = []
for field in record.get_fields(*LABELS):
line = f"{LABELS[field.tag]}: {field_text(field)}"
if line not in lines: # same heading from LCSH and FAST
lines.append(line)
f008 = record.get_fields("008")
lang = f008[0].data[35:38] if f008 else ""
if lang in LANG:
lines.append(f"Language: {LANG[lang]}")
return "\n".join(lines)
# to_unicode converts MARC-8 records (leader/09 blank) as well as UTF-8 ones
with open("records.mrc", "rb") as fh:
for record in MARCReader(fh, to_unicode=True):
if record:
print(pre_encode(record), end="\n\n")
Numbers in the text link here. Several 2026 papers are preprints that have not yet been peer reviewed.
Research proposal
The plan to test this thesis on real data: four research questions, three phases, the data and rights involved, and how results will be measured.
Looking for a partner library, catalogers, information-science faculty and funders.