Downloads · 30 days
2
6% of all-time downloads
fukugawa/gemma-2-2b-finetuned-bnb-4bit
gemma-2-2b-finetuned-bnb-4bit is a text generation model from fukugawa. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as gemma.
fukugawa/gemma-2-2b-finetunedをBitsAndBytes(0.44.1)で4bit量子化
Downloads · 30 days
2
6% of all-time downloads
All-time downloads
31
Public
Parameters
2.6B
2.4 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors2.3 GB · 98%
How the weights are stored.
U82B · 77%
From the Hugging Face model README
fukugawa/gemma-2-2b-finetunedをBitsAndBytes(0.44.1)で4bit量子化
以下はBitsAndBytesで4bit量子化して自分のリポジトリにPushするまでのサンプルコードです。
# python 3.10
pip install bitsandbytes==0.44.1
pip install accelerate==1.2.1
pip install transformers==4.50.0
pip install huggingface_hub[cli]
# アクセストークンを入力してログイン
huggingface-cli login
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
model_id = "fukugawa/gemma-2-2b-finetuned"
repo_id = "fukugawa/gemma-2-2b-finetuned-bnb-4bit"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=bnb_config, device_map="auto")
tokenizer.push_to_hub(repo_id)
model.push_to_hub(repo_id)