semhash 0.4.2__tar.gz → 0.6.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.
- {semhash-0.4.2 → semhash-0.6.0}/Makefile +1 -1
- {semhash-0.4.2 → semhash-0.6.0}/PKG-INFO +8 -8
- {semhash-0.4.2 → semhash-0.6.0}/README.md +5 -5
- {semhash-0.4.2 → semhash-0.6.0}/benchmarks/README.md +48 -47
- {semhash-0.4.2 → semhash-0.6.0}/benchmarks/data.py +1 -1
- semhash-0.6.0/benchmarks/results/image_train_benchmark_results.json +20 -0
- semhash-0.6.0/benchmarks/results/image_train_test_benchmark_results.json +22 -0
- semhash-0.6.0/benchmarks/results/train_benchmark_results.json +155 -0
- semhash-0.6.0/benchmarks/results/train_test_benchmark_results.json +172 -0
- {semhash-0.4.2 → semhash-0.6.0}/benchmarks/run_text_benchmarks.py +1 -1
- {semhash-0.4.2 → semhash-0.6.0}/pyproject.toml +3 -2
- {semhash-0.4.2 → semhash-0.6.0}/semhash/datamodels.py +69 -30
- {semhash-0.4.2 → semhash-0.6.0}/semhash/index.py +16 -15
- {semhash-0.4.2 → semhash-0.6.0}/semhash/records.py +26 -25
- {semhash-0.4.2 → semhash-0.6.0}/semhash/semhash.py +108 -151
- {semhash-0.4.2 → semhash-0.6.0}/semhash/utils.py +57 -5
- {semhash-0.4.2 → semhash-0.6.0}/semhash/version.py +1 -1
- {semhash-0.4.2 → semhash-0.6.0}/semhash.egg-info/PKG-INFO +8 -8
- {semhash-0.4.2 → semhash-0.6.0}/semhash.egg-info/requires.txt +2 -2
- semhash-0.6.0/semhash.egg-info/scm_version.json +8 -0
- {semhash-0.4.2 → semhash-0.6.0}/tests/test_datamodels.py +29 -37
- {semhash-0.4.2 → semhash-0.6.0}/tests/test_semhash.py +158 -15
- {semhash-0.4.2 → semhash-0.6.0}/tests/test_utils.py +18 -0
- semhash-0.6.0/uv.lock +2222 -0
- semhash-0.4.2/benchmarks/results/image_train_benchmark_results.json +0 -20
- semhash-0.4.2/benchmarks/results/image_train_test_benchmark_results.json +0 -22
- semhash-0.4.2/benchmarks/results/train_benchmark_results.json +0 -155
- semhash-0.4.2/benchmarks/results/train_test_benchmark_results.json +0 -172
- semhash-0.4.2/semhash.egg-info/scm_version.json +0 -8
- semhash-0.4.2/uv.lock +0 -1292
- {semhash-0.4.2 → semhash-0.6.0}/.github/workflows/ci.yaml +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/.github/workflows/release.yaml +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/.gitignore +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/.pre-commit-config.yaml +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/CITATION.cff +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/LICENSE +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/assets/images/semhash_logo.png +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/assets/images/semhash_logo_v2.png +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/benchmarks/__init__.py +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/benchmarks/run_image_benchmarks.py +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/semhash/__init__.py +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/semhash/py.typed +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/semhash.egg-info/SOURCES.txt +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/semhash.egg-info/dependency_links.txt +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/semhash.egg-info/scm_file_list.json +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/semhash.egg-info/top_level.txt +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/setup.cfg +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/tests/conftest.py +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/tests/data/test_model/README.md +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/tests/data/test_model/config.json +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/tests/data/test_model/model.safetensors +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/tests/data/test_model/modules.json +0 -0
- {semhash-0.4.2 → semhash-0.6.0}/tests/data/test_model/tokenizer.json +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: semhash
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Fast Multimodal Semantic Deduplication & Filtering
|
|
5
5
|
Author-email: Thomas van Dongen <thomasvdongen@proton.me>, Stéphan Tulkens <stephantul@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -41,8 +41,8 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
41
41
|
Classifier: Natural Language :: English
|
|
42
42
|
Requires-Python: >=3.10
|
|
43
43
|
Description-Content-Type: text/markdown
|
|
44
|
-
Requires-Dist: model2vec
|
|
45
|
-
Requires-Dist: vicinity[usearch]>=0.4.
|
|
44
|
+
Requires-Dist: model2vec<0.12.0,>=0.11.0
|
|
45
|
+
Requires-Dist: vicinity[usearch]>=0.4.6
|
|
46
46
|
Requires-Dist: frozendict
|
|
47
47
|
Requires-Dist: pyversity
|
|
48
48
|
Provides-Extra: dev
|
|
@@ -203,9 +203,9 @@ semhash = SemHash.from_records(records=records, columns=["question", "context"])
|
|
|
203
203
|
deduplicated_records = semhash.self_deduplicate().selected
|
|
204
204
|
```
|
|
205
205
|
|
|
206
|
-
The `deduplicate` and `self_deduplicate` functions return a [DeduplicationResult](https://github.com/MinishLab/semhash/blob/main/semhash/datamodels.py
|
|
206
|
+
The `deduplicate` and `self_deduplicate` functions return a [DeduplicationResult](https://github.com/MinishLab/semhash/blob/main/semhash/datamodels.py). This object stores the deduplicated corpus, a set of duplicate objects (along with the objects that caused duplication), and several useful functions to further inspect the deduplication result.
|
|
207
207
|
|
|
208
|
-
The `filter_outliers`, `self_filter_outliers`, `find_representative`, and `self_find_representative` functions return a [FilterResult](https://github.com/MinishLab/semhash/blob/main/semhash/datamodels.py
|
|
208
|
+
The `filter_outliers`, `self_filter_outliers`, `find_representative`, and `self_find_representative` functions return a [FilterResult](https://github.com/MinishLab/semhash/blob/main/semhash/datamodels.py). This object stores the found outliers/representative samples.
|
|
209
209
|
|
|
210
210
|
For both the `DeduplicationResult` and `FilterResult` objects, you can easily view the filtered records with the `selected` attribute (e.g. to view outliers: `outliers = semhash.self_filter_outliers().filtered`)
|
|
211
211
|
|
|
@@ -420,7 +420,7 @@ from semhash import SemHash
|
|
|
420
420
|
texts = load_dataset("ag_news", split="train")["text"]
|
|
421
421
|
|
|
422
422
|
# Load an embedding model (in this example, a multilingual model)
|
|
423
|
-
model = StaticModel.from_pretrained("minishlab/
|
|
423
|
+
model = StaticModel.from_pretrained("minishlab/blink-multilingual-64M-int8")
|
|
424
424
|
|
|
425
425
|
# Initialize a SemHash with the model and custom encoder
|
|
426
426
|
semhash = SemHash.from_records(records=texts, model=model)
|
|
@@ -525,7 +525,7 @@ from semhash import SemHash
|
|
|
525
525
|
texts = load_dataset("ag_news", split="train")["text"]
|
|
526
526
|
|
|
527
527
|
# Load an embedding model
|
|
528
|
-
model = StaticModel.from_pretrained("minishlab/
|
|
528
|
+
model = StaticModel.from_pretrained("minishlab/blink-8M-int8")
|
|
529
529
|
|
|
530
530
|
# Create embeddings
|
|
531
531
|
embeddings = model.encode(texts)
|
|
@@ -583,7 +583,7 @@ deduplicated_records = semhash.self_deduplicate().selected
|
|
|
583
583
|
|
|
584
584
|
## Benchmarks
|
|
585
585
|
|
|
586
|
-
SemHash is extremely fast and scales to large datasets with millions of records. We've benchmarked both text and image deduplication across a variety of datasets. For example, deduplicating text 1.8M records takes only ~
|
|
586
|
+
SemHash is extremely fast and scales to large datasets with millions of records. We've benchmarked both text and image deduplication across a variety of datasets. For example, deduplicating text 1.8M records takes only ~67 seconds on CPU.
|
|
587
587
|
|
|
588
588
|
For detailed benchmark results and analysis, see the [benchmarks directory](benchmarks/README.md).
|
|
589
589
|
|
|
@@ -147,9 +147,9 @@ semhash = SemHash.from_records(records=records, columns=["question", "context"])
|
|
|
147
147
|
deduplicated_records = semhash.self_deduplicate().selected
|
|
148
148
|
```
|
|
149
149
|
|
|
150
|
-
The `deduplicate` and `self_deduplicate` functions return a [DeduplicationResult](https://github.com/MinishLab/semhash/blob/main/semhash/datamodels.py
|
|
150
|
+
The `deduplicate` and `self_deduplicate` functions return a [DeduplicationResult](https://github.com/MinishLab/semhash/blob/main/semhash/datamodels.py). This object stores the deduplicated corpus, a set of duplicate objects (along with the objects that caused duplication), and several useful functions to further inspect the deduplication result.
|
|
151
151
|
|
|
152
|
-
The `filter_outliers`, `self_filter_outliers`, `find_representative`, and `self_find_representative` functions return a [FilterResult](https://github.com/MinishLab/semhash/blob/main/semhash/datamodels.py
|
|
152
|
+
The `filter_outliers`, `self_filter_outliers`, `find_representative`, and `self_find_representative` functions return a [FilterResult](https://github.com/MinishLab/semhash/blob/main/semhash/datamodels.py). This object stores the found outliers/representative samples.
|
|
153
153
|
|
|
154
154
|
For both the `DeduplicationResult` and `FilterResult` objects, you can easily view the filtered records with the `selected` attribute (e.g. to view outliers: `outliers = semhash.self_filter_outliers().filtered`)
|
|
155
155
|
|
|
@@ -364,7 +364,7 @@ from semhash import SemHash
|
|
|
364
364
|
texts = load_dataset("ag_news", split="train")["text"]
|
|
365
365
|
|
|
366
366
|
# Load an embedding model (in this example, a multilingual model)
|
|
367
|
-
model = StaticModel.from_pretrained("minishlab/
|
|
367
|
+
model = StaticModel.from_pretrained("minishlab/blink-multilingual-64M-int8")
|
|
368
368
|
|
|
369
369
|
# Initialize a SemHash with the model and custom encoder
|
|
370
370
|
semhash = SemHash.from_records(records=texts, model=model)
|
|
@@ -469,7 +469,7 @@ from semhash import SemHash
|
|
|
469
469
|
texts = load_dataset("ag_news", split="train")["text"]
|
|
470
470
|
|
|
471
471
|
# Load an embedding model
|
|
472
|
-
model = StaticModel.from_pretrained("minishlab/
|
|
472
|
+
model = StaticModel.from_pretrained("minishlab/blink-8M-int8")
|
|
473
473
|
|
|
474
474
|
# Create embeddings
|
|
475
475
|
embeddings = model.encode(texts)
|
|
@@ -527,7 +527,7 @@ deduplicated_records = semhash.self_deduplicate().selected
|
|
|
527
527
|
|
|
528
528
|
## Benchmarks
|
|
529
529
|
|
|
530
|
-
SemHash is extremely fast and scales to large datasets with millions of records. We've benchmarked both text and image deduplication across a variety of datasets. For example, deduplicating text 1.8M records takes only ~
|
|
530
|
+
SemHash is extremely fast and scales to large datasets with millions of records. We've benchmarked both text and image deduplication across a variety of datasets. For example, deduplicating text 1.8M records takes only ~67 seconds on CPU.
|
|
531
531
|
|
|
532
532
|
For detailed benchmark results and analysis, see the [benchmarks directory](benchmarks/README.md).
|
|
533
533
|
|
|
@@ -21,9 +21,10 @@ This directory contains the benchmarking code and results for SemHash. The bench
|
|
|
21
21
|
### Setup
|
|
22
22
|
|
|
23
23
|
All text benchmarks were run with the following configuration:
|
|
24
|
+
- **Device**: MacBook Pro (Apple M5, 48 GB RAM)
|
|
24
25
|
- **CPU-only**: All benchmarks run on CPU (no GPU acceleration)
|
|
25
26
|
- **ANN backend**: Default backend (USearch)
|
|
26
|
-
- **Encoder**: Default encoder ([
|
|
27
|
+
- **Encoder**: Default encoder ([blink-8M-int8](https://huggingface.co/minishlab/blink-8M-int8))
|
|
27
28
|
- **Timing**: Includes encoding time, index building time, and deduplication time
|
|
28
29
|
- **Dependencies**: Requires `datasets` package (`pip install datasets`)
|
|
29
30
|
|
|
@@ -35,23 +36,23 @@ This benchmark measures the performance of deduplicating within a single trainin
|
|
|
35
36
|
|
|
36
37
|
| Dataset | Original Train Size | Deduplicated Train Size | % Removed | Deduplication Time (s) |
|
|
37
38
|
|----------------------|----------------------|--------------------------|------------|--------------------------|
|
|
38
|
-
| bbc | 1225 |
|
|
39
|
-
| senteval_cr | 3012 |
|
|
40
|
-
| tweet_sentiment_extraction | 27481 |
|
|
41
|
-
| emotion | 16000 |
|
|
42
|
-
| amazon_counterfactual | 5000 |
|
|
43
|
-
| ag_news | 120000 |
|
|
44
|
-
| enron_spam | 31716 |
|
|
45
|
-
| subj | 8000 |
|
|
46
|
-
| sst5 | 8544 |
|
|
47
|
-
| 20_newgroups | 11314 |
|
|
48
|
-
| hatespeech_offensive | 22783 |
|
|
49
|
-
| ade | 17637 |
|
|
50
|
-
| imdb | 25000 |
|
|
51
|
-
| massive_scenario | 11514 |
|
|
52
|
-
| student | 117519 |
|
|
53
|
-
| squad_v2 | 130319 |
|
|
54
|
-
| wikitext | 1801350 |
|
|
39
|
+
| bbc | 1225 | 1160 | 5.31 | 0.09 |
|
|
40
|
+
| senteval_cr | 3012 | 3004 | 0.27 | 0.08 |
|
|
41
|
+
| tweet_sentiment_extraction | 27481 | 27046 | 1.58 | 0.92 |
|
|
42
|
+
| emotion | 16000 | 15889 | 0.69 | 0.47 |
|
|
43
|
+
| amazon_counterfactual | 5000 | 4998 | 0.04 | 0.12 |
|
|
44
|
+
| ag_news | 120000 | 109946 | 8.38 | 4.73 |
|
|
45
|
+
| enron_spam | 31716 | 21852 | 31.10 | 0.81 |
|
|
46
|
+
| subj | 8000 | 7991 | 0.11 | 0.25 |
|
|
47
|
+
| sst5 | 8544 | 8531 | 0.15 | 0.33 |
|
|
48
|
+
| 20_newgroups | 11314 | 10742 | 5.06 | 0.27 |
|
|
49
|
+
| hatespeech_offensive | 22783 | 22453 | 1.45 | 0.61 |
|
|
50
|
+
| ade | 17637 | 15798 | 10.43 | 0.66 |
|
|
51
|
+
| imdb | 25000 | 24875 | 0.50 | 0.75 |
|
|
52
|
+
| massive_scenario | 11514 | 10468 | 9.08 | 0.28 |
|
|
53
|
+
| student | 117519 | 91064 | 22.51 | 4.34 |
|
|
54
|
+
| squad_v2 | 130319 | 112866 | 13.39 | 6.29 |
|
|
55
|
+
| wikitext | 1801350 | 935800 | 48.05 | 67.29 |
|
|
55
56
|
|
|
56
57
|
### Train/Test Deduplication Benchmark
|
|
57
58
|
|
|
@@ -59,33 +60,33 @@ This benchmark measures the performance of deduplicating a test dataset against
|
|
|
59
60
|
|
|
60
61
|
| Dataset | Train Size | Test Size | Deduplicated Test Size | % Removed | Deduplication Time (s) |
|
|
61
62
|
|----------------------|--------------|--------------|--------------------------|------------|--------------------------|
|
|
62
|
-
| bbc | 1225 | 1000 |
|
|
63
|
-
| senteval_cr | 3012 | 753 |
|
|
64
|
-
| tweet_sentiment_extraction | 27481 | 3534 |
|
|
65
|
-
| emotion | 16000 | 2000 |
|
|
66
|
-
| amazon_counterfactual | 5000 | 5000 |
|
|
67
|
-
| ag_news | 120000 | 7600 |
|
|
68
|
-
| enron_spam | 31716 | 2000 |
|
|
69
|
-
| subj | 8000 | 2000 | 1999 | 0.05 | 0.
|
|
70
|
-
| sst5 | 8544 | 2210 |
|
|
71
|
-
| 20_newgroups | 11314 | 7532 |
|
|
72
|
-
| hatespeech_offensive | 22783 | 2000 |
|
|
73
|
-
| ade | 17637 | 5879 |
|
|
74
|
-
| imdb | 25000 | 25000 |
|
|
75
|
-
| massive_scenario | 11514 | 2974 |
|
|
76
|
-
| student | 117519 | 5000 |
|
|
77
|
-
| squad_v2 | 130319 | 11873 |
|
|
78
|
-
| wikitext | 1801350 | 4358 |
|
|
63
|
+
| bbc | 1225 | 1000 | 894 | 10.60 | 0.11 |
|
|
64
|
+
| senteval_cr | 3012 | 753 | 751 | 0.27 | 0.07 |
|
|
65
|
+
| tweet_sentiment_extraction | 27481 | 3534 | 3453 | 2.29 | 0.62 |
|
|
66
|
+
| emotion | 16000 | 2000 | 1968 | 1.60 | 0.33 |
|
|
67
|
+
| amazon_counterfactual | 5000 | 5000 | 4995 | 0.10 | 0.17 |
|
|
68
|
+
| ag_news | 120000 | 7600 | 6419 | 15.54 | 3.03 |
|
|
69
|
+
| enron_spam | 31716 | 2000 | 1115 | 44.25 | 0.53 |
|
|
70
|
+
| subj | 8000 | 2000 | 1999 | 0.05 | 0.20 |
|
|
71
|
+
| sst5 | 8544 | 2210 | 2207 | 0.14 | 0.26 |
|
|
72
|
+
| 20_newgroups | 11314 | 7532 | 7134 | 5.28 | 0.33 |
|
|
73
|
+
| hatespeech_offensive | 22783 | 2000 | 1951 | 2.45 | 0.43 |
|
|
74
|
+
| ade | 17637 | 5879 | 4989 | 15.14 | 0.51 |
|
|
75
|
+
| imdb | 25000 | 25000 | 24869 | 0.52 | 1.00 |
|
|
76
|
+
| massive_scenario | 11514 | 2974 | 2476 | 16.75 | 0.24 |
|
|
77
|
+
| student | 117519 | 5000 | 3290 | 34.20 | 2.47 |
|
|
78
|
+
| squad_v2 | 130319 | 11873 | 11868 | 0.04 | 3.78 |
|
|
79
|
+
| wikitext | 1801350 | 4358 | 2225 | 48.94 | 40.45 |
|
|
79
80
|
|
|
80
81
|
### Key Findings
|
|
81
82
|
|
|
82
83
|
SemHash is extremely fast and scales to large datasets with millions of records. Some notable findings include:
|
|
83
84
|
|
|
84
|
-
- **Speed**: Deduplication is fast even for large datasets (e.g., 1.8M records in ~
|
|
85
|
+
- **Speed**: Deduplication is fast even for large datasets (e.g., 1.8M records in ~67 seconds)
|
|
85
86
|
- **Train/Test Leakage**: Several datasets show significant train/test overlap:
|
|
86
|
-
- `enron_spam`:
|
|
87
|
-
- `student`:
|
|
88
|
-
- `wikitext`:
|
|
87
|
+
- `enron_spam`: 44% of test data overlaps with training data
|
|
88
|
+
- `student`: 34% of test data overlaps with training data
|
|
89
|
+
- `wikitext`: 49% of test data overlaps with training data
|
|
89
90
|
|
|
90
91
|
### Running Text Benchmarks
|
|
91
92
|
|
|
@@ -106,7 +107,7 @@ make benchmark-text
|
|
|
106
107
|
### Setup
|
|
107
108
|
|
|
108
109
|
All image benchmarks were run with the following configuration:
|
|
109
|
-
- **Device**: Apple
|
|
110
|
+
- **Device**: MacBook Pro (Apple M5, 48 GB RAM), GPU via MPS
|
|
110
111
|
- **ANN backend**: Default backend (USearch)
|
|
111
112
|
- **Encoder**: MobileNetV3-Small ([mobilenetv3_small_100.lamb_in1k](https://huggingface.co/timm/mobilenetv3_small_100.lamb_in1k))
|
|
112
113
|
- **Batch size**: 128 images per batch
|
|
@@ -120,8 +121,8 @@ This benchmark measures the performance of deduplicating within a single trainin
|
|
|
120
121
|
|
|
121
122
|
| Dataset | Original Train Size | Deduplicated Train Size | % Removed | Deduplication Time (s) |
|
|
122
123
|
|----------------------|----------------------|--------------------------|------------|--------------------------|
|
|
123
|
-
| cifar10 | 50000 |
|
|
124
|
-
| fashion_mnist | 60000 |
|
|
124
|
+
| cifar10 | 50000 | 48390 | 3.22 | 38.05 |
|
|
125
|
+
| fashion_mnist | 60000 | 23549 | 60.75 | 42.70 |
|
|
125
126
|
|
|
126
127
|
#### Train/Test Deduplication Benchmark
|
|
127
128
|
|
|
@@ -129,14 +130,14 @@ This benchmark measures the performance of deduplicating a test dataset against
|
|
|
129
130
|
|
|
130
131
|
| Dataset | Train Size | Test Size | Deduplicated Test Size | % Removed | Deduplication Time (s) |
|
|
131
132
|
|----------------------|--------------|--------------|--------------------------|------------|--------------------------|
|
|
132
|
-
| cifar10 | 50000 | 10000 | 9397 | 6.03 |
|
|
133
|
-
| fashion_mnist | 60000 | 10000 |
|
|
133
|
+
| cifar10 | 50000 | 10000 | 9397 | 6.03 | 43.35 |
|
|
134
|
+
| fashion_mnist | 60000 | 10000 | 2056 | 79.44 | 46.89 |
|
|
134
135
|
|
|
135
136
|
### Key Findings
|
|
136
137
|
|
|
137
|
-
- **Fashion-MNIST high deduplication**: Fashion-MNIST shows very high duplication rates (
|
|
138
|
-
- **CIFAR-10 moderate deduplication**: CIFAR-10 shows lower duplication (3.
|
|
139
|
-
- **Speed**: Image deduplication is fast even for large datasets (60k images in ~
|
|
138
|
+
- **Fashion-MNIST high deduplication**: Fashion-MNIST shows very high duplication rates (61% train, 79% test) due to the simple nature of the dataset (10 clothing categories with similar items)
|
|
139
|
+
- **CIFAR-10 moderate deduplication**: CIFAR-10 shows lower duplication (3.22% train, 6.03% test) as it contains more diverse natural images
|
|
140
|
+
- **Speed**: Image deduplication is fast even for large datasets (60k images in ~43 seconds on MPS); note that the actual deduplication step is quick, with most time spent on encoding images
|
|
140
141
|
|
|
141
142
|
### Running Image Benchmarks
|
|
142
143
|
|
|
@@ -37,7 +37,7 @@ DATASET_DICT: dict[str, DatasetRecord] = {
|
|
|
37
37
|
name="SetFit/amazon_massive_scenario_en-US", text_name="text", label_name="label"
|
|
38
38
|
),
|
|
39
39
|
"student": DatasetRecord(name="SetFit/student-question-categories", text_name="text", label_name="label"),
|
|
40
|
-
"squad_v2": DatasetRecord(name="squad_v2", columns=["question", "context"], split_two="validation"),
|
|
40
|
+
"squad_v2": DatasetRecord(name="rajpurkar/squad_v2", columns=["question", "context"], split_two="validation"),
|
|
41
41
|
"wikitext": DatasetRecord(
|
|
42
42
|
name="Salesforce/wikitext", text_name="text", label_name="text", sub_directory="wikitext-103-raw-v1"
|
|
43
43
|
),
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"dataset": "cifar10",
|
|
4
|
+
"original_train_size": 50000,
|
|
5
|
+
"deduplicated_train_size": 48390,
|
|
6
|
+
"percent_removed": 3.2200000000000006,
|
|
7
|
+
"build_time_seconds": 36.14036558299995,
|
|
8
|
+
"deduplication_time_seconds": 1.9100148340003216,
|
|
9
|
+
"time_seconds": 38.05038041700027
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"dataset": "fashion_mnist",
|
|
13
|
+
"original_train_size": 60000,
|
|
14
|
+
"deduplicated_train_size": 23549,
|
|
15
|
+
"percent_removed": 60.75166666666667,
|
|
16
|
+
"build_time_seconds": 38.96308354100256,
|
|
17
|
+
"deduplication_time_seconds": 3.733158041999559,
|
|
18
|
+
"time_seconds": 42.69624158300212
|
|
19
|
+
}
|
|
20
|
+
]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"dataset": "cifar10",
|
|
4
|
+
"train_size": 50000,
|
|
5
|
+
"test_size": 10000,
|
|
6
|
+
"deduplicated_test_size": 9397,
|
|
7
|
+
"percent_removed": 6.030000000000002,
|
|
8
|
+
"build_time_seconds": 36.14036558299995,
|
|
9
|
+
"deduplication_time_seconds": 7.210748125002283,
|
|
10
|
+
"time_seconds": 43.35111370800223
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"dataset": "fashion_mnist",
|
|
14
|
+
"train_size": 60000,
|
|
15
|
+
"test_size": 10000,
|
|
16
|
+
"deduplicated_test_size": 2056,
|
|
17
|
+
"percent_removed": 79.44,
|
|
18
|
+
"build_time_seconds": 38.96308354100256,
|
|
19
|
+
"deduplication_time_seconds": 7.9287375419989985,
|
|
20
|
+
"time_seconds": 46.89182108300156
|
|
21
|
+
}
|
|
22
|
+
]
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"dataset": "bbc",
|
|
4
|
+
"original_train_size": 1225,
|
|
5
|
+
"deduplicated_train_size": 1160,
|
|
6
|
+
"percent_removed": 5.306122448979589,
|
|
7
|
+
"build_time_seconds": 0.08228383300593123,
|
|
8
|
+
"deduplication_time_seconds": 0.007828624977264553,
|
|
9
|
+
"time_seconds": 0.09011245798319578
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"dataset": "senteval_cr",
|
|
13
|
+
"original_train_size": 3012,
|
|
14
|
+
"deduplicated_train_size": 3004,
|
|
15
|
+
"percent_removed": 0.26560424966799445,
|
|
16
|
+
"build_time_seconds": 0.05288445801124908,
|
|
17
|
+
"deduplication_time_seconds": 0.025682082981802523,
|
|
18
|
+
"time_seconds": 0.0785665409930516
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"dataset": "tweet_sentiment_extraction",
|
|
22
|
+
"original_train_size": 27481,
|
|
23
|
+
"deduplicated_train_size": 27046,
|
|
24
|
+
"percent_removed": 1.582911829991629,
|
|
25
|
+
"build_time_seconds": 0.5076506669865921,
|
|
26
|
+
"deduplication_time_seconds": 0.4142158339964226,
|
|
27
|
+
"time_seconds": 0.9218665009830147
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"dataset": "emotion",
|
|
31
|
+
"original_train_size": 16000,
|
|
32
|
+
"deduplicated_train_size": 15889,
|
|
33
|
+
"percent_removed": 0.6937500000000041,
|
|
34
|
+
"build_time_seconds": 0.27774158300599083,
|
|
35
|
+
"deduplication_time_seconds": 0.19270449999021366,
|
|
36
|
+
"time_seconds": 0.4704460829962045
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"dataset": "amazon_counterfactual",
|
|
40
|
+
"original_train_size": 5000,
|
|
41
|
+
"deduplicated_train_size": 4998,
|
|
42
|
+
"percent_removed": 0.039999999999995595,
|
|
43
|
+
"build_time_seconds": 0.0722738339973148,
|
|
44
|
+
"deduplication_time_seconds": 0.046256500005256385,
|
|
45
|
+
"time_seconds": 0.11853033400257118
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"dataset": "ag_news",
|
|
49
|
+
"original_train_size": 120000,
|
|
50
|
+
"deduplicated_train_size": 109946,
|
|
51
|
+
"percent_removed": 8.378333333333332,
|
|
52
|
+
"build_time_seconds": 2.676411458000075,
|
|
53
|
+
"deduplication_time_seconds": 2.0554405419970863,
|
|
54
|
+
"time_seconds": 4.731851999997161
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"dataset": "enron_spam",
|
|
58
|
+
"original_train_size": 31716,
|
|
59
|
+
"deduplicated_train_size": 21852,
|
|
60
|
+
"percent_removed": 31.10102156640182,
|
|
61
|
+
"build_time_seconds": 0.46140299999387935,
|
|
62
|
+
"deduplication_time_seconds": 0.3460086249979213,
|
|
63
|
+
"time_seconds": 0.8074116249918006
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"dataset": "subj",
|
|
67
|
+
"original_train_size": 8000,
|
|
68
|
+
"deduplicated_train_size": 7991,
|
|
69
|
+
"percent_removed": 0.11250000000000426,
|
|
70
|
+
"build_time_seconds": 0.14867070800391957,
|
|
71
|
+
"deduplication_time_seconds": 0.10164587499457411,
|
|
72
|
+
"time_seconds": 0.2503165829984937
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"dataset": "sst5",
|
|
76
|
+
"original_train_size": 8544,
|
|
77
|
+
"deduplicated_train_size": 8531,
|
|
78
|
+
"percent_removed": 0.1521535580524369,
|
|
79
|
+
"build_time_seconds": 0.1941677920112852,
|
|
80
|
+
"deduplication_time_seconds": 0.13278829099726863,
|
|
81
|
+
"time_seconds": 0.32695608300855383
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"dataset": "20_newgroups",
|
|
85
|
+
"original_train_size": 11314,
|
|
86
|
+
"deduplicated_train_size": 10742,
|
|
87
|
+
"percent_removed": 5.0556832243238485,
|
|
88
|
+
"build_time_seconds": 0.1735126669809688,
|
|
89
|
+
"deduplication_time_seconds": 0.09359279199270532,
|
|
90
|
+
"time_seconds": 0.2671054589736741
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"dataset": "hatespeech_offensive",
|
|
94
|
+
"original_train_size": 22783,
|
|
95
|
+
"deduplicated_train_size": 22453,
|
|
96
|
+
"percent_removed": 1.448448404512137,
|
|
97
|
+
"build_time_seconds": 0.36001295899040997,
|
|
98
|
+
"deduplication_time_seconds": 0.251703166984953,
|
|
99
|
+
"time_seconds": 0.611716125975363
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"dataset": "ade",
|
|
103
|
+
"original_train_size": 17637,
|
|
104
|
+
"deduplicated_train_size": 15798,
|
|
105
|
+
"percent_removed": 10.426943357713892,
|
|
106
|
+
"build_time_seconds": 0.3542046249785926,
|
|
107
|
+
"deduplication_time_seconds": 0.3076234170002863,
|
|
108
|
+
"time_seconds": 0.6618280419788789
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"dataset": "imdb",
|
|
112
|
+
"original_train_size": 25000,
|
|
113
|
+
"deduplicated_train_size": 24875,
|
|
114
|
+
"percent_removed": 0.5000000000000004,
|
|
115
|
+
"build_time_seconds": 0.440583040995989,
|
|
116
|
+
"deduplication_time_seconds": 0.3077678340196144,
|
|
117
|
+
"time_seconds": 0.7483508750156034
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"dataset": "massive_scenario",
|
|
121
|
+
"original_train_size": 11514,
|
|
122
|
+
"deduplicated_train_size": 10468,
|
|
123
|
+
"percent_removed": 9.08459266979329,
|
|
124
|
+
"build_time_seconds": 0.18055304102017544,
|
|
125
|
+
"deduplication_time_seconds": 0.09604270799900405,
|
|
126
|
+
"time_seconds": 0.2765957490191795
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"dataset": "student",
|
|
130
|
+
"original_train_size": 117519,
|
|
131
|
+
"deduplicated_train_size": 91064,
|
|
132
|
+
"percent_removed": 22.511253499434137,
|
|
133
|
+
"build_time_seconds": 2.141833374975249,
|
|
134
|
+
"deduplication_time_seconds": 2.2007687920122407,
|
|
135
|
+
"time_seconds": 4.34260216698749
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"dataset": "squad_v2",
|
|
139
|
+
"original_train_size": 130319,
|
|
140
|
+
"deduplicated_train_size": 112866,
|
|
141
|
+
"percent_removed": 13.392521428187754,
|
|
142
|
+
"build_time_seconds": 3.180365708016325,
|
|
143
|
+
"deduplication_time_seconds": 3.112715416995343,
|
|
144
|
+
"time_seconds": 6.293081125011668
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"dataset": "wikitext",
|
|
148
|
+
"original_train_size": 1801350,
|
|
149
|
+
"deduplicated_train_size": 935800,
|
|
150
|
+
"percent_removed": 48.05007355594415,
|
|
151
|
+
"build_time_seconds": 39.0202667080157,
|
|
152
|
+
"deduplication_time_seconds": 28.270351332990685,
|
|
153
|
+
"time_seconds": 67.29061804100638
|
|
154
|
+
}
|
|
155
|
+
]
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"dataset": "bbc",
|
|
4
|
+
"train_size": 1225,
|
|
5
|
+
"test_size": 1000,
|
|
6
|
+
"deduplicated_test_size": 894,
|
|
7
|
+
"percent_removed": 10.599999999999998,
|
|
8
|
+
"build_time_seconds": 0.08228383300593123,
|
|
9
|
+
"deduplication_time_seconds": 0.0305490420141723,
|
|
10
|
+
"time_seconds": 0.11283287502010353
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"dataset": "senteval_cr",
|
|
14
|
+
"train_size": 3012,
|
|
15
|
+
"test_size": 753,
|
|
16
|
+
"deduplicated_test_size": 751,
|
|
17
|
+
"percent_removed": 0.26560424966799445,
|
|
18
|
+
"build_time_seconds": 0.05288445801124908,
|
|
19
|
+
"deduplication_time_seconds": 0.016543708014069125,
|
|
20
|
+
"time_seconds": 0.0694281660253182
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"dataset": "tweet_sentiment_extraction",
|
|
24
|
+
"train_size": 27481,
|
|
25
|
+
"test_size": 3534,
|
|
26
|
+
"deduplicated_test_size": 3453,
|
|
27
|
+
"percent_removed": 2.292020373514436,
|
|
28
|
+
"build_time_seconds": 0.5076506669865921,
|
|
29
|
+
"deduplication_time_seconds": 0.11679291701875627,
|
|
30
|
+
"time_seconds": 0.6244435840053484
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"dataset": "emotion",
|
|
34
|
+
"train_size": 16000,
|
|
35
|
+
"test_size": 2000,
|
|
36
|
+
"deduplicated_test_size": 1968,
|
|
37
|
+
"percent_removed": 1.6000000000000014,
|
|
38
|
+
"build_time_seconds": 0.27774158300599083,
|
|
39
|
+
"deduplication_time_seconds": 0.05182408299879171,
|
|
40
|
+
"time_seconds": 0.32956566600478254
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"dataset": "amazon_counterfactual",
|
|
44
|
+
"train_size": 5000,
|
|
45
|
+
"test_size": 5000,
|
|
46
|
+
"deduplicated_test_size": 4995,
|
|
47
|
+
"percent_removed": 0.10000000000000009,
|
|
48
|
+
"build_time_seconds": 0.0722738339973148,
|
|
49
|
+
"deduplication_time_seconds": 0.10255170799791813,
|
|
50
|
+
"time_seconds": 0.17482554199523292
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"dataset": "ag_news",
|
|
54
|
+
"train_size": 120000,
|
|
55
|
+
"test_size": 7600,
|
|
56
|
+
"deduplicated_test_size": 6419,
|
|
57
|
+
"percent_removed": 15.539473684210526,
|
|
58
|
+
"build_time_seconds": 2.676411458000075,
|
|
59
|
+
"deduplication_time_seconds": 0.3541311669978313,
|
|
60
|
+
"time_seconds": 3.0305426249979064
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"dataset": "enron_spam",
|
|
64
|
+
"train_size": 31716,
|
|
65
|
+
"test_size": 2000,
|
|
66
|
+
"deduplicated_test_size": 1115,
|
|
67
|
+
"percent_removed": 44.25,
|
|
68
|
+
"build_time_seconds": 0.46140299999387935,
|
|
69
|
+
"deduplication_time_seconds": 0.06506937500671484,
|
|
70
|
+
"time_seconds": 0.5264723750005942
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"dataset": "subj",
|
|
74
|
+
"train_size": 8000,
|
|
75
|
+
"test_size": 2000,
|
|
76
|
+
"deduplicated_test_size": 1999,
|
|
77
|
+
"percent_removed": 0.04999999999999449,
|
|
78
|
+
"build_time_seconds": 0.14867070800391957,
|
|
79
|
+
"deduplication_time_seconds": 0.04964187499717809,
|
|
80
|
+
"time_seconds": 0.19831258300109766
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"dataset": "sst5",
|
|
84
|
+
"train_size": 8544,
|
|
85
|
+
"test_size": 2210,
|
|
86
|
+
"deduplicated_test_size": 2207,
|
|
87
|
+
"percent_removed": 0.13574660633484115,
|
|
88
|
+
"build_time_seconds": 0.1941677920112852,
|
|
89
|
+
"deduplication_time_seconds": 0.06451991698122583,
|
|
90
|
+
"time_seconds": 0.25868770899251103
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"dataset": "20_newgroups",
|
|
94
|
+
"train_size": 11314,
|
|
95
|
+
"test_size": 7532,
|
|
96
|
+
"deduplicated_test_size": 7134,
|
|
97
|
+
"percent_removed": 5.284121083377591,
|
|
98
|
+
"build_time_seconds": 0.1735126669809688,
|
|
99
|
+
"deduplication_time_seconds": 0.15224216697970405,
|
|
100
|
+
"time_seconds": 0.32575483396067284
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"dataset": "hatespeech_offensive",
|
|
104
|
+
"train_size": 22783,
|
|
105
|
+
"test_size": 2000,
|
|
106
|
+
"deduplicated_test_size": 1951,
|
|
107
|
+
"percent_removed": 2.4499999999999966,
|
|
108
|
+
"build_time_seconds": 0.36001295899040997,
|
|
109
|
+
"deduplication_time_seconds": 0.07481212500715628,
|
|
110
|
+
"time_seconds": 0.43482508399756625
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"dataset": "ade",
|
|
114
|
+
"train_size": 17637,
|
|
115
|
+
"test_size": 5879,
|
|
116
|
+
"deduplicated_test_size": 4989,
|
|
117
|
+
"percent_removed": 15.138629018540573,
|
|
118
|
+
"build_time_seconds": 0.3542046249785926,
|
|
119
|
+
"deduplication_time_seconds": 0.1563692500058096,
|
|
120
|
+
"time_seconds": 0.5105738749844022
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"dataset": "imdb",
|
|
124
|
+
"train_size": 25000,
|
|
125
|
+
"test_size": 25000,
|
|
126
|
+
"deduplicated_test_size": 24869,
|
|
127
|
+
"percent_removed": 0.5240000000000022,
|
|
128
|
+
"build_time_seconds": 0.440583040995989,
|
|
129
|
+
"deduplication_time_seconds": 0.5591723329853266,
|
|
130
|
+
"time_seconds": 0.9997553739813156
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"dataset": "massive_scenario",
|
|
134
|
+
"train_size": 11514,
|
|
135
|
+
"test_size": 2974,
|
|
136
|
+
"deduplicated_test_size": 2476,
|
|
137
|
+
"percent_removed": 16.745124411566913,
|
|
138
|
+
"build_time_seconds": 0.18055304102017544,
|
|
139
|
+
"deduplication_time_seconds": 0.05798879198846407,
|
|
140
|
+
"time_seconds": 0.23854183300863951
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"dataset": "student",
|
|
144
|
+
"train_size": 117519,
|
|
145
|
+
"test_size": 5000,
|
|
146
|
+
"deduplicated_test_size": 3290,
|
|
147
|
+
"percent_removed": 34.199999999999996,
|
|
148
|
+
"build_time_seconds": 2.141833374975249,
|
|
149
|
+
"deduplication_time_seconds": 0.33121483397553675,
|
|
150
|
+
"time_seconds": 2.473048208950786
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"dataset": "squad_v2",
|
|
154
|
+
"train_size": 130319,
|
|
155
|
+
"test_size": 11873,
|
|
156
|
+
"deduplicated_test_size": 11868,
|
|
157
|
+
"percent_removed": 0.04211235576517813,
|
|
158
|
+
"build_time_seconds": 3.180365708016325,
|
|
159
|
+
"deduplication_time_seconds": 0.5946447500027716,
|
|
160
|
+
"time_seconds": 3.7750104580190964
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"dataset": "wikitext",
|
|
164
|
+
"train_size": 1801350,
|
|
165
|
+
"test_size": 4358,
|
|
166
|
+
"deduplicated_test_size": 2225,
|
|
167
|
+
"percent_removed": 48.94446994033961,
|
|
168
|
+
"build_time_seconds": 39.0202667080157,
|
|
169
|
+
"deduplication_time_seconds": 1.4329454580147285,
|
|
170
|
+
"time_seconds": 40.453212166030426
|
|
171
|
+
}
|
|
172
|
+
]
|
|
@@ -19,7 +19,7 @@ def main() -> None: # noqa: C901
|
|
|
19
19
|
train_test_dedup_results = []
|
|
20
20
|
# Load the model and initialize SemHash
|
|
21
21
|
|
|
22
|
-
model = StaticModel.from_pretrained("minishlab/
|
|
22
|
+
model = StaticModel.from_pretrained("minishlab/blink-8M-int8")
|
|
23
23
|
|
|
24
24
|
for dataset_name, record in DATASET_DICT.items():
|
|
25
25
|
logger.info(f"Loading dataset: {dataset_name} from {record.name}")
|