datatrove-rs 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- datatrove_rs-0.1.0/Cargo.lock +320 -0
- datatrove_rs-0.1.0/Cargo.toml +15 -0
- datatrove_rs-0.1.0/PKG-INFO +207 -0
- datatrove_rs-0.1.0/README.md +166 -0
- datatrove_rs-0.1.0/crates/datatrove-core/Cargo.toml +16 -0
- datatrove_rs-0.1.0/crates/datatrove-core/data/py_unicode.json +1 -0
- datatrove_rs-0.1.0/crates/datatrove-core/src/bin/profile.rs +196 -0
- datatrove_rs-0.1.0/crates/datatrove-core/src/filters/c4.rs +146 -0
- datatrove_rs-0.1.0/crates/datatrove-core/src/filters/fineweb.rs +60 -0
- datatrove_rs-0.1.0/crates/datatrove-core/src/filters/gopher_quality.rs +105 -0
- datatrove_rs-0.1.0/crates/datatrove-core/src/filters/gopher_repetition/dup.rs +107 -0
- datatrove_rs-0.1.0/crates/datatrove-core/src/filters/gopher_repetition/joined.rs +94 -0
- datatrove_rs-0.1.0/crates/datatrove-core/src/filters/gopher_repetition/tests.rs +73 -0
- datatrove_rs-0.1.0/crates/datatrove-core/src/filters/gopher_repetition/top.rs +154 -0
- datatrove_rs-0.1.0/crates/datatrove-core/src/filters/gopher_repetition.rs +141 -0
- datatrove_rs-0.1.0/crates/datatrove-core/src/filters/mod.rs +42 -0
- datatrove_rs-0.1.0/crates/datatrove-core/src/lib.rs +9 -0
- datatrove_rs-0.1.0/crates/datatrove-core/src/minhash.rs +132 -0
- datatrove_rs-0.1.0/crates/datatrove-core/src/pystr.rs +130 -0
- datatrove_rs-0.1.0/crates/datatrove-core/src/pyunicode.rs +138 -0
- datatrove_rs-0.1.0/crates/datatrove-core/src/simplify.rs +132 -0
- datatrove_rs-0.1.0/crates/datatrove-core/src/words.rs +124 -0
- datatrove_rs-0.1.0/crates/datatrove-py/Cargo.toml +14 -0
- datatrove_rs-0.1.0/crates/datatrove-py/src/lib.rs +306 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/Cargo.toml +19 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/data/en_rules.json +1 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/src/affix/edges.rs +59 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/src/affix/fancy.rs +61 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/src/affix/mod.rs +60 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/src/affix/split.rs +309 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/src/affix/whole.rs +28 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/src/bin/affixcheck.rs +29 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/src/bin/bench.rs +118 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/src/lib.rs +33 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/src/pyalt.rs +165 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/src/pyre.rs +149 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/src/rules.rs +75 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/src/specials.rs +216 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/src/tokenizer.rs +249 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/tools/affix_ref.py +56 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/tools/compare.py +48 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/tools/export_rules.py +69 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/tools/fuzz_docs.py +38 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/tools/parity.sh +14 -0
- datatrove_rs-0.1.0/crates/spacy-tokenizer/tools/spacy_ref.py +52 -0
- datatrove_rs-0.1.0/pyproject.toml +53 -0
- datatrove_rs-0.1.0/python/datatrove_rs/__init__.py +29 -0
- datatrove_rs-0.1.0/python/datatrove_rs/__main__.py +23 -0
- datatrove_rs-0.1.0/python/datatrove_rs/_autopatch.py +5 -0
- datatrove_rs-0.1.0/python/datatrove_rs/_base.py +71 -0
- datatrove_rs-0.1.0/python/datatrove_rs/_mirror.py +65 -0
- datatrove_rs-0.1.0/python/datatrove_rs/_patching.py +46 -0
- datatrove_rs-0.1.0/python/datatrove_rs/_replacements.py +32 -0
- datatrove_rs-0.1.0/python/datatrove_rs/_run.py +118 -0
- datatrove_rs-0.1.0/python/datatrove_rs/extractors.py +24 -0
- datatrove_rs-0.1.0/python/datatrove_rs/filters.py +116 -0
- datatrove_rs-0.1.0/python/datatrove_rs/minhash.py +38 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "aho-corasick"
|
|
7
|
+
version = "1.1.5"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"memchr",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[[package]]
|
|
15
|
+
name = "bit-set"
|
|
16
|
+
version = "0.8.0"
|
|
17
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
18
|
+
checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
|
|
19
|
+
dependencies = [
|
|
20
|
+
"bit-vec",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[[package]]
|
|
24
|
+
name = "bit-vec"
|
|
25
|
+
version = "0.8.0"
|
|
26
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
|
+
checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
|
|
28
|
+
|
|
29
|
+
[[package]]
|
|
30
|
+
name = "datatrove-core"
|
|
31
|
+
version = "0.1.0"
|
|
32
|
+
dependencies = [
|
|
33
|
+
"hashbrown",
|
|
34
|
+
"regex",
|
|
35
|
+
"rustc-hash",
|
|
36
|
+
"serde",
|
|
37
|
+
"serde_json",
|
|
38
|
+
"sha1_smol",
|
|
39
|
+
"spacy-tokenizer-rs",
|
|
40
|
+
"xxhash-rust",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[[package]]
|
|
44
|
+
name = "datatrove-py"
|
|
45
|
+
version = "0.1.0"
|
|
46
|
+
dependencies = [
|
|
47
|
+
"datatrove-core",
|
|
48
|
+
"pyo3",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
[[package]]
|
|
52
|
+
name = "fancy-regex"
|
|
53
|
+
version = "0.18.0"
|
|
54
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
55
|
+
checksum = "e1e1dacd0d2082dfcf1351c4bdd566bbe89a2b263235a2b50058f1e130a47277"
|
|
56
|
+
dependencies = [
|
|
57
|
+
"bit-set",
|
|
58
|
+
"regex-automata",
|
|
59
|
+
"regex-syntax",
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
[[package]]
|
|
63
|
+
name = "hashbrown"
|
|
64
|
+
version = "0.17.1"
|
|
65
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
66
|
+
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
|
|
67
|
+
|
|
68
|
+
[[package]]
|
|
69
|
+
name = "heck"
|
|
70
|
+
version = "0.5.0"
|
|
71
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
72
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
73
|
+
|
|
74
|
+
[[package]]
|
|
75
|
+
name = "itoa"
|
|
76
|
+
version = "1.0.18"
|
|
77
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
78
|
+
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
|
79
|
+
|
|
80
|
+
[[package]]
|
|
81
|
+
name = "libc"
|
|
82
|
+
version = "0.2.189"
|
|
83
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
84
|
+
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
|
85
|
+
|
|
86
|
+
[[package]]
|
|
87
|
+
name = "memchr"
|
|
88
|
+
version = "2.8.3"
|
|
89
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
90
|
+
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
91
|
+
|
|
92
|
+
[[package]]
|
|
93
|
+
name = "once_cell"
|
|
94
|
+
version = "1.21.4"
|
|
95
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
96
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
97
|
+
|
|
98
|
+
[[package]]
|
|
99
|
+
name = "portable-atomic"
|
|
100
|
+
version = "1.15.0"
|
|
101
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
102
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
103
|
+
|
|
104
|
+
[[package]]
|
|
105
|
+
name = "proc-macro2"
|
|
106
|
+
version = "1.0.107"
|
|
107
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
108
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
109
|
+
dependencies = [
|
|
110
|
+
"unicode-ident",
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
[[package]]
|
|
114
|
+
name = "pyo3"
|
|
115
|
+
version = "0.29.2"
|
|
116
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
117
|
+
checksum = "4688ddedf473e32662b9b067670129a8afb8c18e351482c70d62ba4a88171e8b"
|
|
118
|
+
dependencies = [
|
|
119
|
+
"libc",
|
|
120
|
+
"once_cell",
|
|
121
|
+
"portable-atomic",
|
|
122
|
+
"pyo3-build-config",
|
|
123
|
+
"pyo3-ffi",
|
|
124
|
+
"pyo3-macros",
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
[[package]]
|
|
128
|
+
name = "pyo3-build-config"
|
|
129
|
+
version = "0.29.2"
|
|
130
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
131
|
+
checksum = "f41027e41b4bd03f6e60f9f417fe24a6341a6bb744edd62b6f709f2a52ea30e9"
|
|
132
|
+
dependencies = [
|
|
133
|
+
"target-lexicon",
|
|
134
|
+
]
|
|
135
|
+
|
|
136
|
+
[[package]]
|
|
137
|
+
name = "pyo3-ffi"
|
|
138
|
+
version = "0.29.2"
|
|
139
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
140
|
+
checksum = "e591a95526fead067432c3b3a33fc74770b87b1e04e73671090d9c2055a2b327"
|
|
141
|
+
dependencies = [
|
|
142
|
+
"libc",
|
|
143
|
+
"pyo3-build-config",
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
[[package]]
|
|
147
|
+
name = "pyo3-macros"
|
|
148
|
+
version = "0.29.2"
|
|
149
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
150
|
+
checksum = "73225868fc1cd84eef2c3c230ddb91273bf1de46aeb8a4248da76d32a0924a1c"
|
|
151
|
+
dependencies = [
|
|
152
|
+
"proc-macro2",
|
|
153
|
+
"pyo3-macros-backend",
|
|
154
|
+
"quote",
|
|
155
|
+
"syn 2.0.119",
|
|
156
|
+
]
|
|
157
|
+
|
|
158
|
+
[[package]]
|
|
159
|
+
name = "pyo3-macros-backend"
|
|
160
|
+
version = "0.29.2"
|
|
161
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
162
|
+
checksum = "571575aa3749fa6216757dd47d2a3e7ef360f329a40f0666a9fbd14889024952"
|
|
163
|
+
dependencies = [
|
|
164
|
+
"heck",
|
|
165
|
+
"proc-macro2",
|
|
166
|
+
"quote",
|
|
167
|
+
"syn 2.0.119",
|
|
168
|
+
]
|
|
169
|
+
|
|
170
|
+
[[package]]
|
|
171
|
+
name = "quote"
|
|
172
|
+
version = "1.0.47"
|
|
173
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
174
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
175
|
+
dependencies = [
|
|
176
|
+
"proc-macro2",
|
|
177
|
+
]
|
|
178
|
+
|
|
179
|
+
[[package]]
|
|
180
|
+
name = "regex"
|
|
181
|
+
version = "1.13.1"
|
|
182
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
183
|
+
checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
|
|
184
|
+
dependencies = [
|
|
185
|
+
"aho-corasick",
|
|
186
|
+
"memchr",
|
|
187
|
+
"regex-automata",
|
|
188
|
+
"regex-syntax",
|
|
189
|
+
]
|
|
190
|
+
|
|
191
|
+
[[package]]
|
|
192
|
+
name = "regex-automata"
|
|
193
|
+
version = "0.4.18"
|
|
194
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
195
|
+
checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
|
|
196
|
+
dependencies = [
|
|
197
|
+
"aho-corasick",
|
|
198
|
+
"memchr",
|
|
199
|
+
"regex-syntax",
|
|
200
|
+
]
|
|
201
|
+
|
|
202
|
+
[[package]]
|
|
203
|
+
name = "regex-syntax"
|
|
204
|
+
version = "0.8.11"
|
|
205
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
206
|
+
checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
|
207
|
+
|
|
208
|
+
[[package]]
|
|
209
|
+
name = "rustc-hash"
|
|
210
|
+
version = "2.1.3"
|
|
211
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
212
|
+
checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
|
|
213
|
+
|
|
214
|
+
[[package]]
|
|
215
|
+
name = "serde"
|
|
216
|
+
version = "1.0.229"
|
|
217
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
218
|
+
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
|
|
219
|
+
dependencies = [
|
|
220
|
+
"serde_core",
|
|
221
|
+
"serde_derive",
|
|
222
|
+
]
|
|
223
|
+
|
|
224
|
+
[[package]]
|
|
225
|
+
name = "serde_core"
|
|
226
|
+
version = "1.0.229"
|
|
227
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
228
|
+
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
|
|
229
|
+
dependencies = [
|
|
230
|
+
"serde_derive",
|
|
231
|
+
]
|
|
232
|
+
|
|
233
|
+
[[package]]
|
|
234
|
+
name = "serde_derive"
|
|
235
|
+
version = "1.0.229"
|
|
236
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
237
|
+
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
|
238
|
+
dependencies = [
|
|
239
|
+
"proc-macro2",
|
|
240
|
+
"quote",
|
|
241
|
+
"syn 3.0.6",
|
|
242
|
+
]
|
|
243
|
+
|
|
244
|
+
[[package]]
|
|
245
|
+
name = "serde_json"
|
|
246
|
+
version = "1.0.151"
|
|
247
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
248
|
+
checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
|
|
249
|
+
dependencies = [
|
|
250
|
+
"itoa",
|
|
251
|
+
"memchr",
|
|
252
|
+
"serde",
|
|
253
|
+
"serde_core",
|
|
254
|
+
"zmij",
|
|
255
|
+
]
|
|
256
|
+
|
|
257
|
+
[[package]]
|
|
258
|
+
name = "sha1_smol"
|
|
259
|
+
version = "1.0.1"
|
|
260
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
261
|
+
checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d"
|
|
262
|
+
|
|
263
|
+
[[package]]
|
|
264
|
+
name = "spacy-tokenizer-rs"
|
|
265
|
+
version = "0.1.0"
|
|
266
|
+
dependencies = [
|
|
267
|
+
"fancy-regex",
|
|
268
|
+
"hashbrown",
|
|
269
|
+
"regex",
|
|
270
|
+
"regex-syntax",
|
|
271
|
+
"rustc-hash",
|
|
272
|
+
"serde",
|
|
273
|
+
"serde_json",
|
|
274
|
+
]
|
|
275
|
+
|
|
276
|
+
[[package]]
|
|
277
|
+
name = "syn"
|
|
278
|
+
version = "2.0.119"
|
|
279
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
280
|
+
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
|
281
|
+
dependencies = [
|
|
282
|
+
"proc-macro2",
|
|
283
|
+
"quote",
|
|
284
|
+
"unicode-ident",
|
|
285
|
+
]
|
|
286
|
+
|
|
287
|
+
[[package]]
|
|
288
|
+
name = "syn"
|
|
289
|
+
version = "3.0.6"
|
|
290
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
291
|
+
checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee"
|
|
292
|
+
dependencies = [
|
|
293
|
+
"proc-macro2",
|
|
294
|
+
"quote",
|
|
295
|
+
"unicode-ident",
|
|
296
|
+
]
|
|
297
|
+
|
|
298
|
+
[[package]]
|
|
299
|
+
name = "target-lexicon"
|
|
300
|
+
version = "0.13.5"
|
|
301
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
302
|
+
checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
|
|
303
|
+
|
|
304
|
+
[[package]]
|
|
305
|
+
name = "unicode-ident"
|
|
306
|
+
version = "1.0.26"
|
|
307
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
308
|
+
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
|
|
309
|
+
|
|
310
|
+
[[package]]
|
|
311
|
+
name = "xxhash-rust"
|
|
312
|
+
version = "0.8.18"
|
|
313
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
314
|
+
checksum = "aee1b19627c7c60102ab80d3a9cbe18de90bfe03bfa6c3715447681f0e8c8af6"
|
|
315
|
+
|
|
316
|
+
[[package]]
|
|
317
|
+
name = "zmij"
|
|
318
|
+
version = "1.0.23"
|
|
319
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
320
|
+
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[workspace]
|
|
2
|
+
resolver = "2"
|
|
3
|
+
members = ["crates/spacy-tokenizer", "crates/datatrove-core", "crates/datatrove-py"]
|
|
4
|
+
|
|
5
|
+
[workspace.dependencies]
|
|
6
|
+
regex = "1.13"
|
|
7
|
+
rustc-hash = "2"
|
|
8
|
+
serde = { version = "1", features = ["derive"] }
|
|
9
|
+
serde_json = "1"
|
|
10
|
+
|
|
11
|
+
[profile.release]
|
|
12
|
+
opt-level = 3
|
|
13
|
+
lto = "thin"
|
|
14
|
+
codegen-units = 1
|
|
15
|
+
debug = 1
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: datatrove-rs
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Development Status :: 4 - Beta
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: Intended Audience :: Science/Research
|
|
7
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
8
|
+
Classifier: Operating System :: MacOS
|
|
9
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
10
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Rust
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
20
|
+
Requires-Dist: datatrove>=0.10.1,<0.11
|
|
21
|
+
Requires-Dist: numpy
|
|
22
|
+
Requires-Dist: regex
|
|
23
|
+
Requires-Dist: pytest ; extra == 'test'
|
|
24
|
+
Requires-Dist: pyarrow ; extra == 'test'
|
|
25
|
+
Requires-Dist: spacy>=3.8,<3.9 ; extra == 'test'
|
|
26
|
+
Requires-Dist: xxhash<4 ; extra == 'test'
|
|
27
|
+
Requires-Dist: tokenizers ; extra == 'test'
|
|
28
|
+
Requires-Dist: trafilatura-rs[trafilatura]>=0.1,<0.2 ; extra == 'trafilatura'
|
|
29
|
+
Provides-Extra: test
|
|
30
|
+
Provides-Extra: trafilatura
|
|
31
|
+
Summary: Drop-in Rust implementations of datatrove's English Gopher, C4, FineWeb filters and MinHash stage 1
|
|
32
|
+
Keywords: datatrove,llm,pretraining,data-filtering,deduplication,minhash,fineweb,rust
|
|
33
|
+
Author: Hexay
|
|
34
|
+
License: Apache-2.0
|
|
35
|
+
Requires-Python: >=3.10
|
|
36
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
37
|
+
Project-URL: Homepage, https://github.com/Hexay/datatrove-rs
|
|
38
|
+
Project-URL: Issues, https://github.com/Hexay/datatrove-rs/issues
|
|
39
|
+
Project-URL: Repository, https://github.com/Hexay/datatrove-rs
|
|
40
|
+
|
|
41
|
+
# datatrove-rs
|
|
42
|
+
|
|
43
|
+
Drop-in Rust implementations of [datatrove](https://github.com/huggingface/datatrove)'s FineWeb filter chain and
|
|
44
|
+
MinHash stage 1, for English. The outputs match datatrove's exactly: the same keep/drop decisions, drop reasons,
|
|
45
|
+
rewritten `doc.text`, stats and signature files.
|
|
46
|
+
|
|
47
|
+
| datatrove step | Rust-backed replacement |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `pipeline.filters.GopherRepetitionFilter` | `datatrove_rs.GopherRepetitionFilter` |
|
|
50
|
+
| `pipeline.filters.GopherQualityFilter` | `datatrove_rs.GopherQualityFilter` |
|
|
51
|
+
| `pipeline.filters.C4QualityFilter` | `datatrove_rs.C4QualityFilter` |
|
|
52
|
+
| `pipeline.filters.FineWebQualityFilter` | `datatrove_rs.FineWebQualityFilter` |
|
|
53
|
+
| `pipeline.dedup.MinhashDedupSignature` | `datatrove_rs.MinhashDedupSignature` |
|
|
54
|
+
| `pipeline.extractors.Trafilatura` | `datatrove_rs.extractors.Trafilatura`, with the `[trafilatura]` extra |
|
|
55
|
+
|
|
56
|
+
The Trafilatura step runs [trafilatura-rs](https://github.com/Hexay/trafilatura-rs), a byte-exact Rust port of
|
|
57
|
+
trafilatura 1.11 (`pip install "datatrove-rs[trafilatura]"`). Without it, datatrove's own Trafilatura runs. Configs
|
|
58
|
+
trafilatura-rs doesn't cover fall back to Python per step. On the FineWeb recipe, where Trafilatura is ~85% of CPU,
|
|
59
|
+
this takes the whole stage from 87.7 s to 17.3 s on 5,000 Common Crawl records (5.1x, identical output; see
|
|
60
|
+
`docs/fineweb-profile.md`).
|
|
61
|
+
|
|
62
|
+
Each class subclasses the datatrove step and takes the same arguments. `filter()` (MinHash: `get_shingles` /
|
|
63
|
+
`get_signature`) is replaced. The filters also override `run()` with an inlined copy of `BaseFilter.run()` whose stat
|
|
64
|
+
bookkeeping is cheaper but bit-for-bit identical (see `python/datatrove_rs/_run.py`); a subclass that overrides
|
|
65
|
+
`filter`, `filter_batch`, `stat_update`, `update_doc_stats` or `track_time` gets datatrove's `run()` instead.
|
|
66
|
+
|
|
67
|
+
## Adopting
|
|
68
|
+
|
|
69
|
+
`pip install datatrove-rs`, then pick one; every other datatrove step keeps running datatrove's own code.
|
|
70
|
+
|
|
71
|
+
1. **No code changes.** Set `DATATROVE_RS=1` (an installed `.pth` hook calls `patch()` at interpreter startup, so
|
|
72
|
+
executor worker processes get it too), or run the unmodified script with `python -m datatrove_rs pipeline.py`.
|
|
73
|
+
2. **One line.** `import datatrove_rs; datatrove_rs.patch()` before building the pipeline. datatrove's own import
|
|
74
|
+
paths (`datatrove.pipeline.filters.GopherQualityFilter`, ...) then hand out the Rust classes; `unpatch()` undoes it.
|
|
75
|
+
3. **Explicit imports, no patching.** `datatrove_rs.<path>` mirrors every `datatrove.<path>` module with the Rust
|
|
76
|
+
classes swapped in, so replacing `datatrove.` with `datatrove_rs.` in the imports is enough:
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from datatrove_rs.pipeline.filters import GopherQualityFilter, URLFilter # Rust, datatrove's own
|
|
80
|
+
from datatrove_rs.pipeline.readers import WarcReader # datatrove's own
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The Rust classes keep `__module__ = "datatrove_rs.*"`, so pickled pipelines (Slurm, local multiprocessing) load them
|
|
84
|
+
on workers whether or not the worker patched. Unsupported languages fall back per step, as described below.
|
|
85
|
+
|
|
86
|
+
Requires datatrove `>=0.10.1,<0.11` and Python 3.10+ (one abi3 wheel). English needs no spaCy install; spaCy is
|
|
87
|
+
only used for the non-English fallback and, when installed, to reproduce the `IS_ALPHA` quirk below.
|
|
88
|
+
|
|
89
|
+
## Speed
|
|
90
|
+
|
|
91
|
+
Single thread, 1,000 FineWeb docs (3.0 MB), median of 3 runs (`tools/dev.sh bench <fineweb.parquet> 1000 3`),
|
|
92
|
+
Ryzen 7 9700X, datatrove 0.10.1, Python 3.13:
|
|
93
|
+
|
|
94
|
+
| Step | datatrove docs/s | datatrove_rs docs/s | Speedup |
|
|
95
|
+
|---|---|---|---|
|
|
96
|
+
| GopherRepetition | 195 | 16,987 | 87x |
|
|
97
|
+
| GopherQuality | 267 | 21,087 | 79x |
|
|
98
|
+
| C4Quality | 268 | 13,119 | 49x |
|
|
99
|
+
| FineWebQuality | 268 | 23,063 | 86x |
|
|
100
|
+
| Chain (`run()`, all 4 filters) | 99 | 6,831 | 69x |
|
|
101
|
+
| MinHash stage 1 | 269 | 12,780 | 48x |
|
|
102
|
+
|
|
103
|
+
The machine was under heavy load from other processes, so absolute numbers swing between runs; compare the ratio.
|
|
104
|
+
All filters on a thread share one tokenizer state and the last doc's tokens (see `words.rs`).
|
|
105
|
+
|
|
106
|
+
Where the time goes (`profile <docs.bin> [reps] [stage]`, `tools/icount.sh`): the spaCy-compatible tokenizer still
|
|
107
|
+
dominates (~45 µs/doc streamed). It runs about three times per doc in the chain: whole doc, C4's per-line sentence
|
|
108
|
+
split, and FineWeb on C4's rewritten text (mostly chunk-cache hits). Python `run()` plumbing is about
|
|
109
|
+
60% cheaper than datatrove's `BaseFilter.run()` (`tools/profile_chain.py <fineweb.parquet>`: 99k vs 249k Python calls
|
|
110
|
+
for the 4-step chain over 1,000 docs).
|
|
111
|
+
|
|
112
|
+
## Parity
|
|
113
|
+
|
|
114
|
+
Every check compares against datatrove running unmodified in the same environment.
|
|
115
|
+
|
|
116
|
+
- `tools/dev.sh parity <fineweb.parquet> --real 6000 --fuzz 3000 --random-configs 3` runs 10,500 docs: 6,000 real
|
|
117
|
+
FineWeb docs, 1,500 perturbed copies and 3,000 fuzzed docs (Unicode edge cases, separators, repetition). It covers
|
|
118
|
+
9 fixed filter configs, 12 random-threshold configs and 5 MinHash configs (xxhash 32/64, sha1 32/64, 3-gram with
|
|
119
|
+
4x6 buckets, dates/raw normalisation). It compares:
|
|
120
|
+
- the per-doc result, or the raised exception type;
|
|
121
|
+
- the rewritten `doc.text`;
|
|
122
|
+
- the `run()` output, every stat field (`repr`, so int vs float counts), the time-stat count and unit, and what
|
|
123
|
+
the exclusion writer receives, at batch sizes 1 to 5;
|
|
124
|
+
- the MinHash signature files, byte for byte.
|
|
125
|
+
|
|
126
|
+
Last run (`--real 4000 --fuzz 2000 --random-configs 3`): **0 mismatches across all 26 cases.** Pass `--workers N --cache DIR` to parallelise and cache the
|
|
127
|
+
datatrove side.
|
|
128
|
+
- `tools/dev.sh test` (pytest) runs the parity cases on a smaller corpus. It also covers `simplify_text`, word
|
|
129
|
+
splitting and sentence splitting on 2,500 random Unicode strings across 17 normalisation configs, the fallback for
|
|
130
|
+
non-English languages, and pickling.
|
|
131
|
+
|
|
132
|
+
### How exactness is kept, and its limits
|
|
133
|
+
|
|
134
|
+
- **Unicode tables.** Python's `str.isspace`/`isalpha`/`lower`, `unicodedata` NFD and categories, `re`'s `\d`/`\s`,
|
|
135
|
+
and the `regex` module's `\p{Nd}` are exported from Python into `crates/datatrove-core/data/py_unicode.json` by
|
|
136
|
+
`tools/export_pytext.py`. The shipped tables come from Python 3.13 (Unicode 15.1). On import, the package warns if
|
|
137
|
+
the running Python uses a different Unicode version, since results could then differ on rare characters.
|
|
138
|
+
- **Language.** The Rust path runs only when datatrove would use a plain `spacy.blank("en")` tokenizer. That covers
|
|
139
|
+
`eng` and every language code datatrove maps to it. Other languages run datatrove's Python code unchanged.
|
|
140
|
+
- **The `IS_ALPHA` token.** Inside `memory_zone`, spaCy 3.8 raises an error on the token `IS_ALPHA` once the same
|
|
141
|
+
process has seen that token before, and datatrove then retokenizes the text without it. The result depends on
|
|
142
|
+
process history, so when spaCy is installed any doc containing `IS_ALPHA` runs through datatrove itself.
|
|
143
|
+
Without spaCy, datatrove could not run at all and Rust handles these docs as spaCy would on first sight.
|
|
144
|
+
- **Reproduced quirks.**
|
|
145
|
+
- `Counter.most_common` tie-breaking;
|
|
146
|
+
- the `"".join` n-gram keys in `find_all_duplicate`;
|
|
147
|
+
- `ZeroDivisionError` on degenerate docs;
|
|
148
|
+
- the one-sentence result for empty text;
|
|
149
|
+
- numpy `uint64` wrap-around in the MinHash permutation.
|
|
150
|
+
|
|
151
|
+
### datatrove 0.10.0 issues found along the way
|
|
152
|
+
|
|
153
|
+
- `utils/text.py` imports `regex` without declaring it (this package depends on `regex` for that reason).
|
|
154
|
+
- The Python MinHash passes `str` to `xxhash`, which xxhash 4 rejects. The reference side needs `xxhash<4`; this
|
|
155
|
+
package's MinHash is unaffected.
|
|
156
|
+
- `importlib.metadata` is used without being imported, and `pipeline.dedup` requires `tokenizers`. For the latter,
|
|
157
|
+
`datatrove_rs.MinhashDedupSignature` is imported lazily, so filter-only installs don't need `tokenizers`.
|
|
158
|
+
|
|
159
|
+
## Layout
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
crates/spacy-tokenizer spaCy English tokenizer port (prefix/suffix/infix rules, specials, URL matcher, chunk cache)
|
|
163
|
+
crates/datatrove-core filters, MinHash, Python-compatible str/Unicode helpers, `profile` binary
|
|
164
|
+
crates/datatrove-py PyO3 bindings (datatrove_rs._core)
|
|
165
|
+
python/datatrove_rs datatrove subclasses and fallback logic
|
|
166
|
+
tools/ dev.sh, parity/bench harnesses, fuzzers, Unicode table exporter
|
|
167
|
+
tests/ pytest parity suite
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Development
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
uv venv -p 3.13 .venv && uv pip install -p .venv/bin/python maturin -e ".[test]"
|
|
174
|
+
tools/dev.sh build # maturin develop --release
|
|
175
|
+
tools/dev.sh test # pytest
|
|
176
|
+
tools/dev.sh parity <parquet> ... # large parity run
|
|
177
|
+
tools/dev.sh bench <parquet> [n] [reps]
|
|
178
|
+
tools/icount.sh <docs.bin> <stage>... # instructions + cycles/doc per `profile` stage
|
|
179
|
+
crates/spacy-tokenizer/tools/parity.sh <docs.bin> # tokenizer vs spaCy, token spans
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Use Python 3.13 so the running Unicode version matches the shipped tables. To test against an upstream checkout,
|
|
183
|
+
add `-e <path-to-datatrove>` to the install. `docs.bin` is UTF-8 docs joined by `\0`.
|
|
184
|
+
|
|
185
|
+
Wall time is unreliable on a loaded machine; A/B Rust changes with `tools/icount.sh` (instruction counts are
|
|
186
|
+
load-independent) and confirm wall time by alternating old/new binaries.
|
|
187
|
+
|
|
188
|
+
After upgrading Python or `regex`, re-export the Unicode tables with `tools/export_pytext.py`.
|
|
189
|
+
|
|
190
|
+
Rust code is formatted with the repo's `rustfmt.toml`; CI (`.github/workflows/ci.yml`) runs `cargo fmt --check`,
|
|
191
|
+
`clippy -D warnings`, `cargo test --release` and the pytest suite on Python 3.13 against datatrove 0.10.1 and the
|
|
192
|
+
latest 0.10.x.
|
|
193
|
+
|
|
194
|
+
## Releasing
|
|
195
|
+
|
|
196
|
+
1. Bump `version` in `pyproject.toml` (the published version; the crate versions don't matter) and merge to `master`.
|
|
197
|
+
2. Tag and push: `git tag v0.1.0 && git push origin v0.1.0`. The tag must equal `v` + the pyproject version.
|
|
198
|
+
3. `.github/workflows/release.yml` builds abi3 wheels (Linux x86_64/aarch64 manylinux_2_28, macOS x86_64/arm64,
|
|
199
|
+
Windows x64) and an sdist, import-tests each, and publishes to PyPI by trusted publishing.
|
|
200
|
+
|
|
201
|
+
One-time setup:
|
|
202
|
+
|
|
203
|
+
- PyPI: on https://pypi.org/manage/account/publishing/ add a pending publisher (or, once the project exists,
|
|
204
|
+
Manage project > Publishing): PyPI project name `datatrove-rs`, owner `Hexay`, repository `datatrove-rs`, workflow
|
|
205
|
+
`release.yml`, environment `pypi`.
|
|
206
|
+
- GitHub: Settings > Environments > New environment `pypi` (optionally with required reviewers and a `v*` tag rule).
|
|
207
|
+
|