wikitext-lance / README.md
tsmithv11's picture
Publish wikitext in Lance format (#1)
b10ae5e
|
Raw History Blame Contribute Delete
8.43 kB
metadata
pretty_name: WikiText in Lance
license: cc-by-sa-4.0
language:
  - en
task_categories:
  - text-generation
  - text-retrieval
tags:
  - lance
  - wikipedia
  - language-modeling
  - information-retrieval
size_categories:
  - 1M<n<10M
arxiv: 1609.07843
configs:
  - config_name: wikitext-103-raw-v1
    default: true
    data_files:
      - split: train
        path: viewer/wikitext-103-raw-v1/train.parquet
      - split: validation
        path: viewer/wikitext-103-raw-v1/validation.parquet
      - split: test
        path: viewer/wikitext-103-raw-v1/test.parquet
  - config_name: wikitext-103-v1
    data_files:
      - split: train
        path: viewer/wikitext-103-v1/train.parquet
      - split: validation
        path: viewer/wikitext-103-v1/validation.parquet
      - split: test
        path: viewer/wikitext-103-v1/test.parquet
  - config_name: wikitext-2-raw-v1
    data_files:
      - split: train
        path: viewer/wikitext-2-raw-v1/train.parquet
      - split: validation
        path: viewer/wikitext-2-raw-v1/validation.parquet
      - split: test
        path: viewer/wikitext-2-raw-v1/test.parquet
  - config_name: wikitext-2-v1
    data_files:
      - split: train
        path: viewer/wikitext-2-v1/train.parquet
      - split: validation
        path: viewer/wikitext-2-v1/validation.parquet
      - split: test
        path: viewer/wikitext-2-v1/test.parquet

WikiText in Lance

Search English Wikipedia article introductions with a natural-language question and locate the matching article in the original WikiText split. This release preserves every text row in all four configurations of WikiText-2 and WikiText-103, with the original split and order. Original Salesforce dataset at the converted revision

Browse on Hugging Face

The viewer previews the first 1,000 rows of every configuration and split using the Parquet tables in viewer/. Use data/<configuration>/<split>.lance for the complete text and search/<raw-configuration>/<split>.lance for semantic retrieval. Open the Dataset Viewer

Splits

Source configuration Train text rows Validation text rows Test text rows
wikitext-103-raw-v1 1,801,350 3,760 4,358
wikitext-103-v1 1,801,350 3,760 4,358
wikitext-2-raw-v1 36,718 3,760 4,358
wikitext-2-v1 36,718 3,760 4,358

The 12 Lance tables contain 3,708,608 text rows including all blank lines and vocabulary markers. The conversion verified a SHA-256 digest over the ordered text values for every split against the source Parquet shards. Row counts, model revision, and checksums

Schema

Table path Columns Contents
data/<configuration>/<split>.lance text, row_id, article_id, article_title, wikipedia_url Exact source line, zero-based row number within its split, and Wikipedia attribution from the corresponding raw article. Initial blank lines have null article fields.
search/<raw-configuration>/<split>.lance article_id, article_title, wikipedia_url, wikipedia_history_url, source_row_start, source_row_stop, embedding One vector per recognizable article, its attribution links, and its half-open range of source line numbers. article_id equals the heading row within the split.

An article boundary is a first-level title line enclosed by blank lines in the raw source. The derived tables contain 600 WikiText-2 train articles and 28,472 WikiText-103 train articles, plus 60 articles in each validation and test split. The published WikiText-103 summary reports 28,475 train articles. All publisher text rows are present in the line-level Lance tables. Original WikiText summary

Embeddings

This release generates one vector per raw article from its normalized title and up to 300 whitespace-delimited words before the first section heading. The conversion joins common WikiText punctuation tokens and removes surrounding whitespace for encoding. The source text column preserves the original data. The word-level configurations share the article mapping and row ranges for their raw counterparts.

The model is sentence-transformers/static-retrieval-mrl-en-v1, an English text retrieval encoder. This release uses the 256-dimensional Matryoshka representation as normalized float32 vectors. Queries use the same model with no prefix. Lance ranks by exact cosine distance. The example prints cosine similarity as 1 - distance, with higher scores first. Pinned model revision

Open the complete text

import lance

wiki = lance.dataset(
    "hf://datasets/lance-format/wikitext-lance/data/wikitext-103-raw-v1/train.lance"
)
print(wiki.count_rows())
print(wiki.to_table(columns=["row_id", "text"], limit=5).to_pylist())

Search the article introductions

pip install pylance==14.0.3 sentence-transformers==6.3.0
import lance
from sentence_transformers import SentenceTransformer

encoder = SentenceTransformer(
    "sentence-transformers/static-retrieval-mrl-en-v1",
    revision="f60985c706f192d45d218078e49e5a8b6f15283a",
    device="cpu",
    truncate_dim=256,
)
query = encoder.encode(
    "How did John Lennon die outside his New York apartment?",
    normalize_embeddings=True,
)
articles = lance.dataset(
    "hf://datasets/lance-format/wikitext-lance/search/wikitext-103-raw-v1/train.lance"
)
hits = articles.to_table(
    columns=["article_id", "article_title", "wikipedia_url", "source_row_start", "source_row_stop", "_distance"],
    nearest={"column": "embedding", "q": query, "k": 5, "metric": "cosine"},
)
for hit in hits.to_pylist():
    score = 1.0 - hit["_distance"]
    row_range = f"[{hit['source_row_start']}, {hit['source_row_stop']})"
    print(f"{score:.4f}\t{hit['article_id']}\t{row_range}\t{hit['article_title']}\t{hit['wikipedia_url']}")

Use source_row_start and source_row_stop with the same split's text table to retrieve the article lines. For a word-level article, open the corresponding configuration without -raw and use the same row range.

License and attribution

WikiText was collected by Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher at Salesforce from articles written by English Wikipedia contributors. This release repackages the publisher's split text in Lance and adds article attribution, search vectors, and a Parquet preview. Source dataset and licensing notices · Original release by Stephen Merity

The publisher's card describes the dataset as CC BY-SA 4.0 and lists CC BY-SA 3.0 and GFDL in its metadata. The underlying Wikipedia text retains its upstream terms, including the CC BY-SA 3.0 grant where applicable. This release uses the Creative Commons share-alike permission and distributes the repackaging and additions under CC BY-SA 4.0. CC BY-SA 4.0 · CC BY-SA 3.0 · Wikimedia attribution and licensing guidance

The Wikipedia article and edit history links credit the contributors. The Lance tables derive these links from raw WikiText titles. An attribution lookup keyed by article_title also supplies current Wikipedia page IDs and history links for 28,189 of the 28,350 distinct titles checked. It records 161 unresolved titles, which retain their title-based links in the Lance tables. The lookup resolves current pages and redirects. The preserved text comes from the 2016 WikiText corpus. Wikipedia attribution lookup · WikiText collection paper

@misc{merity2016pointer,
  title = {Pointer Sentinel Mixture Models},
  author = {Stephen Merity and Caiming Xiong and James Bradbury and Richard Socher},
  year = {2016},
  eprint = {1609.07843},
  archivePrefix = {arXiv},
  primaryClass = {cs.CL}
}