mathconv-corpus / README.md
viktor-shcherb's picture
Order the largest producers of the sample by name on ties
f84cf20 verified
|
Raw History Blame Contribute Delete
19.9 kB
metadata
license: other
license_name: per-row-source-licences
license_link: >-
  https://huggingface.co/datasets/viktor-shcherb/mathconv-corpus/blob/main/LICENSES.md
pretty_name: mathconv corpus
language:
  - en
  - de
  - fr
  - es
  - pt
  - ru
  - zh
  - ja
size_categories:
  - 100K<n<1M
task_categories:
  - text-generation
tags:
  - mathml
  - latex
  - math
  - formulas
  - evaluation
configs:
  - config_name: default
    data_files:
      - split: dev
        path: data/dev.jsonl.gz
      - split: test
        path: data/test.jsonl.gz
  - config_name: evaluation
    data_files:
      - split: test
        path: data/evaluation.jsonl
  - config_name: documents
    data_files:
      - split: train
        path: data/documents.jsonl

mathconv corpus

Version 1. 235,071 MathML formulas from 8,668 openly licensed documents, each with its source, its licence and, for part of the rows, a reference in TeX.

What the corpus is for

The corpus is the evaluation data of mathconv, an open-source math formula converter. It is also useful for anyone who needs real MathML:

  • to test MathML parsers, converters and renderers against markup produced by publishers, authoring tools, web pages and TeX converters;
  • to see which elements, attributes and habits occur in practice, which a tolerant parser has to handle;
  • to measure how well a MathML-to-TeX converter agrees with a reference, on the rows that carry TeX.

Only individual formulas are included, never whole documents. It is too small and too uneven in its sources to train a model on, and it is not a sample of mathematics on the web.

Using the data

The dataset has three configurations.

configuration split content
default dev 163,846 formulas from 6,066 documents, for developing a converter
default test 71,225 formulas from 2,602 other documents, for reporting results
evaluation test 20,000 formulas drawn from test, small enough to evaluate on every change
documents train one record for every source document, once for each source that uses it
from datasets import load_dataset

dev = load_dataset("viktor-shcherb/mathconv-corpus", split="dev")
sample = load_dataset("viktor-shcherb/mathconv-corpus", "evaluation", split="test")

Pass revision= with a commit id to fix the version. A result computed on the corpus is reproducible only for the revision it was computed on, so cite the revision with it. The files are plain JSON Lines; data/dev.jsonl.gz and data/test.jsonl.gz are gzip-compressed, data/evaluation.jsonl and data/documents.jsonl are not.

Rows

Every row is one formula. All rows have the same fields.

field meaning
id First 16 hexadecimal characters of the SHA-256 of the UTF-8 bytes of mathml. The same string taken from two sources has the same id; source and id together are unique.
mathml The formula as <math>...</math>, exactly as found in or produced for the source, including namespace prefixes (mml:), HTML-style syntax and any errors.
source The group the row belongs to, listed in the next section.
producer The tool or publisher that wrote the MathML: a publisher, an authoring tool, or a converter with its version.
origin The document the formula comes from: a DOI link, an arXiv page, a Wikipedia revision, or a file in a repository at a fixed commit, sometimes with a #L<line> anchor.
licence SPDX identifier of the licence of that document, such as CC-BY-4.0.
licence_url The licence as the source document gives it.
context inline, display, or unknown when the source does not say.
markup presentation, content or mixed, from the element names.
tex A reference in TeX for the formula, or null.
tex_kind author for TeX written by a person (the author of an article, a Wikipedia editor, a test author) or given to a converter as its input; normalised for TeX produced by a tool that rewrites it, such as the alttext of LaTeXML. null when tex is.
count How many times the exact string occurred in the documents the builder read, summed over exact duplicates.
duplicates How many near-duplicate rows of the same source were merged into this one; see below.
note A remark, set on converter error outputs that were kept on purpose, otherwise null.
split dev or test.

Rows keep the order of their source files. Whitespace, entities and attribute order in mathml are as in the source.

Duplicates

