🚀 购物助手模型
本模型经过训练,可将购物优惠信息分类,能根据用户的查询为其提供更优质的推荐。
🚀 快速开始
以下是使用该模型的Python代码示例:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
tokenizer = AutoTokenizer.from_pretrained("selvaonline/shopping-assistant")
model = AutoModelForSequenceClassification.from_pretrained("selvaonline/shopping-assistant")
text = "I'm looking for headphones"
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.sigmoid(outputs.logits)
categories = ["electronics", "clothing", "home", "kitchen", "toys", "other"]
top_categories = []
for i, score in enumerate(predictions[0]):
if score > 0.5:
top_categories.append((categories[i], score.item()))
top_categories.sort(key=lambda x: x[1], reverse=True)
for category, score in top_categories:
print(f"{category}: {score:.4f}")
✨ 主要特性
- 基于DistilBERT模型,并在购物优惠数据集上进行了微调。
- 能够将购物优惠信息分类为以下类别:电子产品、服装、家居、厨房用品、玩具、其他。
- 可用于为用户提供购物推荐。
📦 安装指南
文档未提及具体安装步骤,可参考transformers
库的官方安装说明。
💻 使用示例
基础用法
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
tokenizer = AutoTokenizer.from_pretrained("selvaonline/shopping-assistant")
model = AutoModelForSequenceClassification.from_pretrained("selvaonline/shopping-assistant")
text = "I'm looking for headphones"
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.sigmoid(outputs.logits)
categories = ["electronics", "clothing", "home", "kitchen", "toys", "other"]
top_categories = []
for i, score in enumerate(predictions[0]):
if score > 0.5:
top_categories.append((categories[i], score.item()))
top_categories.sort(key=lambda x: x[1], reverse=True)
for category, score in top_categories:
print(f"{category}: {score:.4f}")
📚 详细文档
模型描述
该模型基于DistilBERT,并在购物优惠数据集上进行了微调。它经过训练,可将优惠信息分类为以下类别:电子产品、服装、家居、厨房用品、玩具、其他。
预期用途与限制
本模型旨在用于对购物优惠信息进行分类,并为用户提供推荐。不应用于其他任何目的。
训练数据
模型在来自DealsFinders.com的购物优惠数据集上进行训练。该数据集根据优惠标题和描述中的关键词自动标注。
训练过程
模型使用Hugging Face Transformers库进行训练。采用多标签分类方法在优惠数据集上进行微调。
评估结果
模型在保留的验证集上进行评估。评估指标包括准确率、精确率、召回率和F1分数。
🔧 技术细节
- 模型类型:基于DistilBERT微调的多标签分类模型。
- 训练数据:来自DealsFinders.com的购物优惠数据集,根据关键词自动标注。
- 训练库:Hugging Face Transformers库。
- 训练方法:多标签分类方法。
- 评估指标:准确率、精确率、召回率和F1分数。
📄 许可证
本项目采用MIT许可证。