Downloads · 30 days
9
36% of all-time downloads
mssfj/gemma-2-9b-4bit-magpie
gemma-2-9b-4bit-magpie is a machine learning model from mssfj. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as gemma.
このモデルはgemma-2-9bをbitsandbytesで4bit量子化し、llm-jp/magpie-sft-v0.1を用いQloraした loraアダプターになります。
Downloads · 30 days
9
36% of all-time downloads
All-time downloads
25
Public
Repo size
2.6 GB
Likes
0
Public
Click a slice to open those files.
.pt1.7 GB · 66%
From the Hugging Face model README
このモデルはgemma-2-9bをbitsandbytesで4bit量子化し、llm-jp/magpie-sft-v0.1を用いQloraした loraアダプターになります。
ベースモデルはmssfj/gemma-2-9b-bnb-4bit-chat-templateになります。
使用方法は以下です。
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
import torch
from peft import PeftModel, PeftConfig
model_name = "mssfj/gemma-2-9b-bnb-4bit-chat-template"
lora_weight = "mssfj/gemma-2-9b-4bit-magpie"
quantization_config = BitsAndBytesConfig(
load_in_4bit=False,
bnb_4bit_compute_dtype=torch.bfloat16,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=False
)
base_model = AutoModelForCausalLM.from_pretrained(
model_name,
quantization_config=quantization_config,
device_map="auto"
)
model = PeftModel.from_pretrained(base_model, lora_weight)
tokenizer = AutoTokenizer.from_pretrained(model_name)
input="""日本で一番高い山は?
"""
messages = [
{"role": "system", "content": """あなたは誠実で優秀な日本人のアシスタントです。あなたはユーザと日本語で会話しています。アシスタントは以下の原則を忠実に守り丁寧に回答します。
- 日本語で簡潔に回答する
- 回答は必ず完結した文で終える
- 質問の文脈に沿った自然な応答をする
"""},
{"role": "user", "content": input},
]
input_ids = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
outputs = model.generate(
input_ids,
max_new_tokens=512,
temperature=0.2,
do_sample=True,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.pad_token_id,
early_stopping=True,
)
response = tokenizer.decode(outputs[0][input_ids.shape[1]:], skip_special_tokens=True)
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
Use the code below to get started with the model.
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]