samscrack commited on
Commit
23c0b2f
·
verified ·
1 Parent(s): 23ca6ad

Initial release: 23,471 quality-filtered + deduped Solidity files (~86M tokens)

Browse files
Files changed (2) hide show
  1. README.md +193 -0
  2. top10.parquet +3 -0
README.md ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ language:
4
+ - en
5
+ - code
6
+ tags:
7
+ - solidity
8
+ - smart-contracts
9
+ - blockchain
10
+ - ethereum
11
+ - code
12
+ - continued-pretraining
13
+ - quality-filtered
14
+ size_categories:
15
+ - 10K<n<100K
16
+ task_categories:
17
+ - text-generation
18
+ - fill-mask
19
+ pretty_name: Solidity CPT Top-10% Quality-Filtered Corpus
20
+ configs:
21
+ - config_name: default
22
+ data_files:
23
+ - split: train
24
+ path: top10.parquet
25
+ ---
26
+
27
+ # Solidity CPT Top-10% Quality-Filtered Corpus
28
+
29
+ A curated, deduplicated corpus of **23,471 modern Solidity source files (~86M tokens)** intended for continued-pretraining (CPT) of code LLMs on smart-contract code.
30
+
31
+ It's the top 10% slice (by composite quality score) of a larger raw corpus that combined:
32
+
33
+ - [`ASSERT-KTH/DISL`](https://huggingface.co/datasets/ASSERT-KTH/DISL) — 514 k unique deployed Solidity files, deduped at file level
34
+ - 30 hand-picked GitHub blue-chip protocols (OpenZeppelin, Uniswap v2/v3/v4, Aave v3, Compound, Morpho, EigenLayer, Pendle, Solady, Seaport, LayerZero, ENS, Optimism, Arbitrum, Polygon L1, etc.)
35
+
36
+ After scoring all 234 877 raw rows on a 0–115 quality scale (see *Quality filter* below) and keeping the top 10 %, the result is **23 487 source files**. After cross-source SHA-256 deduplication of whitespace-normalised text, **23 471 unique files** remain. This is what's published here.
37
+
38
+ ## At a glance
39
+
40
+ | | |
41
+ |---|---|
42
+ | Rows | 23,471 |
43
+ | Total characters | 342,858,470 |
44
+ | Approx. tokens (Qwen3.6 tokenizer, ~4 chars/tok) | **~86M** |
45
+ | Average chars per row | 14,607 |
46
+ | Source: `disl` (Etherscan-verified) | 20,975 (89 %) |
47
+ | Source: `github/<protocol>` (audited blue-chips) | 2,496 (11 %) |
48
+ | File format | parquet (snappy) + jsonl |
49
+
50
+ ## Schema
51
+
52
+ Each row is one Solidity source file:
53
+
54
+ | Field | Type | Description |
55
+ |---|---|---|
56
+ | `text` | string | Raw Solidity source code |
57
+ | `source` | string | `disl` (Etherscan-verified contract) or `github/<repo-slug>` |
58
+ | `address` | string | Ethereum mainnet address (DISL only) |
59
+ | `name` | string | Contract name |
60
+ | `compiler` | string | Solc version e.g. `v0.8.20+commit.a1b2c3d4` (DISL only) |
61
+ | `license` | string | License from Etherscan (often empty) |
62
+ | `path` | string | Path inside the GitHub repo (GitHub rows only) |
63
+ | `n_chars` | int | Length of `text` in characters |
64
+
65
+ ## Quality filter (composite 0–115 score)
66
+
67
+ Every raw row was scored independently on each signal; rows scoring **≥ 55 (top-10% threshold)** were kept.
68
+
69
+ | Signal | Points |
70
+ |---|---:|
71
+ | Pragma 0.8.20+ (modern compiler) | +30 |
72
+ | Pragma 0.8.13–19 | +20 |
73
+ | Pragma 0.8.x (any) | +10 |
74
+ | Has SPDX license header | +10 |
75
+ | Has `@notice` / `@dev` NatSpec | +10 |
76
+ | Has `@param` / `@return` NatSpec | +10 |
77
+ | Comment density 5–30 % | +10 |
78
+ | Uses custom errors (`error X();`) | +5 |
79
+ | Uses `unchecked { ... }` blocks | +5 |
80
+ | No SafeMath import (avoids old patterns) | +5 |
81
+ | Size 500–8000 chars | +10 |
82
+ | Source: GitHub blue-chip | +20 |
83
+
84
+ **Pre-scoring filters** (applied to all sources before scoring):
85
+ - Pragma must be 0.8.x (0.4–0.7 dropped — incompatible with `forge-std/Test.sol >=0.8.13`)
86
+ - Not flagged as `proxy=True` in DISL (drops EIP-1167/1967 minimal proxies)
87
+ - Has at least one `contract X` declaration (drops interface-only / library-only files)
88
+ - 200 ≤ length ≤ 50000 chars (drops stubs and mega-flatteners)
89
+ - For GitHub: vendored `lib/openzeppelin-contracts`, `lib/forge-std`, `out/`, `cache/`, `typechain-types/` stripped
90
+
91
+ **Post-quality dedup**: SHA-256 of the whitespace-collapsed text. Caught 16 cross-source duplicates.
92
+
93
+ ## Score distribution of the top-10% slice
94
+
95
+ The 23 471 surviving rows have scores in [55, 115]. The mode falls in the 55–69 band (typical "modern, idiomatic, audited" Solidity). The long tail (90+) skews heavily toward GitHub blue-chips and DISL contracts that cite their license + use NatSpec extensively.
96
+
97
+ ## Suggested use
98
+
99
+ This corpus is sized for **adapter-based CPT** (LoRA / DoRA) on a 7B–30B+ code LM. Per [Biderman et al. 2024 ("LoRA Learns Less and Forgets Less")](https://arxiv.org/abs/2405.09673), useful adapter-CPT plateaus around 200M–1B tokens — this 86M corpus is on the lower end of that range and works well as a fast first-iteration validation slice.
100
+
101
+ For larger adapter-CPT runs, the same pipeline produces:
102
+ - **top30** tier (~70 k rows, ~229M tokens)
103
+ - **top60** tier (~141 k rows, ~458M tokens)
104
+
105
+ (Not yet published. Open an issue if you'd like them released.)
106
+
107
+ ## Loading
108
+
109
+ ### `datasets` library (recommended)
110
+
111
+ ```python
112
+ from datasets import load_dataset
113
+
114
+ ds = load_dataset("samscrack/solidity-cpt-top10-quality", split="train")
115
+ print(ds) # ~23 471 rows
116
+ print(ds[0]["text"][:500])
117
+ ```
118
+
119
+ ### Direct parquet
120
+
121
+ ```python
122
+ import pyarrow.parquet as pq
123
+ table = pq.read_table("top10.parquet")
124
+ df = table.to_pandas()
125
+ print(df.head())
126
+ ```
127
+
128
+ ### Streaming (for low-RAM environments)
129
+
130
+ ```python
131
+ ds = load_dataset(
132
+ "samscrack/solidity-cpt-top10-quality",
133
+ split="train",
134
+ streaming=True,
135
+ )
136
+ for row in ds.take(3):
137
+ print(row["source"], row["name"], row["compiler"])
138
+ ```
139
+
140
+ ## Suggested CPT recipe (Qwen3.6-27B reference)
141
+
142
+ This corpus was built for the [Qwopus3.6-27B-solidity-cpt-stageA](https://huggingface.co/samscrack/Qwopus3.6-27B-solidity-cpt-stageA) pipeline. The recipe used:
143
+
144
+ - LoRA r=64, α=64, target modules: `q_proj` `k_proj` `v_proj` `o_proj` `gate_proj` `up_proj` `down_proj` `out_proj`
145
+ - Megatron-style packing into 8192-token sequences with EOS separators
146
+ - LR 5e-5 (cosine), bf16 + 4-bit base (QLoRA), 1 epoch
147
+ - Tokenized with the Qwen3.6 tokenizer (vocab 152 k)
148
+
149
+ A Stage-A CPT over a 1500-sequence (~12M token) subset of this corpus showed loss drop from a warmup peak of 0.67 to a stable 0.36–0.41 plateau in ~40 steps — clear evidence the data is high-signal for adapter-CPT.
150
+
151
+ ## License & legal notes
152
+
153
+ This dataset is released under **CC BY 4.0**, inheriting the most-restrictive upstream license (DISL is CC BY 4.0).
154
+
155
+ **Per-row provenance varies**:
156
+ - DISL rows: derived from Etherscan public-verified contracts. The dataset (and DISL itself) are CC BY 4.0; **the underlying contract source has whatever license the deployer chose** — often empty / "unspecified" / all-rights-reserved by default. Suitable for research and adapter-style CPT, not necessarily safe for redistribution-as-source.
157
+ - GitHub blue-chip rows: each repo has its own SPDX header. Most are MIT or Apache-2.0; some Uniswap pieces are BUSL/GPL. Inspect the `path` field and the upstream repo if license matters for your use case.
158
+
159
+ If you need stronger commercial-use guarantees, restrict to rows where:
160
+ - `source` starts with `github/`, AND
161
+ - `text` contains an explicit MIT or Apache-2.0 SPDX line near the top.
162
+
163
+ ## Citation
164
+
165
+ ```bibtex
166
+ @misc{solidity_cpt_top10_2026,
167
+ title = {Solidity CPT Top-10\% Quality-Filtered Corpus},
168
+ author = {samscrack},
169
+ year = {2026},
170
+ url = {https://huggingface.co/datasets/samscrack/solidity-cpt-top10-quality}
171
+ }
172
+ ```
173
+
174
+ If you use this data, please also cite the upstream sources:
175
+
176
+ ```bibtex
177
+ @misc{disl_2024,
178
+ title = {DISL: Fueling Research with A Large Dataset of Solidity Smart Contracts},
179
+ author = {Storhaug, Andreas et al.},
180
+ year = {2024},
181
+ url = {https://arxiv.org/abs/2403.16861}
182
+ }
183
+ ```
184
+
185
+ ## Acknowledgements
186
+
187
+ - [ASSERT-KTH](https://huggingface.co/ASSERT-KTH) for releasing DISL
188
+ - The OpenZeppelin, Uniswap, Aave, Compound, Morpho, EigenLayer, Pendle, Solady, Seaport, LayerZero, ENS, Optimism, Arbitrum, and Polygon teams for keeping their protocol code public and auditable
189
+ - The Foundry team for forge-std (used as the `>=0.8.13` floor for pragma filtering)
190
+
191
+ ## Changelog
192
+
193
+ - **2026-05-03** — initial release; 23 471 rows, ~86M tokens, top 10% by composite quality score
top10.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:185f1ac548f0df10a8166c8a2a10610bcc3422ce77f51567c3de86ddc8f5e455
3
+ size 109124886