🚀 Qwen2-7B-Instruct-Better-Translation
Qwen2-7B-Instruct-Better-Translationは、Qwen2-7B-Instructをベースにした言語モデルで、英語から中国語への翻訳を改善するために最適化されています。
🚀 クイックスタート
Qwen2-7B-Instruct-Better-Translationは、高品質な英語から中国語への翻訳を提供するように設計されています。特に、逐語的な翻訳ではなく、自然で慣用的な翻訳を生成することに重点を置いています。
✨ 主な機能
- Qwen2-7B-Instructをベースにした言語モデルで、英語から中国語への翻訳を最適化。
- 自然で慣用的な翻訳を生成するように微調整されています。
- 複雑なニュアンスのある英語のテキストに対しても正確で流暢な翻訳を提供します。
📦 インストール
このモデルを使用するには、互換性の問題を避けるために、transformers>=4.37.0
をインストールしてください。
💻 使用例
基本的な使用法
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "sevenone/Qwen2-7B-Instruct-Better-Translation"
device = "cuda"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype="auto",
device_map="auto"
)
prompt = "Translate the following sentence to Chinese: 'Artificial intelligence is transforming industries worldwide.'"
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(device)
generated_ids = model.generate(
model_inputs.input_ids,
max_new_tokens=512
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)
📚 ドキュメント
モデル概要
Qwen2-7B-Instruct-Better-Translationは、Qwen2-7B-Instructをベースにした微調整された言語モデルで、英語から中国語への翻訳を改善するために特に最適化されています。このモデルは、Direct Preference Optimization (DPO) を使用して、流暢で慣用的な翻訳 (選択) を逐語的な翻訳 (拒否) よりも優先するカスタムデータセットで微調整されました。
開発者
sevenone
詳細情報
項目 |
詳細 |
ライセンス |
Qwen2 License |
ベースモデル |
Qwen2-7B-Instruct |
モデルサイズ |
7B |
コンテキスト長 |
131,072トークン (Qwen2-7B-Instructから継承) |
詳細については、GitHubを参照してください。
トレーニングの詳細
このモデルは、Direct Preference Optimization (DPO) を使用して微調整されました。これは、ユーザーが提供した嗜好に基づいて、モデルが特定の出力を他の出力よりも好むように最適化する方法です。トレーニングデータセットは、英語の原文と、対応する翻訳が「選択」 (慣用的) または「拒否」 (逐語的) としてラベル付けされたもので構成されています。
- トレーニングフレームワーク: Hugging Face Transformers
- オプティマイザ: AdamW
- トレーニング方法: Lora with direct preference optimization
- トレーニングデータ: 英語から中国語への翻訳用のカスタム嗜好データセット
- 嗜好タイプ: 慣用的な翻訳 (選択) を逐語的な翻訳 (拒否) よりも優先
📄 ライセンス
Qwen2 License
引用
もしsevenone/qwen2-7b-instruct-better-translationがあなたの作業に役立った場合は、以下のように引用してください。
@misc{sevenone_2024,
author = {sevenone},
title = {Qwen2-7B-Instruct-Better-Translation},
year = 2024,
url = {https://huggingface.co/sevenone/Qwen2-7B-Instruct-Better-Translation},
publisher = {Hugging Face}
}