File size: 7,260 Bytes
f1a46ec | 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 | ---
pretty_name: Python Library Documentation Corpus for RAG & Continued Pretraining (Version-Aware)
license: cc-by-nc-4.0
language:
- en
multilinguality:
- monolingual
size_categories:
- n<1K
task_categories:
- text-generation
- text-retrieval
task_ids:
- language-modeling
- document-retrieval
annotations_creators:
- machine-generated
language_creators:
- found
source_datasets:
- original
tags:
- documentation
- python
- python-docs
- software
- code
- cpython
- continued-pretraining
- retrieval
- rag
- retrieval-augmented-generation
- version-aware
- technical-documentation
- matrixnorm
configs:
- config_name: domain_pretraining
data_files:
- split: train
path: data/domain_pretraining/train.csv
- config_name: domain_retrieval
data_files:
- split: train
path: data/domain_retrieval/train.csv
---
# Python Library Documentation Corpus for RAG & Continued Pretraining (Version-Aware)
*Release name: MatrixNorm DomainPacks software_docs v1 (free toy sample)*
**Version-aware software documentation** for continued pretraining and retrieval: the official docs of Python 3.13 and 3.12, Flask, Click, Jinja, Werkzeug and attrs, read from sha256-pinned release archives, normalized, split into heading-scoped chunks that keep code blocks whole, and de-duplicated across versions (3.12 keeps only the text that differs from 3.13). Each pretraining row carries its version context and the exact archive and character range it came from. Retrieval rows ask about a specific API symbol or section in a specific version, with the exact supporting chunk as the positive, same-document hard negatives that never mention the target, and unanswerable queries for plausible API names that exist nowhere in that project's docs.
## Free toy sample
This public repo is a deliberately tiny, CSV-only toy sample: 188 documentation chunks and 200 retrieval queries plus the rows linked to them. It is meant for looking at the schema and running a pipeline once (a toy training run), not for training a real model. The full and training-ready versions (`williamTLmiller/python-documentation-rag-corpus-full`) are private and licensed separately; contact energea@energeatech.com.
This toy sample keeps **42 whole document groups** (train groups): every chunk and every retrieval query of a
kept group, so each query's positive and hard negatives are also chunks in `domain_pretraining`. Validation and
test groups stay in the private full release so they remain unseen; every row here is train.
## Rows
| View | File | Rows (train) |
|---|---|---:|
| `domain_pretraining` | `data/domain_pretraining/train.csv` | 188 |
| `domain_retrieval` | `data/domain_retrieval/train.csv` | 200 |
| `source_attributions` | `data/source_attributions.csv` | 188 |
```python
from datasets import load_dataset
ds = load_dataset("williamTLmiller/python-documentation-rag-corpus", "domain_pretraining")
```
Every view is one plain CSV file. Nested fields (`positives`, `hard_negatives`, `source_refs`) are JSON text in
their cell: read them with `json.loads`. `source_attributions.csv` has one row per chunk (archive, revision,
license and character range).
**Views.** `domain_pretraining`: `text` (an exact slice of the normalized source file), `language`, `profile`, `version_context` (for example `Python 3.13.0`) and `source_refs` (archive URL, version plus archive sha256, license, and `path#codepoints:start:end`). `domain_retrieval`: `query`, `positives`, `hard_negatives` and `answerability` (`answerable` or `unanswerable`). For RAG evaluation, an unanswerable query has no positive, and the hard negative is the closest real passage, which does not answer it.
## What is in this toy sample
* **`domain_pretraining`:** 188 chunks (608,520 characters) by version: Python 3.13.0 112, Python 3.12.7 32, Flask 3.1.3 27, attrs 26.1.0 8, Click 8.5.0 3, Jinja 3.1.6 3, Werkzeug 3.1.9 3.
* **`domain_retrieval`:** 200 queries: `answerable` 185 (one positive each), `unanswerable`
15 (no positive); 222 hard negatives in all.
## How it was built
Sources are pinned by exact release-archive URL and sha256 (python.org and PyPI release files). Only the documentation directory of each archive is read, as text; nothing is executed. Python code examples are syntax-checked with `ast.parse` and recorded as pass or fail; they are never run. Chunks target 4,000 characters (maximum 8,000) with 300-character overlap when a long section must be split, and splits only fall on blank lines outside literal blocks, code blocks and tables. A section that cannot be split under the maximum is quarantined, never truncated. Exact duplicates (after whitespace normalization) keep the newest version. Groups = the same doc path across versions, merged with any documents that share a duplicate chunk, so the same text never lands on both sides of a split.
## Validation
Every record is checked before it is written: schema, cross-references, split membership, and the dataset-specific checks described above. A family that fails any check is quarantined as a whole, never silently dropped or partially kept.
Full-release build stats (not this toy sample): `{"chunks_exclude": 2512, "chunks_include": 4408, "chunks_quarantine": 28, "documents": 1156, "examples_not_run": 1049, "examples_syntax_fail": 1506, "examples_syntax_pass": 8380, "symbols": 17525}`
## How the toy sample was drawn
Whole document groups (train groups) only. Groups are sorted by documentation tree (Python 3.13, Python 3.12,
Flask, Click, Jinja, Werkzeug, attrs) and taken round-robin over the trees; inside a tree they go in a fixed
salted-SHA-256 order of the group id (`sha256("matrixnorm-toy-v1|" + family_id)`). A group is added only while both
views stay within 200 rows, so the pick is deterministic and every tree is represented.
## Trainability baseline
Measured on the full release's held-out splits (this toy sample is train only). TF-IDF retrieval (vectorizer fit on train pretraining text only), ranking each held-out query against that split's pooled positives and hard negatives:
| Split | Answerable queries | Pool | Recall@1 | Recall@5 | MRR | Random Recall@5 |
|---|---:|---:|---:|---:|---:|---:|
| validation | 44 | 30 | 0.250 | 0.523 | 0.374 | 0.167 |
| test | 31 | 29 | 0.484 | 0.613 | 0.563 | 0.172 |
The held-out sets are small, so treat these as a sanity check that the pairs are learnable, not as a benchmark.
## Limitations
- Seven documentation trees only; Python dominates the token count. Retrieval positives come from the symbol's own directive or section, so paraphrased or multi-hop questions are not covered.
- reStructuredText and MyST markup is kept as written (it is the source text); strip it if you need plain prose.
- Python 3.12 rows are only the chunks whose text differs from 3.13.
## Licensing
CC BY-NC 4.0 (see `LICENSE` and `NOTICE`). The license covers only the MatrixNorm packaging layer; the documentation text keeps its own PSF-2.0 / BSD-3-Clause / MIT license, copied in `source-license-copies/`. Commercial licensing: energea@energeatech.com.
## Citation
```
MatrixNorm DomainPacks software_docs v1 (free toy sample). williamTLmiller, MatrixNorm, 2026. https://huggingface.co/datasets/williamTLmiller/python-documentation-rag-corpus
```
|