Nekyia: Virgilio
Nekyia is a project from ordos-research that trains small language models from zero on text from before a cutoff date. The name comes from Odyssey 11, and Virgilio is the guide who speaks to a medieval Italian. This model has 893.5 M parameters and reads Latin, Italian, Old French, Middle English, Old Spanish, and other Romance languages from before 1450.
Example answers
- Question:
Quid est iustitia?Answer:Iustitia est virtus aequalitatis distributiva, prout scilicet unicuique reddit quod suum est.Gloss: What is justice? Justice is the distributive virtue of equality, as it gives to each person what is his own. - Question:
Utrum anima sit immortalis?Answer:Anima est immortalis, et ex se et ex sua conditione.Gloss: Is the soul immortal? The soul is immortal, both from itself and from its condition. (In two of four samples, the model said that the soul is not immortal, because it argues both sides.) - Question:
Maestro, che cosa è amore?Answer:È uno ardentissimo desiderio d'avere quello che l'uomo più ama, e questo cotale amore regna nella volontà.Gloss: Master, what is love? It is a most burning desire to have what a man loves most, and this love rules in the will. - Question:
Maistres, por quoi est la mer salee?Answer:Por ço qu'ele est salee e amere e plaine de tempeste e de pluie e de venz.Gloss: Master, why is the sea salty? Because it is salty and bitter and full of storm and rain and winds. - Question:
What is synne?Answer:Synne is wikked will or a wickid werke, wherfore it is cleped þe firste synne þat god made, after Abel is cleped Abel.
These examples are plain samples from the chat model (temperature=0.8, top_p=0.95), selected by hand from 4 samples each.
How to use it
A prompt must start with a header line. Do not put text before the header. Use these forms for each language:
Latin:
<|doc|> lang=la date=1250..1280 id=chat source=scta genre=dialogue
A. Quid est iustitia?
M.
Italian:
<|doc|> lang=it date=1300..1350 id=chat source=ovi genre=dialogue
Discepolo. Maestro, che cosa è amore?
Maestro.
Old French:
<|doc|> lang=fro date=1200..1250 id=chat source=bfm genre=dialogue
Deciples. Maistres, por quoi est la mer salee?
Maistres.
Middle English:
<|doc|> lang=enm date=1380..1425 id=chat source=cme genre=dialogue
DIUES. What is synne?
PAUPER.
Rules for a prompt:
- Start every prompt with the
<|doc|>header line. - Put the speaker label on a new line after the question.
- Stop generation at the first line break (
\n). - Install
transformersversion 4.51 or later (tested with version 5.22).
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
repo = "ordos-research/nekyia-virgilio"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo).eval() # base model: add subfolder="base"
prompt = '<|doc|> lang=la date=1250..1280 id=chat source=scta genre=dialogue\nA. Quid est iustitia?\nM.'
ids = tok(prompt, return_tensors="pt", add_special_tokens=False).input_ids
newline = tok.encode("\n", add_special_tokens=False)[-1]
out = model.generate(ids.repeat(4, 1), max_new_tokens=100, do_sample=True, temperature=0.8, top_p=0.95,
eos_token_id=[newline, tok.eos_token_id], pad_token_id=tok.pad_token_id)
for o in out:
print(tok.decode(o[ids.shape[1]:], skip_special_tokens=True).split("\n")[0].strip())
One plain sample is weaker than a selected answer. The project chat page writes 8 candidate answers and keeps the candidate that the question helps most. This method uses the mean log-probability of the answer after the real question, minus the mean after other questions. The selection code is in serve/rerank.py and serve/templates.py in the folder code/ of this repository. The full code, with the chat page, is at https://github.com/conorreid/nekyia. The repository also holds the base model before the chat fine-tune in the base/ folder. To load the base model, add subfolder="base".
Training text
| Stem | Content | M words | Passes | Held-out loss (nats/token) | Held-out bits/character |
|---|---|---|---|---|---|
la | Latin, edited text (ancient authors, Church Fathers, scholastic authors from SCTA, Corpus Corporum) | 210.1 | 4 | 2.987 | 0.96 |
la_ms | Latin manuscript transcriptions (CoMMA corpus: machine-read medieval manuscripts, with scribe abbreviation signs) | 2,526.9 | 0.84 | 4.842 | |
fro_ms | Old French manuscript transcriptions (CoMMA) | 405.7 | 3 | 4.136 | |
it | Italian to 1450 (OVI corpus, Datini letters, Biblioteca Italiana, new OCR of old editions) | 36.1 | 10 | 3.139 | 1.20 |
osp | Old Spanish (OSTA) | 20.4 | 5 | 3.444 | 1.24 |
enm | Middle English (Corpus of Middle English Prose and Verse, TEAMS texts, letters and local documents) | 13.1 | 10 | 3.791 | 1.64 |
fro | Old French, edited text (Base de Français Médiéval and others) | 9.7 | 10 | 2.849 | 1.19 |
rom | Other Romance (Galician-Portuguese, Catalan, Occitan, Franco-Italian, Anglo-Norman) | 1.2 | 8 | 2.833 |
The corpus has about 5.6 B training tokens, and about 457 M of them are edited text. The corpus contains no modern introductions, no translations, no Wikipedia, and no synthetic text. Filters remove modern editor text such as introductions, notes, apparatus, and indexes. Edited text stops at 1450. A manuscript enters the corpus if its date range starts by 1450 (for example, a manuscript dated 1401-1500). At least 20 percent of the Latin manuscript text and 14 percent of the French manuscript text are copies of other manuscripts of the same work. The pipeline did not remove these copies.
Training
The model uses the Qwen3ForCausalLM architecture with tied embeddings and its own BPE tokenizer. Every weight trained from a random start on the project corpus.
| Setting | Value |
|---|---|
| Parameters | 893.5 M |
| Layers | 28 |
| Width / Intermediate | 1,536 / 4,096 |
| Context window | 2,048 tokens |
| Tokenizer vocabulary | 65,536 ids (about 1.5 tokens per word) |
| Hardware | 8 NVIDIA H100 GPUs on RunPod |
| Time | 14.2 hours |
| Steps and tokens | 27,100 steps of 294,912 tokens (7.99 B tokens) |
| Optimizer and precision | AdamW, bf16 mixed precision |
| Learning rate | 4e-4 (1,000-step warm-up, linear decay over the last 20 percent) |
| Regularization | Dropout 0.1, weight decay 0.3, z-loss 1e-5 |
The base run occurred from 13 to 14 November 2026. The last 10 percent of the steps read edited text only. This last phase caused the model to lose part of the manuscript text (la_ms loss increased from 4.16 to 4.84). The bits per character values in the table come from different holdout texts and give the order only.
The chat model at the top level is a 50-step fine-tune from the end of the base model. It used a learning rate of 5e-5 and a batch size of 6 windows of 2,048 tokens. Half of each batch was a replay of edited base text. Short fine-tunes worked best, because the loss on test pairs increased after step 100.
The fine-tune used only real question and reply pairs from period texts. A decision model (which gives a yes/no probability and writes no text) selected the pairs, with limits set from 300 hand labels. The training set had 3,070 Latin pairs (scholastic questions of the form Utrum ...? with the first sentences after Respondeo, question books, and pairs from running text), 1,241 Italian pairs, 283 Old French pairs, 183 Middle English pairs, and 42 Old Spanish pairs.
Evaluation
Question gain measures the loss of the real reply after a different question minus the loss after its own question. A positive number shows that the model uses the question. After the fine-tune, question gain is +0.58 for Latin and +0.26 for Italian (up from +0.48 and +0.22 on the base model).
The project also tested fixed questions written before sampling, with 8 candidates and answer selection. A decision model gave the probability that the reply directly answers the question. Across three rounds, the mean score was 0.75 for Latin (60 answers), 0.85 for Italian (30), 0.85 for Old French (30), and 0.76 for Middle English (30). The Akhilleus model scored 0.44 on the same 20 Latin questions. This measure scores form (a direct reply on the subject) and not truth. It is not calibrated across languages, and the spread between rounds is up to 0.13.
In base model samples, scholastic Latin is fluent and stays on the subject. Italian, Old French, and Middle English use correct old language, but their content is circular. One reader (the project owner) found the scholastic Latin the best of the four Nekyia models. No blind human scoring exists yet.
Limits
Specific limits of Virgilio:
- The medieval Christian viewpoint is dominant.
- The model can write scribe abbreviation signs from the manuscript corpus.
- Old Spanish has only 42 training pairs and no test evaluation.
- Middle English and Old French have few training pairs.
- The Thomas Aquinas test pairs are not a clean test, because a second copy of the Summa is in the training text.
General limits of all Nekyia models:
- The models are small. An answer has the correct language and form, and it is usually on the subject, but its content is often wrong, circular, or empty.
- The models know nothing after their cutoff date.
- The models repeat the views of their sources, which include views on religion, slavery, women, and foreign peoples that are offensive today.
- Do not use these models for facts, for translation, or for any decision.
- OCR errors and some modern editor text remain in the training corpus.
The other Nekyia models
ordos-research/nekyia-akhilleus: Ancient Greek and Latin. Cutoff 610. 324 M parameters. Answers in Attic Greek, with weaker Latin.ordos-research/nekyia-dongpo: Classical Chinese. Cutoff 1279. 306 M parameters. Gives question and answer in the 問答 form, and keeps the manner of Chan replies.ordos-research/nekyia-teiresias: the ancient world in more than 20 languages. Cutoff 610. 324 M parameters. The first model and a proof of the method.
Licence
The licence of this repository is cc-by-nc-sa-4.0. The original texts are in the public domain, but some of the digital editions in the training corpus have non-commercial terms.