🚀 WebOrganizer/TopicClassifier
TopicClassifier 能够根据网页的 URL 和文本内容,将网页内容划分为 17 个类别。该模型基于 gte-base-en-v1.5 微调而来,拥有 1.4 亿参数,在特定训练数据上进行了优化。
[论文] [网站] [GitHub]
✨ 主要特性
- 基于网页的 URL 和文本内容,将网页内容组织成 17 个类别。
- 以 gte-base-en-v1.5 为基础模型,参数规模达 1.4 亿。
- 在特定训练数据上进行了两阶段的微调,提升分类性能。
📦 安装指南
文档未提及具体安装步骤,跳过该章节。
💻 使用示例
基础用法
此分类器期望输入采用以下格式:
{url}
{text}
示例代码如下:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("WebOrganizer/TopicClassifier")
model = AutoModelForSequenceClassification.from_pretrained(
"WebOrganizer/TopicClassifier",
trust_remote_code=True,
use_memory_efficient_attention=False)
web_page = """http://www.example.com
How to build a computer from scratch? Here are the components you need..."""
inputs = tokenizer([web_page], return_tensors="pt")
outputs = model(**inputs)
probs = outputs.logits.softmax(dim=-1)
print(probs.argmax(dim=-1))
你可以使用 softmax 函数将模型的 logits
转换为概率分布,该分布涵盖以下 24 个类别(按标签顺序排列,也可查看模型配置中的 id2label
和 label2id
):
- 成人内容
- 艺术与设计
- 软件开发
- 犯罪与法律
- 教育与就业
- 硬件
- 娱乐
- 社交生活
- 时尚与美容
- 金融与商业
- 食品与餐饮
- 游戏
- 健康
- 历史
- 家居与爱好
- 工业
- 文学
- 政治
- 宗教
- 科学与技术
- 软件
- 体育与健身
- 交通
- 旅游
这些类别的完整定义可在 分类法配置 中找到。
高级用法
为了实现高效推理,我们建议你启用未填充(unpadding)和内存高效注意力机制,使用高效的 gte-base-en-v1.5 实现。这 需要安装 xformers
(更多信息请参考 此处),并按如下方式加载模型:
AutoModelForSequenceClassification.from_pretrained(
"WebOrganizer/TopicClassifier",
trust_remote_code=True,
unpad_inputs=True,
use_memory_efficient_attention=True,
torch_dtype=torch.bfloat16
)
📚 详细文档
所有领域分类器
🔧 技术细节
模型是基于 gte-base-en-v1.5 进行微调的,该基础模型拥有 1.4 亿参数。微调过程分为两个阶段,使用了以下训练数据:
- WebOrganizer/TopicAnnotations-Llama-3.1-8B:由 Llama-3.1-8B 标注的 100 万篇文档(第一阶段训练)
- WebOrganizer/TopicAnnotations-Llama-3.1-405B-FP8:由 Llama-3.1-405B-FP8 标注的 10 万篇文档(第二阶段训练)
📄 许可证
文档未提及许可证信息,跳过该章节。
📖 引用
如果你使用了该模型,请引用以下论文:
@article{wettig2025organize,
title={Organize the Web: Constructing Domains Enhances Pre-Training Data Curation},
author={Alexander Wettig and Kyle Lo and Sewon Min and Hannaneh Hajishirzi and Danqi Chen and Luca Soldaini},
journal={arXiv preprint arXiv:2502.10341},
year={2025}
}