🚀 購物助手模型
本模型經過訓練,可將購物優惠信息分類,能根據用戶的查詢為其提供更優質的推薦。
🚀 快速開始
以下是使用該模型的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許可證。