kanana-safeguard-bnb-4bit
Collection
kanana-safeguard-bnb-4bit
โข
3 items
โข
Updated
pip install transformers accelerate bitsandbytes torch
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
model_name = "nxtcloud-org/kanana-safeguard-siren-8b-4bit"
# BitsAndBytesConfig ์ค์
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16
)
# ๋ชจ๋ธ๊ณผ ํ ํฌ๋์ด์ ๋ก๋
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
quantization_config=bnb_config,
device_map="auto",
trust_remote_code=True
)
# ์ฌ์ฉ ์์ - ์์ ์ฑ ๊ฒ์ฆ
text = "์ด๊ฒ์ ๊ฒ์ฆํ ํ
์คํธ์
๋๋ค."
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model.generate(
**inputs,
max_length=512,
temperature=0.7,
do_sample=True,
pad_token_id=tokenizer.eos_token_id
)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(result)
์ด ์์ํ ๋ชจ๋ธ์ ์๋ณธ ๋ชจ๋ธ๊ณผ ๋์ผํ Apache License 2.0์ ๋ฐ๋ฆ ๋๋ค.
Copyright 2025 Kakao Corp. (Original model)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@misc{kakao-kanana-safeguard-siren-8b,
title={Kanana Safeguard Siren 8B},
author={Kakao Corp},
year={2024},
publisher={Hugging Face},
url={https://huggingface.co/kakaocorp/kanana-safeguard-8b}
}
Base model
kakaocorp/kanana-safeguard-8b