Within a source, rows with identical mathml are merged and their count is added. Formulas that differ only in volatile attributes of the root math element are near-duplicates: the first occurrence is kept as it is and duplicates counts the rows merged into it. The volatile attributes are id, xml:id, altimg. They identify the element in its document (M12, d33e5766, S1.Ex13Xb.m3) or name a per-formula bitmap (si65.svg) and carry no mathematics; every other root attribute either repeats across a source or changes the formula. 41,258 rows were merged this way, which is 15 percent of the rows read. Near-duplicates of different sources are not merged.

Sources

The corpus has 19 sources, each collected separately. Documents are counted when they have at least one row in the corpus; the total counts a document once even if several sources use it, as several tools convert the same Wikipedia article.

source producer documents formulas near-duplicates merged with reference TeX licences
arxiv-html LaTeXML 530 21,952 8,063 100% (normalised) CC BY 4.0, CC BY-SA 4.0, CC0 1.0
biomodels BioModels (SBML kinetic laws, rules and function definitions) 520 6,955 0 0% CC0 1.0
copernicus-jats Copernicus Publications 26 1,790 4,265 0% CC BY 4.0
crawl-focus Copernicus Publications; Mathoid (MediaWiki Math) 2 90 25 98% (author) CC BY 4.0, CC BY-SA 3.0
generated-katex KaTeX 0.19.1 1,342 7,756 0 100% (author) CC BY-SA 4.0
generated-latex2mathml latex2mathml 3.81.1 1,346 7,951 0 100% (author) CC BY-SA 4.0
generated-latexml LaTeXML 0.8.8 1,066 2,966 0 100% (author) CC BY-SA 4.0
generated-latexml-content LaTeXML 0.8.8 608 888 0 100% (author) CC BY-SA 4.0
generated-mathjax MathJax 3.2.1 1,345 7,887 0 100% (author) CC BY-SA 4.0
generated-pandoc pandoc 3.10 1,325 7,561 0 100% (author) CC BY-SA 4.0
generated-temml Temml 0.14.0 1,347 7,744 0 100% (author) CC BY-SA 4.0
mathcat-tests MathCAT test suite 175 4,591 0 0% MIT
mathjax-tests MathJax (test-suite snapshots) 43 2,606 0 100% (author) Apache 2.0
mdn MDN 47 103 0 0% CC0 1.0
openstax OpenStax 424 19,990 10 6% (author) CC BY 4.0
planetmath LaTeXML 130 1,786 1,215 100% (normalised) CC BY-SA 2.5
pmc 30 publishers and publisher groups 4,690 122,056 27,676 22% (author) CC BY 2.0, CC BY 2.5, CC BY 3.0, CC BY 4.0, CC0 1.0
wikipedia-render Wikipedia renderer (MediaWiki action=parse, retrieved 2026-12-03) 1,355 7,922 0 100% (author) CC BY-SA 4.0
wpt web-platform-tests 629 2,477 4 0% BSD 3-Clause
all 8,668 235,071 41,258 44%

Journal articles.

  • pmc: articles of the PubMed Central open-access subset whose licence is CC BY or CC0, read from the anonymous S3 copy of the subset; candidate identifiers came from the Europe PMC search. The licence was checked for every article, from the metadata and from the licence URLs in the article XML. producer is the publisher or publisher group. tex is the tex-math of the same alternatives element, which Springer Nature, eLife and PeerJ supply; it has the wrapper of the publisher's typesetting removed.
  • arxiv-html: papers from the arXiv HTML pages (LaTeXML output) whose licence, taken from the arXiv OAI-PMH record, is CC BY, CC BY-SA or CC0. tex is the normalised TeX annotation of LaTeXML.
  • copernicus-jats: article XML of Copernicus Publications journals (CC BY 4.0).
  • planetmath: entries of PlanetMath, rendered by an older LaTeXML. The licence is the one the site states for all entries (CC BY-SA 2.5) and is not repeated on each entry page.

Books, test suites and references.

  • openstax: sections of three OpenStax book repositories (physics in Polish, precalculus in Spanish, statistics in English), authored in CNXML with unbound m: prefixes.
  • mdn: the MathML examples of MDN Web Docs (CC0).
  • mathcat-tests, wpt, mathjax-tests: the MathML in the test suites of MathCAT (MIT), web-platform-tests (BSD 3-Clause) and MathJax (Apache 2.0). These contain deliberately odd input, and some rows are not well-formed XML.
  • biomodels: kinetic laws and rules of BioModels models whose own file carries the CC0 dedication. The markup is Content MathML.
  • crawl-focus: two web pages, an article page of a Copernicus journal and a copy of a German Wikipedia article.

