The Dataset Viewer has been disabled on this dataset.

mGENRE title trie + Wikidata QID lookup — impresso NEL assets

Three marisa-trie native binaries that support multilingual entity linking with mGENRE. They are the runtime assets for the impresso-project/nel-mgenre-multilingual model as run by the impresso-inference harness:

  • a title prefix tree that constrains beam search to valid Wikipedia titles,
  • a (language, title) → Wikidata QID lookup for offline QID resolution, and
  • a QID → (class, birthdate) attribute table for offline post-linking filters (disambiguation drop, birthdate anachronism, entity-type repair).

Both are mmap-loaded at startup, so cold start is seconds regardless of file size (the legacy pickle path took ~57 min).

Files

File Size Format Role
titles_lang_all105_marisa_trie_with_redirect.marisa ~600 MB marisa_trie.Trie (native .save/.mmap) Prefix tree of valid Title >> lang token-id sequences (105 languages, redirects included). Drives constrained beam search via a prefix_allowed_tokens_fn callback.
lang_title2wikidataID-normalized_with_redirect.marisa ~200 MB marisa_trie.BytesTrie Maps f"{lang}\x1f{title}" → the lex-smallest Wikidata QID (ASCII). Resolves generated titles to QIDs offline.
qid2attrs.marisa ~70 MB marisa_trie.RecordTrie (fmt "<Bi") Maps each Wikidata QID(class_code, birth_days). Per-QID attributes for offline post-linking filters.

The two GENRE-derived files hold ~89 million keys each (all105 = the 105 languages of the underlying mBART-50 / mGENRE vocabulary); qid2attrs.marisa holds ~20.2 million keys — one per distinct QID reachable through the lookup.

Provenance & construction

These files are converted, byte-faithfully, from Facebook Research's GENRE public downloads at https://dl.fbaipublicfiles.com/GENRE/:

  • titles_lang_all105_marisa_trie_with_redirect.pkl (~582 MB) — a pickled GENRE MarisaTrie wrapper. Conversion extracts the inner marisa_trie.Trie and re-saves it as a bare native binary so it can be mmap-ed directly.
  • lang_title2wikidataID-normalized_with_redirect.pkl (~3.9 GB) — a dict[(lang, title), str | set[QID]]. Conversion streams it into a marisa_trie.BytesTrie, collapsing multi-QID values to the lex-smallest QID at build time (so the runtime does a single trie lookup instead of an ~8-minute normalisation pass per launch).

The conversion is performed by the impresso-nel-stage-assets tool in impresso-inference (src/impresso_inference/tasks/nel/cli/stage_assets.py). Nothing about the entity inventory is added or removed — this is a format/packaging re-host of the GENRE data for fast startup.

QID attributes (qid2attrs.marisa)

Unlike the two files above, qid2attrs.marisa is not derived from GENRE — it is built from Wikidata so that post-linking filters run fully offline (no live Wikidata/Wikipedia HTTP calls). It is keyed by Wikidata QID and each value is a fixed 5-byte record (marisa_trie.RecordTrie, struct format "<Bi"):

Field Type Meaning
class_code uint8 (B) Coarse entity class: 0=other, 1=org, 2=loc, 3=person, 4=disambiguation. The numeric order is the resolution priority (higher wins on multi-class QIDs).
birth_days int32 (i) Earliest date of birth as days since 0001-01-01 (proleptic Gregorian). Sentinel -2147483648 (-2**31) means no/unusable birthdate (absent, BCE, or imprecise).

Coverage (from the 20.2 M linkable QIDs): other 38.9 %, loc 32.5 %, person 18.2 %, disambiguation 6.0 %, org 4.4 %; 16.5 % carry a birthdate (90 % of the person class).

Construction — by the impresso-nel-stage-qid-attrs tool (src/impresso_inference/tasks/nel/cli/stage_qid_attrs.py):

  1. Enumerate the linkable universe = the distinct QID values of lang_title2wikidataID-normalized_with_redirect.marisa (the only QIDs mGENRE can emit).
  2. Pull attributes from the QLever Wikidata endpoint:
    • class via wdt:P31/wdt:P279* against fixed roots — person wd:Q5, organization wd:Q43229, location wd:Q27096213 + wd:Q42124, and disambiguation pages via direct wdt:P31 wd:Q4167410;
    • birthdate via the earliest wdt:P569 (conservative: only the earliest claim).
  3. Intersect with the linkable set and pack one record per QID.

