🚀 精细网络教育分类器(FineWeb - Edu classifier)
这是一个用于判断网页教育价值的分类器。它旨在从网络数据集中筛选和整理教育内容,基于 [LLama3 - 70B - instruct](https://huggingface.co/meta - llama/Meta - Llama - 3 - 70B - Instruct) 为 FineWeb 数据集中的网页样本生成的 450k [标注](https://huggingface.co/datasets/HuggingFaceFW/fineweb - edu - llama3 - annotations) 进行训练。
我们使用该分类器构建了 [精细网络教育数据集(FineWeb - Edu)](https://huggingface.co/datasets/HuggingFaceFW/fineweb - edu)。
🚀 快速开始
如何在 Transformers 中使用
要加载精细网络教育分类器,请使用以下代码:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/fineweb-edu-classifier")
model = AutoModelForSequenceClassification.from_pretrained("HuggingFaceTB/fineweb-edu-classifier")
text = "This is a test sentence."
inputs = tokenizer(text, return_tensors="pt", padding="longest", truncation=True)
outputs = model(**inputs)
logits = outputs.logits.squeeze(-1).float().detach().numpy()
score = logits.item()
result = {
"text": text,
"score": score,
"int_score": int(round(max(0, min(score, 5)))),
}
print(result)
✨ 主要特性
该分类器主要用于判断网页的教育价值,能够从网络数据集中筛选和整理教育内容。
📚 详细文档
模型概述
这是一个用于判断网页教育价值的分类器,其目的是从网络数据集中筛选和整理教育内容。它基于 [LLama3 - 70B - instruct](https://huggingface.co/meta - llama/Meta - Llama - 3 - 70B - Instruct) 为 FineWeb 数据集中的网页样本生成的 450k [标注](https://huggingface.co/datasets/HuggingFaceFW/fineweb - edu - llama3 - annotations) 进行训练。
训练过程
该分类器在 450,000 对网页样本及其 0 到 5 的分数上进行训练,这些分数由 Llama3 生成。样本根据其教育质量进行标注,0 表示无教育价值,5 表示教育价值高。
以下是用于 Llama3 标注的提示:
我们在 [Snowflake - arctic - embed](https://huggingface.co/Snowflake/snowflake - arctic - embed - m) 上添加了一个具有单一回归输出的分类头,并以 3e - 4 的学习率对模型进行了 20 个 epoch 的训练。在训练期间,嵌入层和编码器层被冻结,以专注于分类头。当使用分数阈值 3 将模型转换为二元分类器时,模型的 F1 分数达到了 82%。
训练详情
属性 |
详情 |
模型类型 |
在 Snowflake - arctic - embed 基础上添加分类头 |
训练数据 |
来自 Llama3 标注的 450,000 个样本 |
训练轮数 |
20 |
学习率 |
3e - 4 |
评估指标 |
F1 分数 |
分类报告
我们将回归模型的预测视为离散类别,以在 46867 个 Llama3 标注样本的保留集上计算指标。
precision recall f1 - score support
0 0.75 0.49 0.59 5694
1 0.78 0.84 0.81 26512
2 0.57 0.61 0.59 10322
3 0.56 0.50 0.53 3407
4 0.58 0.35 0.44 807
5 0.33 0.01 0.02 125
accuracy 0.71 46867
macro avg 0.60 0.47 0.50 46867
weighted avg 0.71 0.71 0.71 46867
混淆矩阵
我们验证了预测的教育分数确实接近其真实值,并且主要受到噪声标注的影响。
2791 2858 45 0 0 0
919 22343 3180 69 1 0
y_true 3 3225 6330 757 7 0
1 66 1473 1694 173 0
0 4 98 420 283 2
0 0 18 85 21 1
y_pred
🔧 技术细节
该分类器基于 Transformer 架构,通过在 [Snowflake - arctic - embed](https://huggingface.co/Snowflake/snowflake - arctic - embed - m) 上添加分类头进行训练。在训练过程中,冻结了嵌入层和编码器层,专注于分类头的训练。通过将回归模型的预测视为离散类别,在保留集上计算评估指标,如 F1 分数等。
📄 许可证
本项目采用 Apache - 2.0 许可证。
🔧 局限性
虽然精细网络教育分类器在为精细网络数据集区分高质量教育内容方面表现良好,但仍存在一些局限性:
⚠️ 重要提示
- 适用范围:该模型在其他数据集上的性能可能会有所变化,特别是对于分布外的样本。它主要关注与小学和中学教育水平相关的教育内容,对于高等教育或专业领域的内容,其性能可能不佳。
- 偏差问题:模型的性能取决于训练数据的质量和代表性以及用于标注的大语言模型(LLM)。两者中的偏差都可能影响分类器的判断。模型可能会对看起来更学术的内容给出较高分数,我们建议使用
int_score >= 3
作为数据整理的阈值。
- 上下文问题:分类器在评估单个网页或摘录时不考虑更广泛的上下文,这可能会影响其在某些场景下的有效性。
训练和推理代码可在 GitHub 上获取:
https://github.com/huggingface/cosmopedia/tree/main/classification