File size: 7,692 Bytes
ebbe603 9acbc4a ebbe603 9acbc4a ebbe603 9acbc4a ebbe603 da86066 ebbe603 9acbc4a ebbe603 9acbc4a ebbe603 9acbc4a ebbe603 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | ---
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<n<10M
source_datasets:
- original
configs:
- config_name: default
data_files:
- split: train
path: data/train-*.parquet
---
# MediaWiki Code2Code Search — Dataset
Pre-computed retrieval artifacts for **MediaWiki Code2Code Search**, a neural system for the
semantic discovery of open-source software entities (functions, types, templates) across the
MediaWiki / Wikimedia ecosystem.
This Hugging Face dataset is a **complementary mirror** of the pre-computed artifacts archived on
Zenodo ([10.5281/zenodo.20586256](https://doi.org/10.5281/zenodo.20586256)). The Hugging Face copy
makes the corpus **browsable in the dataset Viewer** and easy to pull with the `datasets` /
`huggingface_hub` libraries.
> **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:** <https://github.com/ftosoni/mediawiki-code2code-search>
- **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).
|