🚀 ModernBERT-QnA-base-squad
このリポジトリは、質問応答タスク用にファインチューニングされた ModernBERT モデルをホストしています。このモデルはSQuADデータセットで優れた性能を発揮し、抽出型質問応答アプリケーションに最適な選択肢となっています。
📦 インストール
現在、公式のPRがマージされるまで、特定の transformers
フォークをインストールする必要があります。
> pip uninstall transformers -y
> git clone https://github.com/bakrianoo/transformers.git
> cd transformers && git checkout feat-ModernBert-QnA-Support && pip install -e .
💻 使用例
基本的な使用法
from transformers.models.modernbert.modular_modernbert import ModernBertForQuestionAnswering
from transformers import AutoTokenizer, pipeline
model_id = "rankyx/ModernBERT-QnA-base-squad"
model = ModernBertForQuestionAnswering.from_pretrained(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)
question_answerer = pipeline("question-answering", model=model, tokenizer=tokenizer)
question = "How many parameters does BLOOM contain?"
context = "BLOOM has 176 billion parameters and can generate text in 46 natural languages and 13 programming languages."
result = question_answerer(question=question, context=context)
print(result)
高度な使用法
from transformers import pipeline
model_id = "rankyx/ModernBERT-QnA-base-squad"
question_answerer = pipeline("question-answering", model=model_id)
question = "What is the capital of France?"
context = "France's capital is Paris, known for its art, gastronomy, and culture."
result = question_answerer(question=question, context=context)
print(result)
📚 ドキュメント
モデル概要
ファインチューニングプロセス
このモデルは、質問応答用の公式スクリプトを使用して、Hugging Face Transformers ライブラリでファインチューニングされました。
ファインチューニングに使用されたコマンド
python run_qa.py \
--model_name_or_path "answerdotai/ModernBERT-base" \
--dataset_name squad \
--do_train \
--do_eval \
--overwrite_output_dir \
--per_device_train_batch_size 25 \
--per_device_eval_batch_size 20 \
--eval_strategy="steps" \
--save_strategy="epoch" \
--logging_steps 50 \
--eval_steps 500 \
--learning_rate 3e-5 \
--warmup_ratio 0.1 \
--weight_decay 0.01 \
--doc_stride 128 \
--max_seq_length 384 \
--max_answer_length 128 \
--num_train_epochs 2 \
--run_name="ModernBERT-QnA-base-squad" \
--output_dir="/path/to/output/directory"
複数のGPUを使用していて、RuntimeError: Detected that you are using FX to symbolically trace a dynamo-optimized function
というエラーが発生した場合は、以下を試してください。
accelerate launch run_qa.py \
...他のパラメータ
結果
評価指標
- F1スコア: 92.59
- 完全一致率: 86.45
- トレーニング損失: 0.860
📄 ライセンス
このモデルは、Apache 2.0ライセンスの下でライセンスされています。詳細は LICENSE を参照してください。
✍️ 引用
このモデルを研究で使用する場合は、以下のように引用してください。
@misc{rankyx2024modernbertqna,
title={ModernBERT-QnA-base-squad},
author={Abu Bakr},
year={2024},
howpublished={\url{https://huggingface.co/rankyx/ModernBERT-QnA-base-squad}}
}
🙌 謝辞
このモデルをファインチューニングしてデプロイするためのツールとリソースを提供してくれたHugging Faceチームに特別な感謝を申し上げます。
🤝 フィードバックと貢献
フィードバックと貢献を歓迎します!気軽にイシューを開いたり、プルリクエストを送信してください。