--- pretty_name: MediaWiki Code2Code Search license: other license_name: apache-2.0-tooling-plus-upstream-foss license_link: LICENSE.md language: - code task_categories: - text-retrieval - sentence-similarity - feature-extraction tags: - code - code-search - code-retrieval - semantic-search - neural-retrieval - mediawiki - wikimedia - faiss - embeddings - bm25 - swhid - software-heritage size_categories: - 1M **If you use this dataset, please cite the paper** (see [Citation](#citation)). Zenodo is the > archival home of the artifacts; the paper is the reference to cite. - **Code / system:** - **Paper:** *MediaWiki Code2Code Search: Neural Retrieval for the Semantic Discovery of Open-Source Software Entities* — Francesco Tosoni, Sant'Anna School of Advanced Studies, Pisa. A peer-reviewed version is **forthcoming in *SoftwareX***. See [Citation](#citation). --- ## Contents | File | Size | Format | Description | |---|---|---|---| | `data/train-*.parquet` (9 shards) | ~172 MiB | Parquet (zstd) | The full `snippets` table, exposed for the **dataset Viewer** and `load_dataset`. Same 1,289,452 rows as `snippets.db`. | | `snippets.db` | 1.74 GiB | SQLite | Serving metadata + code for every entity (single `snippets` table). | | `embeddings.npy` | 4.92 GiB | NumPy `float32` | Dense embeddings, shape `(1289452, 1024)`, **L2-normalised**, from `Qwen/Qwen3-Embedding-0.6B`. Row *i* aligns with `snippets.db` row `id = i`. | | `mediawiki.index` | 168.6 MiB | FAISS | `IndexIVFPQ` (L2) with an `IndexFlatL2` coarse quantizer, 128 sub-quantizers × 8 bits, dim 1024. Built over the embeddings above. | | `bm25_index.pkl` | 423.6 MiB | Pickle | BM25 lexical baseline built over the `code` field (identifier tokeniser; keywords and tokens shorter than three characters dropped). | > **Note on `.npy` / `.index` / `.pkl`:** these binary artifacts do not render in the Viewer by > design; the Parquet shards provide the browsable view of the same underlying rows. > > **Also on Zenodo only:** the raw pre-migration corpus `raw_snippets.json` (~1.75 GiB) lives in the > [Zenodo record](https://doi.org/10.5281/zenodo.20586256) but is intentionally **not** mirrored here > — its content is already captured by `snippets.db` and the Parquet shards. ### Data fields (`snippets` table / Parquet) | Column | Type | Description | |---|---|---| | `id` | int64 | Row id; aligns with the corresponding row of `embeddings.npy`. | | `original_id` | string | Upstream extraction id (content hash). | | `swhid` | string | **[SWHID](https://www.swhid.org/)** of the source content, with `origin=` and `lines=` qualifiers — resolvable on [Software Heritage](https://archive.softwareheritage.org/) for exact provenance and upstream licensing. | | `sha1` | string | SHA-1 of the source blob. | | `repo_name` | string | Upstream repository name. | | `repo_group` | string | Repository group / namespace. | | `filepath` | string | Path of the source file within the repository. | | `name` | string | Entity name / signature (e.g. `check_dumps_log_path(path)`). | | `type` | string | One of `function`, `type`, `template`. | | `code` | string | Source snippet text for the entity (see [Licensing](#licensing-important)). | ### Corpus statistics - **1,289,452** structural entities: - `function`: 1,050,748 - `type`: 237,653 - `template`: 1,051 - **2,242** active repositories (distinct `(repo_group, repo_name)` pairs) across the MediaWiki / Wikimedia ecosystem. - **12** programming languages extracted via language-specific structural parsing. - Embedding model: **`Qwen/Qwen3-Embedding-0.6B`** (1024-dim). Retrieval is nearest-neighbour by **Euclidean (L2) distance** over L2-normalised vectors. --- ## Usage Browse the corpus in the **Viewer** above, or load it programmatically. **Tabular rows (Parquet) with `datasets`:** ```python from datasets import load_dataset ds = load_dataset("ftosoni/mediawiki-code2code-search", split="train") print(ds) print(ds[0]["name"], ds[0]["type"]) print(ds[0]["swhid"]) ``` **Raw serving artifacts with `huggingface_hub`:** ```python from huggingface_hub import hf_hub_download repo = "ftosoni/mediawiki-code2code-search" db = hf_hub_download(repo, "snippets.db", repo_type="dataset") emb = hf_hub_download(repo, "embeddings.npy", repo_type="dataset") index = hf_hub_download(repo, "mediawiki.index", repo_type="dataset") bm25 = hf_hub_download(repo, "bm25_index.pkl", repo_type="dataset") import numpy as np, faiss X = np.load(emb, mmap_mode="r") # (1289452, 1024) float32, L2-normalised faiss_index = faiss.read_index(index) # IndexIVFPQ (L2) ``` `embeddings.npy` row `i` corresponds to `snippets.db` row `id = i` and to FAISS vector `i`. --- ## Licensing (important) This dataset combines two distinct layers, and they carry **different licenses**: 1. **Tooling / packaging** (schema, indexes, embeddings, this card): **Apache-2.0**, matching the canonical [Zenodo record](https://doi.org/10.5281/zenodo.20586256). 2. **The `code` snippets** in `snippets.db` / the Parquet shards are **derived from upstream MediaWiki / Wikimedia repositories**, each under **its own free/open-source license** (predominantly **GPL-2.0-or-later**, with some MIT / BSD / Apache-2.0 and others). These upstream licenses govern the snippet text; redistribution here relies on their permission to redistribute. There is **no per-row `license` column**. Instead, **every entity carries an `swhid`** with an `origin=` qualifier, so the exact upstream repository — and therefore its authoritative license and copyright — can be resolved on [Software Heritage](https://archive.softwareheritage.org/) and at the origin repository. Snippets are fragments and may not carry their file's original license header; consult the origin before reuse. See [`LICENSE.md`](LICENSE.md) for the full statement. --- ## Citation Please cite the paper: ```bibtex @misc{tosoni2026mediawikicode2codesearchneural, title = {MediaWiki Code2Code Search: Neural Retrieval for the Semantic Discovery of Open-Source Software Entities}, author = {Francesco Tosoni}, year = {2026}, eprint = {2607.26766}, archivePrefix = {arXiv}, primaryClass = {cs.IR}, url = {https://arxiv.org/abs/2607.26766} } ``` The pre-computed artifacts are archived on Zenodo: [10.5281/zenodo.20586256](https://doi.org/10.5281/zenodo.20586256). A peer-reviewed version of the paper is forthcoming in *SoftwareX*. --- ## Acknowledgements Corpus derived from the MediaWiki / Wikimedia software ecosystem. Provenance is tracked with [SWHID](https://www.swhid.org/) identifiers resolvable on [Software Heritage](https://archive.softwareheritage.org/). Embeddings computed with [`Qwen/Qwen3-Embedding-0.6B`](https://huggingface.co/Qwen/Qwen3-Embedding-0.6B); indexing with [FAISS](https://github.com/facebookresearch/faiss).