Wikipedia and generated groups. Wikipedia articles are CC BY-SA 4.0 and contain TeX formulas. A pool of 20,000 distinct TeX formulas was drawn from 1,499 articles in eight languages (English, French, German, Russian, Spanish, Portuguese, Chinese, Japanese), taking formulas with rare commands first and filling up at random. wikipedia-render holds the MathML that Wikipedia's own renderer returns for these formulas. Each generated-* source is MathML produced by running a named tool version on TeX of the pool: KaTeX 0.19.1, MathJax 3.2.1, Temml 0.14.0, pandoc 3.10, latex2mathml 3.81.1 and LaTeXML 0.8.8 (with presentation and with content output). Each tool converted its own random subset of the pool, so subsets overlap. The generated MathML inherits the CC BY-SA 4.0 licence of the TeX it came from, and tex holds that TeX. Formulas that a tool rejected are not in the corpus; a few error outputs that a tool reported inside its markup (merror, red mtext) were kept on purpose and carry a note.

All sources were collected on 2026-12-03. In pmc, arxiv-html and planetmath at most 60 distinct formulas were taken from one document, first those that contain rare elements (mtable, mfenced, mmultiscripts, menclose, mpadded, mphantom, munderover, mlabeledtr, maction, mglyph, mstack, mlongdiv, mscarries, mprescripts, merror), then the rest in an order given by a hash. The scripts in scripts/ repeat every collection.

Splits and the evaluation sample

Documents, not formulas, are assigned to a split, so no document has formulas in both. The split is a function of the origin of the document: the documents of one family (a DOI prefix, a repository, a site) are ordered by the SHA-256 of their origin and the first 70 percent go to dev, the rest to test. A document therefore has the same split in every source that uses it, such as a Wikipedia article that several tools converted. Every source and every producer that has at least two documents appears in both splits. The same formula can still occur on both sides, because different documents contain the same expression.

source dev documents test documents dev formulas test formulas evaluation sample
arxiv-html 371 159 15,210 6,742 1,849
biomodels 364 156 4,834 2,121 581
copernicus-jats 18 8 1,226 564 154
crawl-focus 1 1 88 2 2
generated-katex 937 405 5,436 2,320 636
generated-latex2mathml 943 403 5,539 2,412 661
generated-latexml 749 317 2,085 881 241
generated-latexml-content 414 194 607 281 100
generated-mathjax 946 399 5,531 2,356 646
generated-pandoc 931 394 5,313 2,248 616
generated-temml 945 402 5,421 2,323 637
mathcat-tests 122 53 3,131 1,460 400
mathjax-tests 30 13 1,627 979 268
mdn 33 14 63 40 40
openstax 297 127 14,103 5,887 1,614
planetmath 91 39 1,261 525 143
pmc 3,283 1,407 85,075 36,981 10,562
wikipedia-render 945 410 5,566 2,356 646
wpt 440 189 1,730 747 204
all 6,066 2,602 163,846 71,225 20,000

dev is for people developing a converter: read it, study it, fit to it. test is for reporting; look at it to find failures, but do not tune against it.

The evaluation sample is 20,000 formulas drawn from test, because evaluating a quarter of a million formulas with several renderers on every change is too slow. The draw is stratified by source and producer: each stratum gets a share of its rows in proportion to its size, at least 100 rows where it has that many, and no producer gets more than 2,000 rows, about a tenth of the sample. Within a stratum the rows with the smallest SHA-256 of their source and id are taken, so the draw is the same every time. The sample is its own file, data/evaluation.jsonl, and a subset of test. Its largest producers:

producer formulas in the sample
LaTeXML 1,992
Springer Nature 1,712
OpenStax 1,614
Elsevier 1,359
MDPI 1,093
PLOS 805
eLife 772
latex2mathml 3.81.1 661
MathJax 3.2.1 646
Wikipedia renderer (MediaWiki action=parse, retrieved 2026-12-03) 646
Hindawi 644
Temml 0.14.0 637

Limits and biases

  • One archive dominates. pmc is 52 percent of the rows, and PubMed Central is mostly biomedical and life-science literature. The largest producers:
