openhermes-gemma-2b-it is a variant of the Gemma 2B language model, which has been further fine-tuned on the OpenHermes-2.5 preference dataset
using QLoRA. This fine-tuning process enhances the model's ability to understand and generate responses that align
with user preferences in conversational settings.
The instruction-tuned models use a chat template that must be adhered to for conversational use.
The easiest way to apply it is using the tokenizer's built-in chat template, as shown in the following snippet.
Let's load the model and apply the chat template to a conversation. In this example, we'll start with a single user interaction:
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import transformers
3import torch
4
5model_id = "Syed-Hasan-8503/openhermes-gemma-2b-it"
6dtype = torch.bfloat16
7
8tokenizer = AutoTokenizer.from_pretrained(model_id)
9model = AutoModelForCausalLM.from_pretrained(
10 model_id,
11 device_map="cuda",
12 torch_dtype=dtype,
13)
14
15chat = [{ "role": "user", "content": "What is Machine Learning?" }]
16prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
1inputs = tokenizer.encode(prompt, add_special_tokens=True, return_tensors="pt")
2outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=250)
3print(tokenizer.decode(outputs[0]))
1base_model: google/gemma-2b-it
2model_type: GemmaForCausalLM
3tokenizer_type: GemmaTokenizer
4trust_remote_code: true
5
6load_in_8bit: false
7load_in_4bit: true
8strict: false
9
10rl: dpo
11chat_template: chatml
12datasets:
13 - path: mlabonne/chatml-OpenHermes2.5-dpo-binarized-alpha
14 split: train
15 type: chatml.intel
16dataset_prepared_path:
17val_set_size: 0.01
18output_dir: ./out
19
20adapter: qlora
21lora_model_dir:
22
23sequence_len: 1800
24sample_packing: false
25pad_to_sequence_len: false
26
27lora_r: 16
28lora_alpha: 16
29lora_dropout: 0.05
30lora_target_linear: true
31lora_fan_in_fan_out:
32lora_target_modules:
33
34wandb_project: axolotl-gemma-dpo
35wandb_entity:
36wandb_watch:
37wandb_name:
38wandb_log_model:
39
40gradient_accumulation_steps: 8
41micro_batch_size: 1
42num_epochs: 1
43optimizer: paged_adamw_32bit
44lr_scheduler: cosine
45learning_rate: 5e-7
46
47train_on_inputs: false
48group_by_length: false
49bf16: true
50fp16: false
51tf32: true
52
53gradient_checkpointing: true
54early_stopping_patience:
55resume_from_checkpoint:
56local_rank:
57logging_steps: 1
58xformers_attention:
59flash_attention: false
60
61warmup_steps: 100
62evals_per_epoch: 1
63eval_table_size:
64eval_table_max_new_tokens: 128
65save_steps: 1000
66max_steps: 1000
67debug:
68deepspeed:
69weight_decay: 0.0
70fsdp:
71fsdp_config:
72special_tokens: