mathconv-corpus / scripts /card_template.md
viktor-shcherb's picture
Publish version 1 of the corpus
93e3ef1 verified
|
Raw History Blame Contribute Delete
15.4 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. {{TOTAL_ROWS}} MathML formulas from {{DOCUMENTS}} 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 {{DEV_ROWS}} formulas from {{DEV_DOCUMENTS}} documents, for developing a converter
default test {{TEST_ROWS}} formulas from {{TEST_DOCUMENTS}} other documents, for reporting results
evaluation test {{EVAL_ROWS}} 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 {{VOLATILE}}. 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. {{MERGED}} rows were merged this way, which is {{DEDUP_SHARE}} percent of the rows read. Near-duplicates of different sources are not merged.

Sources

The corpus has {{SOURCE_COUNT}} 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.

{{SOURCES_TABLE}}

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.

{{SPLIT_TABLE}}

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 {{EVAL_ROWS}} 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 {{SAMPLE_FLOOR}} rows where it has that many, and no producer gets more than {{PRODUCER_CAP}} 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:

{{EVAL_PRODUCERS}}

Limits and biases

  • One archive dominates. pmc is {{PMC_SHARE}} percent of the rows, and PubMed Central is mostly biomedical and life-science literature. The largest producers:

{{TOP_PRODUCERS}}

  • 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. {{NO_TEX_SHARE}} 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.

{{LICENCE_TABLE}}

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.