Downloads · 30 days
22
0% of all-time downloads
kenhktsui/fineweb-edu-fasttext-classifier
fineweb-edu-fasttext-classifier is a text classification model from kenhktsui. Use it when you need a label for a piece of text. It is set up for fasttext. The card lists the license as odc-by.
This is a FastText classifier for judging the educational value of web pages based on training data fineweb-edu-llama3-annotations. There are two objectives: - ⚡ throughput optimisation: It can classify more than 2000…
Downloads · 30 days
22
0% of all-time downloads
All-time downloads
199K
Public
Repo size
2.9 GB
Likes
5
Public
Click a slice to open those files.
.bin2.5 GB · 87%
From the Hugging Face model README
This is a FastText classifier for judging the educational value of web pages based on training data fineweb-edu-llama3-annotations. There are two objectives:
The FastText approach is inspired by my independent development of educational classifier based on a different definition of educational value, which can be found at kenhktsui/llm-data-textbook-quality-fasttext-classifier-v2.
from typing import List
import re
from huggingface_hub import hf_hub_download
import fasttext
model_hf = fasttext.load_model(hf_hub_download("kenhktsui/fineweb-edu-fasttext-classifier", "model.bin"))
def replace_newlines(text: str) -> str:
return re.sub("\n+", " ", text)
def predict(text_list: List[str]) -> List[dict]:
text_list = [replace_newlines(text) for text in text_list]
pred = model_hf.predict(text_list)
return [{"label": int(l[0].lstrip("__label__")), "score": s[0]}
for l, s in zip(*pred)]
predict(["Hi"])
# Output: [{'label': 0, 'score': 1.00001}]
The last 46867 samples are used as test data, but it's not the exact test data as in HuggingFaceFW/fineweb-edu-classifier
precision recall f1-score support
0 0.72 0.44 0.55 5704
1 0.73 0.87 0.80 26595
2 0.52 0.49 0.50 10350
3 0.48 0.33 0.39 3397
4 0.69 0.03 0.06 819
5 0.00 0.00 0.00 2
accuracy 0.68 46867
macro avg 0.52 0.36 0.38 46867
weighted avg 0.67 0.68 0.66 46867
The below table compares FastText model vs transformer based model.
| Label | This Model | HuggingFaceFW/fineweb-edu-classifier |
|---|---|---|
| 0 | 0.55 | 0.59 |
| 1 | 0.80 | 0.81 |
| 2 | 0.50 | 0.59 |
| 3 | 0.39 | 0.53 |
| 4 | 0.06 | 0.44 |
| 5 | 0.00 | 0.02 |
Label 0, 1, 2 are comparable to the original model.
The performance degradation starts to be noticeable in label 3, and widen further in 4, which is due to limited capacity of fasttext model.
So, this classifer can perform reasonably well in label 0, 1, 2, and also 3 with some degradation.
[ 2537 3098 65 4 0 0]
[ 944 23037 2491 123 0 0]
y_true [ 26 4742 5048 533 1 0]
[ 4 434 1846 1105 8 0]
[ 0 38 213 544 24 0]
[ 0 0 0 0 2 0]
y_pred
The model has a accuracy of 68%, and it is more likely to underpredict educational value than overpredict so. The exhibited conservatism is good for filtering large amount of data.
| Predicted - Actual Rating | Frequency | % |
|---|---|---|
| 0 | 31751 | 67.7% |
| -1 | 8078 | 17.2% |
| +1 | 6130 | 13.1% |
| -2 | 673 | 1.4% |
| +2 | 189 | 0.4% |
| -3 | 42 | 0.1% |
| +3 | 4 | 0.0% |
Spearman rank-order correlation coefficient is 0.5881 in MiniPile train split and 0.5832 in test split, indicating a moderately strong monotonic relationship in over 1 million representative document in web data.
@misc{ktsui2024cpueduvalue,
title={Low Latency CPU Based Educational Value Classifier With Generic Educational Value},
author={Ken Tsui and Huu Nguyen},
year={2024},
}