🚀 MiniLM-L6-mnli
このモデルは、テキスト分類やゼロショット分類に特化しており、精度を指標として評価されます。高速な推論が可能で、特定のタスクにおいて有効です。
🚀 クイックスタート
このセクションでは、MiniLM-L6-mnliモデルの基本的な使い方を説明します。
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "MoritzLaurer/MiniLM-L6-mnli"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
premise = "I liked the movie"
hypothesis = "The movie was good."
input = tokenizer(premise, hypothesis, truncation=True, return_tensors="pt")
output = model(input["input_ids"].to(device))
prediction = torch.softmax(output["logits"][0], -1).tolist()
label_names = ["entailment", "neutral", "contradiction"]
prediction = {name: round(float(pred) * 100, 1) for pred, name in zip(prediction, label_names)}
print(prediction)
✨ 主な機能
- このモデルは、MultiNLIデータセットで学習されています。
- ベースモデルはMicrosoftのMiniLM-L6で、非常に高速ですが、他のモデルよりも精度がやや低いです。
📦 インストール
このモデルを使用するには、transformers
ライブラリが必要です。以下のコマンドでインストールできます。
pip install transformers torch
💻 使用例
基本的な使用法
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "MoritzLaurer/MiniLM-L6-mnli"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
premise = "I liked the movie"
hypothesis = "The movie was good."
input = tokenizer(premise, hypothesis, truncation=True, return_tensors="pt")
output = model(input["input_ids"].to(device))
prediction = torch.softmax(output["logits"][0], -1).tolist()
label_names = ["entailment", "neutral", "contradiction"]
prediction = {name: round(float(pred) * 100, 1) for pred, name in zip(prediction, label_names)}
print(prediction)
📚 ドキュメント
学習データ
MultiNLIデータセットを使用して学習されています。
学習手順
MiniLM-L6-mnli-binaryは、Hugging Faceのトレーナーを使用して、以下のハイパーパラメータで学習されました。
training_args = TrainingArguments(
num_train_epochs=5, # total number of training epochs
learning_rate=2e-05,
per_device_train_batch_size=32, # batch size per device during training
per_device_eval_batch_size=32, # batch size for evaluation
warmup_ratio=0.1, # number of warmup steps for learning rate scheduler
weight_decay=0.06, # strength of weight decay
fp16=True # mixed precision training
)
評価結果
このモデルは、MultiNLIの(マッチした)テストセットを使用して評価されました。精度: 0.814
🔧 技術詳細
このモデルは、MicrosoftのMiniLM-L6をベースに構築されており、MultiNLIデータセットで学習されています。学習にはHugging Faceのトレーナーを使用し、特定のハイパーパラメータを設定しています。
📄 ライセンス
原文書にライセンス情報は記載されていません。
属性 |
詳情 |
モデルタイプ |
テキスト分類、ゼロショット分類 |
学習データ |
MultiNLI |