onegin-1
a deterministic model for reproducing Eugene Onegin
2 min readupdated
A specialized n-gram model (a model that predicts the next character from a sequence of preceding ones) that reproduces the dedication and eight chapters of Alexander Pushkin's novel character by character. Instead of standard weight-optimization training, it relies on a transition table built directly from the reference text in the Russian Virtual Library. Created by sergei-shteiner, the model serves as a reference baseline for evaluating models on the "Onegin by Heart" benchmark. It is useful for researchers and developers testing evaluation pipelines for long-text memorization and reproduction.
Key features
- Generates the entire reference text character by character from the initial state to the end-of-sequence signal, including headings, stanza numbers, line breaks, and the author's ellipses.
- Relies on a context tail of up to 363 characters—the minimum threshold needed to uniquely determine the next character without collisions.
- Ships in two ready-to-use formats: a looped graph for ONNX Runtime (
onegin-ngram.onnx) and a PyTorch checkpoint with anEmbeddinglayer (model.pt). - Runs deterministically on CPU, outputting an identical UTF-8 file with a verified SHA-256 checksum on every run.
What you can do
- Use it as a baseline when testing language models on verbatim reproduction of long Russian texts in the "Onegin by Heart" benchmark.
- Integrate it into automated tests for evaluation systems and metrics to verify line-matching accuracy and chapter ordering.
Example
import sys
from onnxruntime import InferenceSession
session = InferenceSession("onegin-ngram.onnx", providers=["CPUExecutionProvider"])
[codepoints] = session.run(None, {})
sys.stdout.buffer.write("".join(map(chr, codepoints)).encode("utf-8"))Read more
Details"Onegin by Heart" benchmark score: 5,275 out of 5,275 verse lines in the right chapter and original order (142,818 characters total).
Hardware requirements: runs on CPU via ONNX Runtime or PyTorch; no GPU required.
No weight-optimization training was performed—the transition table was generated directly from the text.
Limitation: the model deterministically reproduces only a single fixed text and is not designed for open-ended generation.










Comments