Views
No views yet
<think> reasoning block followed by a plain-language response.type_c_contrasts) was added to sharpen decision boundaries.| Parameter | Value |
|---|---|
| Training regime | fp16 mixed precision |
| Epochs | 3 |
| Per-device batch size | 2 |
| Gradient accumulation steps | 8 (effective batch = 16) |
| Learning rate | 2e-4 |
| Warmup steps | 100 |
| Max sequence length | 2048 |
| Packing | disabled |
| Checkpoint selection | best eval loss |
| Parameter | Value |
|---|---|
| Rank (r) | 16 |
| Alpha | 16 |
| Dropout | 0 |
| Bias | none |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3from peft import PeftModel
4
5base_model_id = 'unsloth/gemma-4-E2B-it'
6adapter_path = 'path/to/gemma-lora'
7token = 'your_hf_token'
8
9tokenizer = AutoTokenizer.from_pretrained(base_model_id, token=token)
10model = AutoModelForCausalLM.from_pretrained(
11 base_model_id,
12 torch_dtype=torch.float16,
13 device_map='cuda',
14 token=token,
15)
16model = PeftModel.from_pretrained(model, adapter_path)
17model.eval()
18
19messages = [{'role': 'user', 'content': 'Should I invest in index funds or individual stocks?'}]
20inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors='pt').to(model.device)
21
22with torch.no_grad():
23 output_ids = model.generate(inputs, max_new_tokens=512, temperature=0.7, do_sample=True)
24
25print(tokenizer.decode(output_ids[0][inputs.shape[-1]:], skip_special_tokens=True))