Views
No views yet
Gemma 2 Baku 2B Instruct (rinna/gemma-2-baku-2b-it)
rinna/gemma-2-baku-2b + 1.0 * (google/gemma-2-2b-it - google/gemma-2-2b)1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4model_id = "rinna/gemma-2-baku-2b-it"
5dtype = torch.bfloat16
6
7tokenizer = AutoTokenizer.from_pretrained(model_id)
8model = AutoModelForCausalLM.from_pretrained(
9 model_id,
10 device_map="cuda",
11 torch_dtype=dtype,
12 attn_implementation="eager",
13)
14
15chat = [
16 { "role": "user", "content": "西田幾多郎とはどんな人物ですか?" },
17]
18prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
19
20input_ids = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt").to(model.device)
21outputs = model.generate(
22 input_ids,
23 max_new_tokens=512,
24)
25
26response = tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True)
27print(response)1@misc{rinna-gemma-2-baku-2b-it,
2 title = {rinna/gemma-2-baku-2b-it},
3 author = {Chen, Xinqi and Wakatsuki, Toshiaki and Sawada, Kei},
4 url = {https://huggingface.co/rinna/gemma-2-baku-2b-it}
5}
6
7@inproceedings{sawada2024release,
8 title = {Release of Pre-Trained Models for the {J}apanese Language},
9 author = {Sawada, Kei and Zhao, Tianyu and Shing, Makoto and Mitsui, Kentaro and Kaga, Akio and Hono, Yukiya and Wakatsuki, Toshiaki and Mitsuda, Koh},
10 booktitle = {Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024)},
11 month = {5},
12 year = {2024},
13 pages = {13898--13905},
14 url = {https://aclanthology.org/2024.lrec-main.1213},
15 note = {\url{https://arxiv.org/abs/2404.01657}}
16}1@article{gemma-2-2024,
2 title = {Gemma 2},
3 url = {https://www.kaggle.com/models/google/gemma-2},
4 publisher = {Kaggle},
5 author = {Gemma Team},
6 year = {2024}
7}
8
9@article{huang2023chat,
10 title = {Chat Vector: A Simple Approach to Equip LLMs with Instruction Following and Model Alignment in New Languages},
11 author = {Huang, Shih-Cheng and Li, Pin-Zu and Hsu, Yu-Chi and Chen, Kuang-Ming and Lin, Yu Tung and Hsiao, Shih-Kai and Tzong-Han Tsai, Richard and Lee, Hung-yi},
12 year = {2023},
13 url = {https://arxiv.org/abs/2310.04799}
14}
15
16@article{hong2024orpo,
17 title = {ORPO: Monolithic Preference Optimization without Reference Model},
18 author = {Hong, Jiwoo and Lee, Noah and Thorne, James},
19 year = {2024},
20 url = {https://arxiv.org/abs/2403.07691}
21}