Role. In impresso-inference the NEL writer looks up each linked QID here to: drop disambiguation pages; drop person mentions whose birthdate is after the article's publication date (an impossible, i.e. wrong, link); and repair entity types (e.g. an org-tagged mention whose QID is actually a location or person).

Intended use

Pair with impresso-project/nel-mgenre-multilingual (mGENRE, an mBART-50 sequence-to-sequence entity linker). mGENRE emits strings of the form "Wikipedia_Title >> xx":

  • The trie restricts generation to valid titles at every decoder step (prevents hallucinated pages).
  • The lookup turns the generated (title, lang) into a Wikidata QID without any live Wikipedia/Wikidata HTTP calls — suitable for offline / batch inference.

In impresso-inference, the NEL task auto-downloads whichever file is missing from this dataset on first launch. See that repo's src/impresso_inference/tasks/nel/ for the full pipeline.

How to load

import marisa_trie

# Title trie — constrained decoding
trie = marisa_trie.Trie()
trie.mmap("titles_lang_all105_marisa_trie_with_redirect.marisa")

# (lang, title) -> QID lookup
lookup = marisa_trie.BytesTrie()
lookup.mmap("lang_title2wikidataID-normalized_with_redirect.marisa")
qid = lookup[f"en\x1fGermany"][0].decode("ascii")   # -> "Q183"

# QID -> (class, birthdate) attributes
from datetime import date, timedelta
CLASS = {0: "other", 1: "org", 2: "loc", 3: "person", 4: "disambiguation"}
BIRTH_NONE, EPOCH = -2**31, date(1, 1, 1)
attrs = marisa_trie.RecordTrie("<Bi")
attrs.mmap("qid2attrs.marisa")
class_code, birth_days = attrs["Q42"][0]            # Douglas Adams -> (3, 712657)
cls = CLASS[class_code]                              # -> "person"
birth = None if birth_days == BIRTH_NONE else EPOCH + timedelta(days=birth_days)  # -> 1952-03-11

Token-id encoding (trie only). marisa-trie stores keys as UTF-8 strings, so mGENRE token ids are encoded per character as chr(t) for t < 55000 and chr(t + 10000) otherwise — a 10 000-codepoint shift that skips the UTF-16 surrogate range. This matches the upstream GENRE byte layout; any consumer of the trie must apply the same shift when decoding allowed-token sets. Keys are Title >> lang token sequences.

Licensing

Released under CC BY-NC 4.0 (non-commercial), inherited from the upstream facebookresearch/GENRE data the trie and lookup are derived from. The underlying knowledge base is public: Wikidata identifiers are CC0, and Wikipedia titles are CC BY-SA. Use for non-commercial research consistent with the GENRE license.

qid2attrs.marisa contains only Wikidata facts (P31/P279/P569), which are CC0; its QID selection follows the GENRE-derived lookup above, so it is distributed here under the same non-commercial terms for consistency.

Citation

The trie and lookup originate from mGENRE:

@article{de-cao-etal-2022-multilingual,
  title   = "Multilingual Autoregressive Entity Linking",
  author  = "De Cao, Nicola and Wu, Ledell and Popat, Kashyap and Artetxe, Mikel
             and Goyal, Naman and Plekhanov, Mikhail and Zettlemoyer, Luke and
             Cancedda, Nicola and Riedel, Sebastian and Petroni, Fabio",
  journal = "Transactions of the Association for Computational Linguistics",
  volume  = "10",
  year    = "2022",
  address = "Cambridge, MA",
  publisher = "MIT Press",
  url     = "https://aclanthology.org/2022.tacl-1.16",
  doi     = "10.1162/tacl_a_00460",
  pages   = "274--290"
}

Acknowledgements

Repackaged for historical-newspaper entity linking by the Impresso project — an interdisciplinary effort on historical media analysis across languages, time, and modalities. Funded by the Swiss National Science Foundation (CRSII5_173719, CRSII5_213585) and the Luxembourg National Research Fund (grant No. 17498891).

Downloads last month
182