Views
No views yet
| Property | Value |
|---|---|
| Base Model | ibm-granite/granite-3.2-8b-instruct |
| Parameters | ~8B (base) + ~198MB (adapter) |
| Fine-Tuning Method | QLoRA SFT (4-bit quantized base + LoRA adapter) |
| LoRA Rank | 16 |
| LoRA Alpha | 32 |
| LoRA Dropout | 0.0 |
| Target Modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Epochs | 5 |
| Effective Batch Size | 2 |
| Learning Rate | 5e-6 |
| Max Sequence Length | 512 |
| Quantization | 4-bit NF4 via bitsandbytes |
| Hardware | NVIDIA L40S (48GB) |
sdg_hubYou are a rules expert for the Basic Fantasy Role-Playing Game. Answer questions accurately based on the official rules. Be specific and cite page references or table values where possible.
1from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
2from peft import PeftModel
3import torch
4
5# 4-bit quantization config
6bnb_config = BitsAndBytesConfig(
7 load_in_4bit=True,
8 bnb_4bit_quant_type="nf4",
9 bnb_4bit_compute_dtype=torch.float16,
10 bnb_4bit_use_double_quant=True,
11)
12
13# Load base model in 4-bit
14base_model = AutoModelForCausalLM.from_pretrained(
15 "ibm-granite/granite-3.2-8b-instruct",
16 quantization_config=bnb_config,
17 device_map="auto",
18 dtype=torch.float16,
19)
20tokenizer = AutoTokenizer.from_pretrained("ibm-granite/granite-3.2-8b-instruct")
21
22# Apply LoRA adapter
23model = PeftModel.from_pretrained(base_model, "redhat-ai-dev/basic-fantasy-granite-lora-adapter")
24model.eval()
25
26# Run inference
27messages = [
28 {"role": "system", "content": "You are a rules expert for the Basic Fantasy Role-Playing Game. Answer questions accurately based on the official rules."},
29 {"role": "user", "content": "What happens if a Thief fails an Open Locks attempt?"},
30]
31
32inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(model.device)
33with torch.no_grad():
34 outputs = model.generate(inputs, max_new_tokens=256, do_sample=False)
35print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))