vsabolcec commited on
Commit
1940ba2
·
0 Parent(s):

Super-squash branch 'main' using huggingface_hub

Browse files
Files changed (23) hide show
  1. .gitattributes +35 -0
  2. README.md +115 -0
  3. arb_Arab.pt +3 -0
  4. ces_Latn.pt +3 -0
  5. cmn_Hani.pt +3 -0
  6. dan_Latn.pt +3 -0
  7. deu_Latn.pt +3 -0
  8. ell_Grek.pt +3 -0
  9. eng_Latn.pt +3 -0
  10. fas_Arab.pt +3 -0
  11. fra_Latn.pt +3 -0
  12. hun_Latn.pt +3 -0
  13. ind_Latn.pt +3 -0
  14. ita_Latn.pt +3 -0
  15. jpn_Jpan.pt +3 -0
  16. nld_Latn.pt +3 -0
  17. pol_Latn.pt +3 -0
  18. por_Latn.pt +3 -0
  19. rus_Cyrl.pt +3 -0
  20. spa_Latn.pt +3 -0
  21. swe_Latn.pt +3 -0
  22. tur_Latn.pt +3 -0
  23. vie_Latn.pt +3 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ - ru
6
+ - zh
7
+ - de
8
+ - ja
9
+ - es
10
+ - fr
11
+ - it
12
+ - pt
13
+ - pl
14
+ - nl
15
+ - id
16
+ - tr
17
+ - cs
18
+ - vi
19
+ - sv
20
+ - fa
21
+ - ar
22
+ - el
23
+ - da
24
+ - hu
25
+ ---
26
+
27
+ # FineWeb-HQ-Classifiers
28
+
29
+ This repository contains the model weights of the trained deep learning classifiers used to identify structured and knowledge-rich samples for the [FineWeb-HQ](https://huggingface.co/datasets/epfml/FineWeb-HQ) and [FineWeb2-HQ](https://huggingface.co/datasets/epfml/FineWeb2-HQ) datasets.
30
+
31
+ FineWeb-HQ and FineWeb2-HQ are high-quality, model-filtered, multilingual pretraining datasets derived as subsets of [FineWeb](https://huggingface.co/datasets/HuggingFaceFW/fineweb) and [FineWeb2](https://huggingface.co/datasets/HuggingFaceFW/fineweb-2). The datasets were created by selecting the top 10% of FineWeb and FineWeb-2 documents. The classifiers use [XLM-RoBERTa](https://huggingface.co/FacebookAI/xlm-roberta-base) embeddings to score the documents.
32
+
33
+ For more details, see our paper [Enhancing Multilingual LLM Pretraining with Model-Based Data Selection](https://arxiv.org/abs/2502.10361).
34
+
35
+ ## Quickstart
36
+
37
+ Classifiers use a simple architecture that takes mean-pooled XLM-RoBERTa embeddings as input and outputs the score logit.
38
+
39
+ ```python
40
+ import torch
41
+ import torch.nn.functional as F
42
+ from transformers import AutoModel, AutoTokenizer
43
+ import huggingface_hub
44
+
45
+
46
+ class BinaryClassifier(torch.nn.Module):
47
+ def __init__(self, embedding_dim=768, hidden_dim=256):
48
+ super(BinaryClassifier, self).__init__()
49
+ self.classifier = torch.nn.Sequential(
50
+ torch.nn.Linear(embedding_dim, hidden_dim),
51
+ torch.nn.ReLU(),
52
+ torch.nn.Dropout(0.2),
53
+ torch.nn.Linear(hidden_dim, 1),
54
+ )
55
+
56
+ def forward(self, X):
57
+ return self.classifier(X)
58
+
59
+ def to_pt(self, file_name):
60
+ torch.save(self.state_dict(), file_name)
61
+
62
+ def from_pt(file_name, embedding_dim=768, hidden_dim=256):
63
+ state_dict = torch.load(
64
+ file_name,
65
+ weights_only=True,
66
+ map_location=torch.device("cpu"),
67
+ )
68
+ classifier = BinaryClassifier(
69
+ embedding_dim=embedding_dim,
70
+ hidden_dim=hidden_dim,
71
+ )
72
+ classifier.load_state_dict(state_dict)
73
+ classifier.eval()
74
+ return classifier
75
+
76
+
77
+ if __name__ == "__main__":
78
+ embedding_model_name = "FacebookAI/xlm-roberta-base"
79
+ tokenizer = AutoTokenizer.from_pretrained(embedding_model_name)
80
+ embedding_model = AutoModel.from_pretrained(
81
+ embedding_model_name,
82
+ dtype=torch.bfloat16,
83
+ )
84
+
85
+ classifiers_dir = huggingface_hub.snapshot_download("epfml/FineWeb-HQ-Classifiers")
86
+ classifier_model_en = BinaryClassifier.from_pt(f"{classifiers_dir}/eng_Latn.pt")
87
+
88
+ def score_sample(text, classifier_model):
89
+ inputs = tokenizer([text], return_tensors="pt")
90
+ embeddings = embedding_model(**inputs).last_hidden_state.float().mean(1)
91
+ score = F.sigmoid(classifier_model(embeddings)).item()
92
+ return score
93
+
94
+ text = "Question: How is bipolar disorder different from unipolar depression or 'regular' depression?\nAnswer: Both bipolar disorder and major depression are typically associated with depressive episodes. So both illnesses are accompanied by depressions. The difference is that in bipolar disorder people also have periods of elevation -- or severe irritability. We call these manic or hypomanic episodes."
95
+ score = score_sample(text, classifier_model_en)
96
+ print(f"{score:0.4f}") # 0.9338
97
+
98
+ text = "Custom Wedding Gifts\nPersonalized photo frames, albums & keepsakes. Heirloom quality!\nCustom Engraved Journals\nHandmade in Florence Italy. Dozens of sizes and paper styles!"
99
+ score = score_sample(text, classifier_model_en)
100
+ print(f"{score:0.4f}") # 0.0001
101
+ ```
102
+
103
+ For a more efficient implementation, see our [Github repository](https://github.com/epfml/fineweb2-hq).
104
+
105
+ ## Citation information
106
+ ```
107
+ @article
108
+ {messmer2025multilingdatacomp,
109
+ title={Enhancing Multilingual LLM Pretraining with Model-Based Data Selection},
110
+ author={Bettina Messmer and Vinko Sabolčec and Martin Jaggi},
111
+ journal={arXiv},
112
+ year={2025},
113
+ url={https://arxiv.org/abs/2502.10361},
114
+ }
115
+ ```
arb_Arab.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:587a82928fa3681cdd3e12db7617aad566af6ecccf540bb8d945d784593b2ea5
3
+ size 790528
ces_Latn.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f8d2fcf9e38b86e965de907a83c0aafae80d1f272890b4b3f3f84a0078c5568
3
+ size 790528
cmn_Hani.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2cec7c131c0fc3a4a8140a19e9cc0b8623254ac5a4678fd04ccaeff11a28f05
3
+ size 790528
dan_Latn.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:00852caa2c2f4fff806827124b3b1a492d22108886b51f76ba2c78a20d95eaf3
3
+ size 790528
deu_Latn.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c46fe8847d6608e95989d8dd45004d6be4ad0b504476bc8624042ebef473fc75
3
+ size 790528
ell_Grek.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:40f3117d4a6a0c133a24d18837560de22427e4db915c864f580c47bc2402f66a
3
+ size 790528
eng_Latn.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b4cd4c8edf0dde329d8856ee4d0c0704767c44120613adabc00b106d8f7c5f0
3
+ size 790528
fas_Arab.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:53c4db06fe17bbdd80bbae6ebcd71d401e54453636f9c3535f627a9a60a77ce7
3
+ size 790528
fra_Latn.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7f426bf679283af98c907758069557961c1b5b54d254d34f06899ac88d2ca888
3
+ size 790528
hun_Latn.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8c15195f8edc341cb2caf1d0147b895a789609306c7c6024862ae4e34b2bf6d0
3
+ size 790528
ind_Latn.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fedf1f41af5ef5a7855501d07c0d6f62ec2b999af32506250b3ff209cb72be46
3
+ size 790528
ita_Latn.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a844d93000de757aafea035b8586ea7e5b5e009aae9c6ac532b4dec756a990d3
3
+ size 790528
jpn_Jpan.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7396d86ae1a55544baf66babd5a2eebdab20e543d9d0886f8e77a093d3173161
3
+ size 790528
nld_Latn.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:62278bf608fa2a47ecd8f5f308d3af0343919595d2ceef15f64c6ee8e9e9ff03
3
+ size 790528
pol_Latn.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ee5e285a1b7d5b21ac2485d3d0fbfcb02f5e368b44f0f056cfcb276d205f746
3
+ size 790528
por_Latn.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5e9d2e6cf1a3a12961caec2c8b209df13f5d354a63d3c4b9f958c6ede7dca6ef
3
+ size 790528
rus_Cyrl.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b0463c126ce77198352f6cb1129c36c9782cad82011189c36bc6364cacb96e6d
3
+ size 790528
spa_Latn.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:70551bb9135847f2c2ee60e778ff7c8bba5928207a811bc8b50651ec0ee40e00
3
+ size 790528
swe_Latn.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5e3b21ea9d86176a16e4860906fb79b89ee7f41e602b687d48af249e5d2d6bde
3
+ size 790528
tur_Latn.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3472898cc521a25eaac304e4bec14f7bae77b692f9b388cb97517ba80d9b2f62
3
+ size 790528
vie_Latn.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f7c4edbc9505b8d2f86a7297541e50701f3ba48fc930fdc4c6e0870ed9930235
3
+ size 790528