🚀 Peft模型卡
這是一個針對Meta的Llama 2 7B進行微調的適配器,用於將捷克語文本翻譯成英語。
🚀 快速開始
此適配器必須加載到Llama 2 7B之上。它使用QLoRA進行了微調。為獲得最佳效果,基礎模型必須使用微調期間使用的完全相同的配置加載。
你可以使用以下代碼加載模型:
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
import torch
from peft import PeftModel
base_model = "meta-llama/Llama-2-7b-hf"
compute_dtype = getattr(torch, "float16")
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=compute_dtype,
bnb_4bit_use_double_quant=True,
)
model = AutoModelForCausalLM.from_pretrained(
original_model_directory, device_map={"": 0}, quantization_config=bnb_config
)
tokenizer = AutoTokenizer.from_pretrained(base_model, use_fast=True)
model = PeftModel.from_pretrained(model, "kaitchup/Llama-2-7b-mt-Czech-to-English")
然後,按如下方式運行模型:
my_text = ""
prompt = my_text+" ###>"
tokenized_input = tokenizer(prompt, return_tensors="pt")
input_ids = tokenized_input["input_ids"].cuda()
generation_output = model.generate(
input_ids=input_ids,
num_beams=10,
return_dict_in_generate=True,
output_scores=True,
max_new_tokens=130
)
for seq in generation_output.sequences:
output = tokenizer.decode(seq, skip_special_tokens=True)
print(output.split("###>")[1].strip())
✨ 主要特性
- 專為將捷克語翻譯成英語而微調。
- 基於Meta的Llama 2 7B模型,使用LoRA適配器技術。
📚 詳細文檔
模型詳情
模型描述
- 開發者:The Kaitchup
- 模型類型:Llama 2 7B的LoRA適配器
- 語言(NLP):捷克語、英語
- 許可證:MIT許可證
屬性 |
詳情 |
模型類型 |
Llama 2 7B的LoRA適配器 |
訓練數據 |
kaitchup/opus-Czech-to-English |
📄 許可證
本模型採用MIT許可證。
📞 模型卡聯繫方式
The Kaitchup