Downloads · 30 days
0
GoldWings/vocational-edu-classifier
vocational-edu-classifier is a text classification model from GoldWings. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as apache-2.0.
本模型是基于 BERT/RoBERTa 系列预训练模型微调的中文职业教育文本分类模型,专门针对职业教育领域的专业分类、需求分析、政策解读等场景进行优化。
Downloads · 30 days
0
Access
Public
Updated Apr 7, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.py30.3 KB · 63%
From the Hugging Face model README
本模型是基于 BERT/RoBERTa 系列预训练模型微调的中文职业教育文本分类模型,专门针对职业教育领域的专业分类、需求分析、政策解读等场景进行优化。
| 属性 | 说明 |
|---|---|
| 基础模型 | bert-base-chinese |
| 参数量 | 110M |
| 输入长度 | 最大 512 tokens |
| 输出类别 | 多分类 (可配置) |
| 训练数据 | 50,000+ 标注样本 |
| 训练框架 | PyTorch + Transformers |
| 模型版本 | v1.0 |
pip install torch transformers pandas scikit-learn
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# 加载模型和分词器
model_name = "GoldWings/vocational-edu-classifier"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
# 分类标签
labels = [
"装备制造类",
"电子信息类",
"财经商贸类",
"文化艺术类",
"教育体育类"
]
# 推理
text = "工业机器人技术、机电一体化技术、数控技术"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
outputs = model(**inputs)
predicted_class = torch.argmax(outputs.logits, dim=1).item()
print(f"专业分类结果: {labels[predicted_class]}")
print(f"置信度: {torch.softmax(outputs.logits, dim=1)[0][predicted_class]:.2%}")
from transformers import pipeline
classifier = pipeline(
"text-classification",
model="your-username/vocational-edu-classifier",
tokenizer="your-username/vocational-edu-classifier"
)
# 批量分类
texts = [
"数控技术、模具设计、机械制造",
"电子商务、市场营销、现代物流",
"计算机网络技术、软件开发、人工智能"
]
results = classifier(texts)
for text, result in zip(texts, results):
print(f"文本: {text}")
print(f"分类: {result['label']} (置信度: {result['score']:.2%})\n")
import pandas as pd
from transformers import AutoTokenizer, AutoModelForSequenceClassification
# 加载模型
model_name = "your-username/vocational-edu-classifier"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
labels = ["装备制造", "电子信息", "财经商贸", "文化艺术", "教育体育", "其他"]
def predict_category(text, batch_size=32):
"""批量预测专业分类"""
predictions = []
# 分批处理
for i in range(0, len(texts), batch_size):
batch_texts = texts[i:i+batch_size]
inputs = tokenizer(batch_texts, return_tensors="pt",
truncation=True, max_length=512, padding=True)
outputs = model(**inputs)
batch_preds = torch.argmax(outputs.logits, dim=1).tolist()
predictions.extend([labels[p] for p in batch_preds])
return predictions
# 读取Excel数据
df = pd.read_excel("专业数据.xlsx")
df["预测分类"] = predict_category(df["专业名称"].tolist())
df.to_excel("分类结果.xlsx", index=False)
print("分类完成!")
├── config.json # 模型配置文件
├── model.safetensors # 模型权重 (推荐格式)
├── model.bin # 模型权重 (兼容格式)
├── tokenizer.json # 分词器配置
├── tokenizer_config.json # 分词器配置
├── vocab.txt # 词表
├── special_tokens_map.json # 特殊token映射
└── README.md # 本文档
training_config = {
"learning_rate": 2e-5,
"per_device_train_batch_size": 32,
"per_device_eval_batch_size": 32,
"num_train_epochs": 3,
"warmup_ratio": 0.1,
"weight_decay": 0.01,
"logging_steps": 100,
"save_steps": 1000,
"eval_steps": 1000,
"load_best_model_at_end": True,
"metric_for_best_model": "f1"
}
| 数据集 | Accuracy | Precision | Recall | F1 |
|---|---|---|---|---|
| 测试集 | 93.5% | 93.2% | 93.5% | 93.3% |
| 验证集 | 94.1% | 93.9% | 94.1% | 94.0% |
| 类别 | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| 装备制造类 | 95.2% | 94.8% | 95.0% | 5234 |
| 电子信息类 | 93.1% | 92.7% | 92.9% | 4123 |
| 财经商贸类 | 92.8% | 93.5% | 93.1% | 3891 |
| 文化艺术类 | 91.5% | 90.2% | 90.8% | 2341 |
| 教育体育类 | 94.3% | 95.1% | 94.7% | 1876 |
如果你有自定义数据集,可以进一步微调模型:
from transformers import Trainer, TrainingArguments
from datasets import load_dataset
# 加载数据集
dataset = load_dataset("csv", data_files="train.csv")
# 预处理
def tokenize_function(examples):
return tokenizer(examples["text"], truncation=True, padding="max_length")
tokenized_dataset = dataset.map(tokenize_function, batched=True)
# 训练参数
training_args = TrainingArguments(
output_dir="./results",
num_train_epochs=3,
per_device_train_batch_size=32,
learning_rate=2e-5,
evaluation_strategy="epoch",
save_strategy="epoch",
load_best_model_at_end=True,
metric_for_best_model="f1"
)
# 开始训练
trainer = Trainer(
model=model,
args=training_args,
train_dataset=tokenized_dataset["train"],
eval_dataset=tokenized_dataset["validation"]
)
trainer.train()
trainer.save_model("./fine-tuned-model")
# 分析专业群建设情况
major_groups = [
"工业机器人技术、机电一体化技术、智能制造装备技术",
"电子商务、网络营销、现代物流管理",
"大数据技术、人工智能技术应用、计算机应用技术"
]
results = classifier(major_groups)
for group, result in zip(major_groups, results):
print(f"专业群: {group}")
print(f"分类: {result['label']} ({result['score']:.2%})\n")
# 分析产业人才需求
industry_text = """
装备制造业:数控技术人才需求旺盛,月薪 8000-15000 元
电子信息产业:嵌入式开发、物联网技术人才紧缺
现代服务业:跨境电商、新媒体运营需求快速增长
"""
inputs = tokenizer(industry_text, return_tensors="pt")
outputs = model(**inputs)
top_predictions = torch.topk(outputs.logits, k=3, dim=1)
print("产业需求分析:")
for i, (idx, score) in enumerate(zip(top_predictions.indices[0], top_predictions.values[0])):
print(f"{i+1}. {labels[idx.item()]}: {torch.softmax(top_predictions.values[0], dim=0)[i]:.2%}")
本模型仅供研究和学习使用,如需商业应用请自行评估适用性。
如果你在研究中使用了本模型,请按以下格式引用:
@misc{vocational-edu-classifier,
author = {Your Name},
title = {职业教育专业分类模型 - Vocational Education Text Classifier},
year = {2024},
publisher = {HuggingFace},
url = {https://huggingface.co/your-username/vocational-edu-classifier}
}
pipeline 接口支持批量处理,提高效率⭐ 如果这个模型对你有帮助,请给个 Star!
如有问题或建议,请提交 Issue 或联系作者。