producer formulas share of the corpus
LaTeXML 23,738 10.1%
Springer Nature 20,989 8.9%
OpenStax 19,990 8.5%
Elsevier 15,845 6.7%
MDPI 12,815 5.5%
PLOS 9,950 4.2%
eLife 8,953 3.8%
latex2mathml 3.81.1 7,951 3.4%
  • Candidates favoured quantitative papers. Candidate articles were first requested with mathematical words in the abstract (equation, model, theorem, Hamiltonian, stochastic, optimisation and similar). The filter was lifted for the groups that fell short, so the effect is weaker there. Papers with few formulas are under-represented.
  • Fields. Among arXiv papers computer science (including machine learning) is the largest category, followed by mathematics, statistics, electrical engineering and economics. OpenStax rows are mostly Polish physics (71 percent of that source).
  • Publishers. Springer Nature, Elsevier, MDPI, Wiley/Hindawi and the Oxford, PNAS and Royal Society group have the most rows; IEEE and IOP Publishing are absent and Cambridge University Press nearly so, because almost no article of theirs passed the licence filter with MathML.
  • Small groups. F1000Research and AIMS Press are small because most of their equations are images, not MathML. Several publishers that appear under unknown or in the long tail of producers have a handful of rows.
  • Few rows per formula shape. In pmc, arxiv-html and planetmath at most 60 distinct formulas per document were taken, rare elements first, so structurally rich formulas are over-represented compared with running text, and single-token formulas (<mi>x</mi>) are under-represented even though they are the most frequent in documents. count records how often a formula occurred.
  • Reference TeX. 56 percent of the rows have no reference TeX; most of them are publisher XML whose TeX is not in the file. For the rows that have TeX, it reflects its origin: for the generated groups it is the input of the tool, so the MathML shows that tool's choices, and an inverse conversion agrees best with the tool that produced it; the normalised TeX of LaTeXML is rewritten by LaTeXML. Author TeX often uses macros defined elsewhere in the document and cannot be rendered by itself.
  • Generated groups are not the wild. Their MathML is regular and complete, and Wikipedia TeX is a narrow style of mathematics; the converters are the same few tools that web pages use.
  • Malformed markup is kept. Test suites and some crawled pages contain markup that is not well-formed XML; a tolerant parser has to cope with it, and the rows are not cleaned.
  • Languages. The text inside formulas is mostly English, with German, French, Spanish, Portuguese, Russian, Chinese and Japanese from Wikipedia and the OpenStax books.

Licences and attribution

The dataset is a collection of excerpts. Each row is published under the licence of the document it was taken from, given in its licence and licence_url fields, and that field is the authority; the dataset as a whole has no single licence. LICENSES.md repeats this and lists the licences below. The scripts under scripts/ are licensed under the MIT licence.

Decisions that affect single licences: an article that lists CC BY together with a CC0 dedication of its data is counted as CC BY; the PlanetMath licence is the site-wide statement; the licence of generated MathML is that of the TeX it was generated from. Filter on licence if you need only some of the licences, for example without the share-alike ones.

Credit the authors of the documents you reuse. ATTRIBUTION.md summarises the sources and data/documents.jsonl lists every source document with its identifier, title, authors where known, venue, publisher, year, licence and licence URL.

Requesting removal

If you are an author or rights holder and want a formula removed, use the issue form Request removal of a formula of the mathconv project, or open a discussion on this dataset page. Give the id of the formula or the address of the source document. Removed rows are left out of the next revision.

Versioning

This is version 1. It replaces the first file of this dataset, data/formulas.jsonl with 6,170 rows from two sources; that file is superseded, and its formulas from copernicus-jats and crawl-focus are part of this version with the new fields (the id is now a SHA-256 hash). Revisions of the dataset are Git commits; cite the commit id of the revision you used.

Scripts

scripts/ holds every script that built the corpus: one extraction script per source (openstax.py, pmc.py, arxiv_html.py and so on, with corpus_common.py and scholarly_common.py), carry_v0.py and extract_local_mathml.py for the two sources of the first file, and assemble.py, which validates, de-duplicates, splits and writes the files of this dataset from the outputs of the others. card_template.md is the template of this card and expected_rows.json holds the row counts that assemble.py checks. Run a script with --help for its arguments.