ldup 2.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.
ldup-2.1.0/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024- ABrain One and contributors
4
+ All rights reserved.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
ldup-2.1.0/PKG-INFO ADDED
@@ -0,0 +1,239 @@
1
+ Metadata-Version: 2.4
2
+ Name: ldup
3
+ Version: 2.1.0
4
+ Summary: Prefix-aware curation & near-dedup for NN code via MinHash/LSH and AST fingerprints.
5
+ Author: Your Team
6
+ Author-email: ABrain One and contributors <AI@ABrain.one>
7
+ License: MIT License
8
+
9
+ Copyright (c) 2024- ABrain One and contributors
10
+ All rights reserved.
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+
30
+ Project-URL: Homepage, https://ABrain.one
31
+ Project-URL: Repository, https://github.com/ABrain-One/nn-dup
32
+ Classifier: Programming Language :: Python :: 3
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Operating System :: OS Independent
35
+ Requires-Python: >=3.9
36
+ Description-Content-Type: text/markdown
37
+ License-File: LICENSE
38
+ Requires-Dist: nn-dup==2.1.0
39
+ Dynamic: author
40
+ Dynamic: license-file
41
+ Dynamic: requires-python
42
+
43
+ # Neural Network Deduplication Pipeline (NN Dup)
44
+ <sub><a href='https://pypi.python.org/pypi/nn-dup'><img src='https://img.shields.io/pypi/v/nn-dup.svg'/></a> <a href="https://pepy.tech/project/nn-dup"><img alt="GitHub release" src="https://static.pepy.tech/badge/nn-dup"></a><br/>
45
+ short alias <a href='https://pypi.python.org/pypi/ldup'>ldup</a></sub>
46
+
47
+ A sophisticated data curation and near-deduplication pipeline for neural network code from the LEMUR dataset. This project implements prefix-aware exact/near/AST deduplication with diversity top-up capabilities.
48
+
49
+ The original version of the NN Dup project was created by <strong>Waleed Khalid</strong> at the Computer Vision Laboratory, University of Würzburg, Germany.
50
+
51
+ ## Overview
52
+
53
+ This pipeline processes neural network implementations from the LEMUR dataset, performing:
54
+ - **Exact deduplication** with prefix-aware canonicalization
55
+ - **Lexical near-deduplication** using MinHash and LSH
56
+ - **Structural deduplication** using AST fingerprints
57
+ - **Diversity top-up** for underrepresented model families
58
+ - **Family-aware train/dev/test splits**
59
+
60
+ ## Features
61
+
62
+ - **Multi-level Deduplication**: Exact, lexical (MinHash+LSH), and structural (AST) deduplication
63
+ - **Prefix-aware Processing**: Maintains representation across different model families
64
+ - **Family-aware Splits**: Ensures proper train/dev/test separation by model families
65
+ - **Diversity Top-up**: Intelligently adds diverse samples for underrepresented prefixes
66
+ - **Comprehensive Reporting**: Detailed statistics and curation reports
67
+ - **Code Export**: Exports deduplicated code files for further use
68
+
69
+ ## Installation
70
+
71
+ ### Prerequisites
72
+ - Python 3.9+
73
+ - CUDA 12.6 (for PyTorch compatibility)
74
+
75
+ ### Setup
76
+
77
+ 1. **Create and activate virtual environment**:
78
+ ```bash
79
+ python3 -m venv .venv
80
+ source .venv/bin/activate # Linux/Mac
81
+ # or
82
+ .venv\Scripts\activate # Windows
83
+ ```
84
+
85
+ 2. **Install dependencies**:
86
+ ```bash
87
+ pip install -r requirements.txt
88
+ ```
89
+
90
+ 3. **Install the package in development mode**:
91
+ ```bash
92
+ pip install -e .
93
+ ```
94
+
95
+ ### Install directly from GitHub
96
+
97
+ Install the latest version directly from the GitHub repository:
98
+
99
+ ```bash
100
+ pip install git+https://github.com/ABrain-One/nn-dup.git
101
+ ```
102
+
103
+ ## Usage
104
+
105
+ ### Basic Usage
106
+
107
+ Run the deduplication pipeline with default settings:
108
+
109
+ ```bash
110
+ python -m ab.dup.preprocessing --out ./curation_output
111
+ ```
112
+
113
+ ### Advanced Usage
114
+
115
+ Filter for specific model families and configure deduplication:
116
+
117
+ ```bash
118
+ python -m ab.dup.preprocessing \
119
+ --out ./curation_output \
120
+ --include FractalNet \
121
+ --include ResNet \
122
+ --min-per-prefix 10 \
123
+ --keep-per-family 5 \
124
+ --lex-thresh-fractal 0.97 \
125
+ --verbose
126
+ ```
127
+
128
+ ### Command Line Options
129
+
130
+ - `--out`: Output directory (default: `./curation_output`)
131
+ - `--include`: Prefix filters for model names (repeatable)
132
+ - `--prefer-prefix-order`: Priority order for canonicalization
133
+ - `--min-per-prefix`: Minimum records per prefix after dedup
134
+ - `--keep-per-family`: Maximum exemplars per family in clusters
135
+ - `--lex-thresh-fractal`: Jaccard threshold for FractalNet family
136
+ - `--topup-prefix`: Enable diversity top-up for specific prefixes
137
+ - `--topup-per-prefix`: Maximum top-up records per prefix
138
+ - `--topup-lex-max`: Maximum lexical similarity for top-up
139
+ - `--topup-struct-max`: Maximum structural similarity for top-up
140
+ - `--dump-accepted-code-dir`: Subdirectory for exported code files
141
+ - `--upweight`: Sampling weight rules (PREFIX:FACTOR)
142
+ - `--verbose`: Enable verbose logging
143
+
144
+ ## Configuration
145
+
146
+ Key parameters in `ab/dup/consts/settings.py`:
147
+
148
+ - `SHINGLE_K = 10`: Token shingle length
149
+ - `NUM_PERM = 256`: MinHash permutations
150
+ - `LSH_THRESH = 0.85`: LSH retrieval threshold
151
+ - `JACCARD_THRESH_LEX = 0.90`: Lexical similarity threshold
152
+ - `JACCARD_THRESH_STRUCT = 0.90`: Structural similarity threshold
153
+ - `SPLIT_RATIOS = (0.80, 0.10, 0.10)`: Train/dev/test ratios
154
+
155
+ ## Output Files
156
+
157
+ The pipeline generates several output files:
158
+
159
+ - **`kept_records.json`**: Metadata for kept records
160
+ - **`tombstones.json`**: Metadata for removed records
161
+ - **`splits.json`**: Train/dev/test assignments
162
+ - **`dedup_report.md`**: Comprehensive curation report
163
+ - **`accepted_code/`**: Directory with deduplicated Python files
164
+ - **`sampling_weights.csv`**: Optional sampling weights
165
+
166
+ ## Example Report
167
+
168
+ ```
169
+ # Curation Report (LEMUR API)
170
+
171
+ ## Summary
172
+ - Total rows fetched from LEMUR: **115,127**
173
+ - Exact duplicates removed: **104,804**
174
+ - Lexical near-duplicates removed: **8,939**
175
+ - Structural duplicates removed: **320**
176
+ - **Kept for training/eval:** **1,064** records
177
+
178
+ ## Parameters
179
+ - Shingle length (k): `10`, MinHash permutations: `256`
180
+ - Lexical Jaccard verify (generic): `0.9`, (Fractal): `0.97`
181
+ - Keep per family (K): `5`, Min per prefix: `1`
182
+ - Train/dev/test ratios: `(0.8, 0.1, 0.1)`
183
+ ```
184
+
185
+ ## Development
186
+
187
+ ### Running Tests
188
+
189
+ ```bash
190
+ python -m ab.dup.preprocessing --help
191
+ ```
192
+
193
+ ### Code Quality
194
+
195
+ ```bash
196
+ pip install -e ".[dev]"
197
+ black ab/
198
+ isort ab/
199
+ flake8 ab/
200
+ ```
201
+
202
+ ## Dependencies
203
+
204
+ - `nn-dataset>=2.1.0`: LEMUR dataset access
205
+ - `datasketch`: MinHash and LSH implementations
206
+ - `pandas>=1.3,<3.0`: Data manipulation
207
+ - `scipy`: Scientific computing
208
+ - `scikit-learn`: Machine learning utilities
209
+
210
+ ## License
211
+
212
+ MIT License - see LICENSE file for details.
213
+
214
+ ## Contributing
215
+
216
+ 1. Fork the repository
217
+ 2. Create a feature branch
218
+ 3. Make your changes
219
+ 4. Add tests if applicable
220
+ 5. Submit a pull request
221
+
222
+ ## Citation
223
+
224
+ If you use this pipeline in your research, please cite:
225
+
226
+ ```bibtex
227
+ @software{nn_dup_2025,
228
+ title={Neural Network Deduplication Pipeline},
229
+ author={Waleed Khalid},
230
+ year={2025},
231
+ url={https://github.com/your-org/nn-dup}
232
+ }
233
+ ```
234
+
235
+ ## Acknowledgments
236
+
237
+ - Built for the LEMUR dataset and NNGPT projects
238
+ - Developed at the Computer Vision Laboratory, University of Würzburg
239
+ - Part of the ABrain One research initiative
ldup-2.1.0/README.md ADDED
@@ -0,0 +1,197 @@
1
+ # Neural Network Deduplication Pipeline (NN Dup)
2
+ <sub><a href='https://pypi.python.org/pypi/nn-dup'><img src='https://img.shields.io/pypi/v/nn-dup.svg'/></a> <a href="https://pepy.tech/project/nn-dup"><img alt="GitHub release" src="https://static.pepy.tech/badge/nn-dup"></a><br/>
3
+ short alias <a href='https://pypi.python.org/pypi/ldup'>ldup</a></sub>
4
+
5
+ A sophisticated data curation and near-deduplication pipeline for neural network code from the LEMUR dataset. This project implements prefix-aware exact/near/AST deduplication with diversity top-up capabilities.
6
+
7
+ The original version of the NN Dup project was created by <strong>Waleed Khalid</strong> at the Computer Vision Laboratory, University of Würzburg, Germany.
8
+
9
+ ## Overview
10
+
11
+ This pipeline processes neural network implementations from the LEMUR dataset, performing:
12
+ - **Exact deduplication** with prefix-aware canonicalization
13
+ - **Lexical near-deduplication** using MinHash and LSH
14
+ - **Structural deduplication** using AST fingerprints
15
+ - **Diversity top-up** for underrepresented model families
16
+ - **Family-aware train/dev/test splits**
17
+
18
+ ## Features
19
+
20
+ - **Multi-level Deduplication**: Exact, lexical (MinHash+LSH), and structural (AST) deduplication
21
+ - **Prefix-aware Processing**: Maintains representation across different model families
22
+ - **Family-aware Splits**: Ensures proper train/dev/test separation by model families
23
+ - **Diversity Top-up**: Intelligently adds diverse samples for underrepresented prefixes
24
+ - **Comprehensive Reporting**: Detailed statistics and curation reports
25
+ - **Code Export**: Exports deduplicated code files for further use
26
+
27
+ ## Installation
28
+
29
+ ### Prerequisites
30
+ - Python 3.9+
31
+ - CUDA 12.6 (for PyTorch compatibility)
32
+
33
+ ### Setup
34
+
35
+ 1. **Create and activate virtual environment**:
36
+ ```bash
37
+ python3 -m venv .venv
38
+ source .venv/bin/activate # Linux/Mac
39
+ # or
40
+ .venv\Scripts\activate # Windows
41
+ ```
42
+
43
+ 2. **Install dependencies**:
44
+ ```bash
45
+ pip install -r requirements.txt
46
+ ```
47
+
48
+ 3. **Install the package in development mode**:
49
+ ```bash
50
+ pip install -e .
51
+ ```
52
+
53
+ ### Install directly from GitHub
54
+
55
+ Install the latest version directly from the GitHub repository:
56
+
57
+ ```bash
58
+ pip install git+https://github.com/ABrain-One/nn-dup.git
59
+ ```
60
+
61
+ ## Usage
62
+
63
+ ### Basic Usage
64
+
65
+ Run the deduplication pipeline with default settings:
66
+
67
+ ```bash
68
+ python -m ab.dup.preprocessing --out ./curation_output
69
+ ```
70
+
71
+ ### Advanced Usage
72
+
73
+ Filter for specific model families and configure deduplication:
74
+
75
+ ```bash
76
+ python -m ab.dup.preprocessing \
77
+ --out ./curation_output \
78
+ --include FractalNet \
79
+ --include ResNet \
80
+ --min-per-prefix 10 \
81
+ --keep-per-family 5 \
82
+ --lex-thresh-fractal 0.97 \
83
+ --verbose
84
+ ```
85
+
86
+ ### Command Line Options
87
+
88
+ - `--out`: Output directory (default: `./curation_output`)
89
+ - `--include`: Prefix filters for model names (repeatable)
90
+ - `--prefer-prefix-order`: Priority order for canonicalization
91
+ - `--min-per-prefix`: Minimum records per prefix after dedup
92
+ - `--keep-per-family`: Maximum exemplars per family in clusters
93
+ - `--lex-thresh-fractal`: Jaccard threshold for FractalNet family
94
+ - `--topup-prefix`: Enable diversity top-up for specific prefixes
95
+ - `--topup-per-prefix`: Maximum top-up records per prefix
96
+ - `--topup-lex-max`: Maximum lexical similarity for top-up
97
+ - `--topup-struct-max`: Maximum structural similarity for top-up
98
+ - `--dump-accepted-code-dir`: Subdirectory for exported code files
99
+ - `--upweight`: Sampling weight rules (PREFIX:FACTOR)
100
+ - `--verbose`: Enable verbose logging
101
+
102
+ ## Configuration
103
+
104
+ Key parameters in `ab/dup/consts/settings.py`:
105
+
106
+ - `SHINGLE_K = 10`: Token shingle length
107
+ - `NUM_PERM = 256`: MinHash permutations
108
+ - `LSH_THRESH = 0.85`: LSH retrieval threshold
109
+ - `JACCARD_THRESH_LEX = 0.90`: Lexical similarity threshold
110
+ - `JACCARD_THRESH_STRUCT = 0.90`: Structural similarity threshold
111
+ - `SPLIT_RATIOS = (0.80, 0.10, 0.10)`: Train/dev/test ratios
112
+
113
+ ## Output Files
114
+
115
+ The pipeline generates several output files:
116
+
117
+ - **`kept_records.json`**: Metadata for kept records
118
+ - **`tombstones.json`**: Metadata for removed records
119
+ - **`splits.json`**: Train/dev/test assignments
120
+ - **`dedup_report.md`**: Comprehensive curation report
121
+ - **`accepted_code/`**: Directory with deduplicated Python files
122
+ - **`sampling_weights.csv`**: Optional sampling weights
123
+
124
+ ## Example Report
125
+
126
+ ```
127
+ # Curation Report (LEMUR API)
128
+
129
+ ## Summary
130
+ - Total rows fetched from LEMUR: **115,127**
131
+ - Exact duplicates removed: **104,804**
132
+ - Lexical near-duplicates removed: **8,939**
133
+ - Structural duplicates removed: **320**
134
+ - **Kept for training/eval:** **1,064** records
135
+
136
+ ## Parameters
137
+ - Shingle length (k): `10`, MinHash permutations: `256`
138
+ - Lexical Jaccard verify (generic): `0.9`, (Fractal): `0.97`
139
+ - Keep per family (K): `5`, Min per prefix: `1`
140
+ - Train/dev/test ratios: `(0.8, 0.1, 0.1)`
141
+ ```
142
+
143
+ ## Development
144
+
145
+ ### Running Tests
146
+
147
+ ```bash
148
+ python -m ab.dup.preprocessing --help
149
+ ```
150
+
151
+ ### Code Quality
152
+
153
+ ```bash
154
+ pip install -e ".[dev]"
155
+ black ab/
156
+ isort ab/
157
+ flake8 ab/
158
+ ```
159
+
160
+ ## Dependencies
161
+
162
+ - `nn-dataset>=2.1.0`: LEMUR dataset access
163
+ - `datasketch`: MinHash and LSH implementations
164
+ - `pandas>=1.3,<3.0`: Data manipulation
165
+ - `scipy`: Scientific computing
166
+ - `scikit-learn`: Machine learning utilities
167
+
168
+ ## License
169
+
170
+ MIT License - see LICENSE file for details.
171
+
172
+ ## Contributing
173
+
174
+ 1. Fork the repository
175
+ 2. Create a feature branch
176
+ 3. Make your changes
177
+ 4. Add tests if applicable
178
+ 5. Submit a pull request
179
+
180
+ ## Citation
181
+
182
+ If you use this pipeline in your research, please cite:
183
+
184
+ ```bibtex
185
+ @software{nn_dup_2025,
186
+ title={Neural Network Deduplication Pipeline},
187
+ author={Waleed Khalid},
188
+ year={2025},
189
+ url={https://github.com/your-org/nn-dup}
190
+ }
191
+ ```
192
+
193
+ ## Acknowledgments
194
+
195
+ - Built for the LEMUR dataset and NNGPT projects
196
+ - Developed at the Computer Vision Laboratory, University of Würzburg
197
+ - Part of the ABrain One research initiative
@@ -0,0 +1,239 @@
1
+ Metadata-Version: 2.4
2
+ Name: ldup
3
+ Version: 2.1.0
4
+ Summary: Prefix-aware curation & near-dedup for NN code via MinHash/LSH and AST fingerprints.
5
+ Author: Your Team
6
+ Author-email: ABrain One and contributors <AI@ABrain.one>
7
+ License: MIT License
8
+
9
+ Copyright (c) 2024- ABrain One and contributors
10
+ All rights reserved.
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+
30
+ Project-URL: Homepage, https://ABrain.one
31
+ Project-URL: Repository, https://github.com/ABrain-One/nn-dup
32
+ Classifier: Programming Language :: Python :: 3
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Operating System :: OS Independent
35
+ Requires-Python: >=3.9
36
+ Description-Content-Type: text/markdown
37
+ License-File: LICENSE
38
+ Requires-Dist: nn-dup==2.1.0
39
+ Dynamic: author
40
+ Dynamic: license-file
41
+ Dynamic: requires-python
42
+
43
+ # Neural Network Deduplication Pipeline (NN Dup)
44
+ <sub><a href='https://pypi.python.org/pypi/nn-dup'><img src='https://img.shields.io/pypi/v/nn-dup.svg'/></a> <a href="https://pepy.tech/project/nn-dup"><img alt="GitHub release" src="https://static.pepy.tech/badge/nn-dup"></a><br/>
45
+ short alias <a href='https://pypi.python.org/pypi/ldup'>ldup</a></sub>
46
+
47
+ A sophisticated data curation and near-deduplication pipeline for neural network code from the LEMUR dataset. This project implements prefix-aware exact/near/AST deduplication with diversity top-up capabilities.
48
+
49
+ The original version of the NN Dup project was created by <strong>Waleed Khalid</strong> at the Computer Vision Laboratory, University of Würzburg, Germany.
50
+
51
+ ## Overview
52
+
53
+ This pipeline processes neural network implementations from the LEMUR dataset, performing:
54
+ - **Exact deduplication** with prefix-aware canonicalization
55
+ - **Lexical near-deduplication** using MinHash and LSH
56
+ - **Structural deduplication** using AST fingerprints
57
+ - **Diversity top-up** for underrepresented model families
58
+ - **Family-aware train/dev/test splits**
59
+
60
+ ## Features
61
+
62
+ - **Multi-level Deduplication**: Exact, lexical (MinHash+LSH), and structural (AST) deduplication
63
+ - **Prefix-aware Processing**: Maintains representation across different model families
64
+ - **Family-aware Splits**: Ensures proper train/dev/test separation by model families
65
+ - **Diversity Top-up**: Intelligently adds diverse samples for underrepresented prefixes
66
+ - **Comprehensive Reporting**: Detailed statistics and curation reports
67
+ - **Code Export**: Exports deduplicated code files for further use
68
+
69
+ ## Installation
70
+
71
+ ### Prerequisites
72
+ - Python 3.9+
73
+ - CUDA 12.6 (for PyTorch compatibility)
74
+
75
+ ### Setup
76
+
77
+ 1. **Create and activate virtual environment**:
78
+ ```bash
79
+ python3 -m venv .venv
80
+ source .venv/bin/activate # Linux/Mac
81
+ # or
82
+ .venv\Scripts\activate # Windows
83
+ ```
84
+
85
+ 2. **Install dependencies**:
86
+ ```bash
87
+ pip install -r requirements.txt
88
+ ```
89
+
90
+ 3. **Install the package in development mode**:
91
+ ```bash
92
+ pip install -e .
93
+ ```
94
+
95
+ ### Install directly from GitHub
96
+
97
+ Install the latest version directly from the GitHub repository:
98
+
99
+ ```bash
100
+ pip install git+https://github.com/ABrain-One/nn-dup.git
101
+ ```
102
+
103
+ ## Usage
104
+
105
+ ### Basic Usage
106
+
107
+ Run the deduplication pipeline with default settings:
108
+
109
+ ```bash
110
+ python -m ab.dup.preprocessing --out ./curation_output
111
+ ```
112
+
113
+ ### Advanced Usage
114
+
115
+ Filter for specific model families and configure deduplication:
116
+
117
+ ```bash
118
+ python -m ab.dup.preprocessing \
119
+ --out ./curation_output \
120
+ --include FractalNet \
121
+ --include ResNet \
122
+ --min-per-prefix 10 \
123
+ --keep-per-family 5 \
124
+ --lex-thresh-fractal 0.97 \
125
+ --verbose
126
+ ```
127
+
128
+ ### Command Line Options
129
+
130
+ - `--out`: Output directory (default: `./curation_output`)
131
+ - `--include`: Prefix filters for model names (repeatable)
132
+ - `--prefer-prefix-order`: Priority order for canonicalization
133
+ - `--min-per-prefix`: Minimum records per prefix after dedup
134
+ - `--keep-per-family`: Maximum exemplars per family in clusters
135
+ - `--lex-thresh-fractal`: Jaccard threshold for FractalNet family
136
+ - `--topup-prefix`: Enable diversity top-up for specific prefixes
137
+ - `--topup-per-prefix`: Maximum top-up records per prefix
138
+ - `--topup-lex-max`: Maximum lexical similarity for top-up
139
+ - `--topup-struct-max`: Maximum structural similarity for top-up
140
+ - `--dump-accepted-code-dir`: Subdirectory for exported code files
141
+ - `--upweight`: Sampling weight rules (PREFIX:FACTOR)
142
+ - `--verbose`: Enable verbose logging
143
+
144
+ ## Configuration
145
+
146
+ Key parameters in `ab/dup/consts/settings.py`:
147
+
148
+ - `SHINGLE_K = 10`: Token shingle length
149
+ - `NUM_PERM = 256`: MinHash permutations
150
+ - `LSH_THRESH = 0.85`: LSH retrieval threshold
151
+ - `JACCARD_THRESH_LEX = 0.90`: Lexical similarity threshold
152
+ - `JACCARD_THRESH_STRUCT = 0.90`: Structural similarity threshold
153
+ - `SPLIT_RATIOS = (0.80, 0.10, 0.10)`: Train/dev/test ratios
154
+
155
+ ## Output Files
156
+
157
+ The pipeline generates several output files:
158
+
159
+ - **`kept_records.json`**: Metadata for kept records
160
+ - **`tombstones.json`**: Metadata for removed records
161
+ - **`splits.json`**: Train/dev/test assignments
162
+ - **`dedup_report.md`**: Comprehensive curation report
163
+ - **`accepted_code/`**: Directory with deduplicated Python files
164
+ - **`sampling_weights.csv`**: Optional sampling weights
165
+
166
+ ## Example Report
167
+
168
+ ```
169
+ # Curation Report (LEMUR API)
170
+
171
+ ## Summary
172
+ - Total rows fetched from LEMUR: **115,127**
173
+ - Exact duplicates removed: **104,804**
174
+ - Lexical near-duplicates removed: **8,939**
175
+ - Structural duplicates removed: **320**
176
+ - **Kept for training/eval:** **1,064** records
177
+
178
+ ## Parameters
179
+ - Shingle length (k): `10`, MinHash permutations: `256`
180
+ - Lexical Jaccard verify (generic): `0.9`, (Fractal): `0.97`
181
+ - Keep per family (K): `5`, Min per prefix: `1`
182
+ - Train/dev/test ratios: `(0.8, 0.1, 0.1)`
183
+ ```
184
+
185
+ ## Development
186
+
187
+ ### Running Tests
188
+
189
+ ```bash
190
+ python -m ab.dup.preprocessing --help
191
+ ```
192
+
193
+ ### Code Quality
194
+
195
+ ```bash
196
+ pip install -e ".[dev]"
197
+ black ab/
198
+ isort ab/
199
+ flake8 ab/
200
+ ```
201
+
202
+ ## Dependencies
203
+
204
+ - `nn-dataset>=2.1.0`: LEMUR dataset access
205
+ - `datasketch`: MinHash and LSH implementations
206
+ - `pandas>=1.3,<3.0`: Data manipulation
207
+ - `scipy`: Scientific computing
208
+ - `scikit-learn`: Machine learning utilities
209
+
210
+ ## License
211
+
212
+ MIT License - see LICENSE file for details.
213
+
214
+ ## Contributing
215
+
216
+ 1. Fork the repository
217
+ 2. Create a feature branch
218
+ 3. Make your changes
219
+ 4. Add tests if applicable
220
+ 5. Submit a pull request
221
+
222
+ ## Citation
223
+
224
+ If you use this pipeline in your research, please cite:
225
+
226
+ ```bibtex
227
+ @software{nn_dup_2025,
228
+ title={Neural Network Deduplication Pipeline},
229
+ author={Waleed Khalid},
230
+ year={2025},
231
+ url={https://github.com/your-org/nn-dup}
232
+ }
233
+ ```
234
+
235
+ ## Acknowledgments
236
+
237
+ - Built for the LEMUR dataset and NNGPT projects
238
+ - Developed at the Computer Vision Laboratory, University of Würzburg
239
+ - Part of the ABrain One research initiative
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ requirements.txt
5
+ setup.py
6
+ version
7
+ ldup.egg-info/PKG-INFO
8
+ ldup.egg-info/SOURCES.txt
9
+ ldup.egg-info/dependency_links.txt
10
+ ldup.egg-info/requires.txt
11
+ ldup.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ nn-dup==2.1.0
@@ -0,0 +1 @@
1
+ dist
@@ -0,0 +1,39 @@
1
+ [build-system]
2
+ requires = ['setuptools', 'wheel']
3
+ build-backend = 'setuptools.build_meta'
4
+
5
+ [project]
6
+ name = 'ldup'
7
+ dynamic = ['version', 'dependencies']
8
+ description = 'Prefix-aware curation & near-dedup for NN code via MinHash/LSH and AST fingerprints.'
9
+ readme = { file = 'README.md', content-type = 'text/markdown' }
10
+ license = { file = "LICENSE" }
11
+ requires-python = '>=3.10'
12
+ classifiers = [
13
+ "Programming Language :: Python :: 3",
14
+ "License :: OSI Approved :: MIT License",
15
+ "Operating System :: OS Independent"
16
+ ]
17
+ authors = [{ name = 'ABrain One and contributors', email = 'AI@ABrain.one' }]
18
+
19
+ [project.urls]
20
+ Homepage = 'https://ABrain.one'
21
+ Repository = 'https://github.com/ABrain-One/nn-dup'
22
+
23
+ [tool.setuptools.dynamic]
24
+ version = { file = 'version' }
25
+ dependencies = { file = 'requirements.txt' }
26
+
27
+ [tool.setuptools.packages.find]
28
+ where = ['']
29
+
30
+ [tool.setuptools]
31
+ include-package-data = true
32
+
33
+ [tool.setuptools.data-files]
34
+ '*' = ['**/*.json']
35
+
36
+ [tool.setuptools.package-data]
37
+ 'ab' = ['*.md']
38
+ '*' = ['requirements.txt', 'README.md', 'LICENSE', 'version']
39
+
@@ -0,0 +1 @@
1
+ nn-dup==2.1.0
ldup-2.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
ldup-2.1.0/setup.py ADDED
@@ -0,0 +1,56 @@
1
+ # setup.py
2
+ from pathlib import Path
3
+ from setuptools import setup, find_packages
4
+
5
+ ROOT = Path(__file__).parent.resolve()
6
+ README = ROOT / "README.md"
7
+ REQUIREMENTS = ROOT / "requirements.txt"
8
+
9
+ def load_requirements():
10
+ """Load requirements from requirements.txt file."""
11
+ if REQUIREMENTS.exists():
12
+ with open(REQUIREMENTS, 'r', encoding='utf-8') as f:
13
+ return [line.strip() for line in f if line.strip() and not line.startswith('#')]
14
+ return []
15
+
16
+ long_description = README.read_text(encoding="utf-8") if README.exists() else (
17
+ "LEMUR NN curation & dedup pipeline (prefix-aware exact/near/AST dedup, "
18
+ "diversity top-up, and accepted-code export)."
19
+ )
20
+
21
+ setup(
22
+ name="lemur-preprocessing",
23
+ version="0.1.1",
24
+ description="Prefix-aware curation & near-dedup for NN code via MinHash/LSH and AST fingerprints.",
25
+ long_description=long_description,
26
+ long_description_content_type="text/markdown",
27
+ author="Your Team",
28
+ license="MIT",
29
+ python_requires=">=3.9",
30
+ packages=find_packages(include=["ab", "ab.*"]),
31
+ include_package_data=True,
32
+ install_requires=load_requirements(),
33
+ extras_require={
34
+ "dev": ["black>=23.0", "isort>=5.0", "flake8>=6.0"],
35
+ },
36
+ entry_points={
37
+ "console_scripts": [
38
+ "lemur-preprocess=ab.dup.preprocessing:main",
39
+ ],
40
+ },
41
+ classifiers=[
42
+ "Programming Language :: Python :: 3",
43
+ "License :: OSI Approved :: MIT License",
44
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
45
+ "Topic :: Software Development :: Code Generators",
46
+ "Operating System :: OS Independent",
47
+ ],
48
+ keywords=[
49
+ "LLM", "deduplication", "MinHash", "LSH", "AST", "neural networks",
50
+ "data curation", "pretraining", "fine-tuning",
51
+ ],
52
+ project_urls={
53
+ "Homepage": "https://github.com/your-org/lemur-preprocessing",
54
+ "Bug Tracker": "https://github.com/your-org/lemur-preprocessing/issues",
55
+ },
56
+ )
ldup-2.1.0/version ADDED
@@ -0,0 +1 @@
1
+ 2.1.0