Views
No views yet
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_name = "soka0000/vclm-korean-7b"
5
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(
8 model_name,
9 torch_dtype=torch.bfloat16,
10 device_map="auto"
11)
12
13messages = [
14 {"role": "user", "content": "2+2는 무엇인가요?"}
15]
16
17input_text = tokenizer.apply_chat_template(
18 messages,
19 tokenize=False,
20 add_generation_prompt=True
21)
22
23inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
24
25outputs = model.generate(
26 **inputs,
27 max_new_tokens=256,
28 temperature=0.7,
29 top_p=0.9,
30 do_sample=True
31)
32
33response = tokenizer.decode(outputs[0][inputs['input_ids'].shape[1]:], skip_special_tokens=True)
34print(response)1from transformers import BitsAndBytesConfig
2
3quantization_config = BitsAndBytesConfig(
4 load_in_4bit=True,
5 bnb_4bit_compute_dtype=torch.float16,
6 bnb_4bit_use_double_quant=True,
7 bnb_4bit_quant_type="nf4"
8)
9
10model = AutoModelForCausalLM.from_pretrained(
11 "soka0000/vclm-korean-7b",
12 quantization_config=quantization_config,
13 device_map="auto"
14)1@misc{vclm-korean-7b,
2 author = {Soka0000},
3 title = {vclm-korean-7b: Korean Language Model},
4 year = {2025},
5 publisher = {HuggingFace},
6 howpublished = {\url{https://huggingface.co/soka0000/vclm-korean-7b}},
7}