A Library You Can Ask

The Magyar Elektronikus Könyvtár — MEK, the digital library of the National Széchényi Library — is one of those quietly enormous public goods: thousands upon thousands of Hungarian books, free to anyone. You can browse it, search it, download from it. What you can’t do is ask it anything — point at the whole collection and say, in plain Hungarian, what does this say about X, and get an answer that comes back out of the books themselves.

So I built a demo that could. Entirely locally, on one machine.

Local by design

Everything ran in-house — the vector store, the embedding model, the chat interface, all on hardware I controlled. Partly that’s cost: no per-token bill, no metered API. Partly it’s that a self-contained stack is easier to trust and to reason about, and nothing about the collection has to leave the room. But there was a sharper reason. A system like this rests almost entirely on one component that most people treat as a commodity — and I didn’t want it to be a commodity. I wanted it to be mine.

The part underneath everything

That component is the embedding model — the thing that turns a sentence into a vector, so that “close in meaning” becomes “close in space.” Retrieval lives or dies on it. And here’s the problem: nearly every embedding model worth using is trained on English, or on a big multilingual mix where Hungarian is a rounding error. Hungarian is Uralic, agglutinative, morphologically dense, spoken by around thirteen million people — exactly the kind of language that gets underserved by off-the-shelf tools.

So I’d trained embedding models for Hungarian — sentence-embedding models built for the language specifically, distilled from a strong teacher and evaluated on Hungarian semantic-similarity data. The huBERT-based variant came out strongest, and that’s the one sitting under the whole library. When the system decides which passages of which books are relevant to your question, it reads them through vectors made by something that actually understands Hungarian.

That’s the part I’m proud of. The rest is plumbing — good plumbing, but plumbing. This was the piece that made the difference.

Hybrid search, because books are stubborn

Retrieval ran on Weaviate, with hybrid search: dense vectors from my model, combined with plain keyword search, the two fused into a single ranking.

Dense vectors are wonderful at meaning and careless with specifics. Ask about a concept and they shine; ask about a particular name, an archaic spelling, an exact title, and they smear it into a general neighbourhood. Books are full of exactly those specifics — proper nouns, rare words, older orthography. Keyword search catches what the vectors blur. Running both and fusing the results gives you the meaning and the exact match, which for a corpus of thousands of Hungarian books — many of them old — matters far more than it would for a tidy modern FAQ.

Where you actually ask it

I put the interface inside Mattermost, the self-hostable chat platform, as a bot. You ask a question in a channel, in Hungarian, and the bot answers from the books, with the sources it drew on. No new application to install, no separate portal to learn, nothing leaving the building. It lives where people already talk.

Under the hood it’s retrieval-augmented generation, kept honest: the question gets embedded, the hybrid search pulls the most relevant passages out of Weaviate, and those passages ground the answer. Grounding it this way is the whole point — the answers trace back to real books rather than to whatever the model half-remembers.

What it adds up to

Thousands of books — a real slice of a national library — chunked, embedded, and indexed on a single machine. Answerable in conversational Hungarian, through a model I built for exactly this language. No cloud, no meter running, nothing about the collection leaving the room.

The library was always public. This just made it something you could talk to.