Instructions to use FrankDigsData/basic-fantasy-granite-lora-adapter with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use FrankDigsData/basic-fantasy-granite-lora-adapter with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("./models/granite-3.2-8b-instruct") model = PeftModel.from_pretrained(base_model, "FrankDigsData/basic-fantasy-granite-lora-adapter") - Transformers
How to use FrankDigsData/basic-fantasy-granite-lora-adapter with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="FrankDigsData/basic-fantasy-granite-lora-adapter") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("FrankDigsData/basic-fantasy-granite-lora-adapter", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use FrankDigsData/basic-fantasy-granite-lora-adapter with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "FrankDigsData/basic-fantasy-granite-lora-adapter" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FrankDigsData/basic-fantasy-granite-lora-adapter", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/FrankDigsData/basic-fantasy-granite-lora-adapter
- SGLang
How to use FrankDigsData/basic-fantasy-granite-lora-adapter with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "FrankDigsData/basic-fantasy-granite-lora-adapter" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FrankDigsData/basic-fantasy-granite-lora-adapter", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "FrankDigsData/basic-fantasy-granite-lora-adapter" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FrankDigsData/basic-fantasy-granite-lora-adapter", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio new
How to use FrankDigsData/basic-fantasy-granite-lora-adapter with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for FrankDigsData/basic-fantasy-granite-lora-adapter to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for FrankDigsData/basic-fantasy-granite-lora-adapter to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for FrankDigsData/basic-fantasy-granite-lora-adapter to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="FrankDigsData/basic-fantasy-granite-lora-adapter", max_seq_length=2048, ) - Docker Model Runner
How to use FrankDigsData/basic-fantasy-granite-lora-adapter with Docker Model Runner:
docker model run hf.co/FrankDigsData/basic-fantasy-granite-lora-adapter
Model Card: Granite 3.2 8B Instruct โ BFRPG LoRA Adapter
Overview
A LoRA adapter fine-tuned on top of IBM Granite 3.2 8B Instruct for Basic Fantasy Role-Playing Game (BFRPG) rules Q&A. This is a parameter-efficient adapter โ the base model weights are not modified. The adapter is loaded on top of the base model at inference time using the PEFT library.
Model Details
| 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) |
Training Data
- Dataset: 6โ8 synthetic Q&A pairs generated from the Basic Fantasy RPG rulebook
- Focus: Thief class abilities (Open Locks, Pick Pockets, Move Silently, etc.) and general BFRPG rules
- Generation Method: LLM-based synthetic data pipeline with faithfulness judging via
sdg_hub
System Prompt:
You 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.
Usage Example
This is a LoRA adapter, not a standalone model. Load the base model first, then apply the adapter:
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
import torch
# 4-bit quantization config
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True,
)
# Load base model in 4-bit
base_model = AutoModelForCausalLM.from_pretrained(
"ibm-granite/granite-3.2-8b-instruct",
quantization_config=bnb_config,
device_map="auto",
dtype=torch.float16,
)
tokenizer = AutoTokenizer.from_pretrained("ibm-granite/granite-3.2-8b-instruct")
# Apply LoRA adapter
model = PeftModel.from_pretrained(base_model, "redhat-ai-dev/basic-fantasy-granite-lora-adapter")
model.eval()
# Run inference
messages = [
{"role": "system", "content": "You are a rules expert for the Basic Fantasy Role-Playing Game. Answer questions accurately based on the official rules."},
{"role": "user", "content": "What happens if a Thief fails an Open Locks attempt?"},
]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(model.device)
with torch.no_grad():
outputs = model.generate(inputs, max_new_tokens=256, do_sample=False)
print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))
Training Procedure
This adapter was trained using TRL with the Unsloth backend via training_hub. The base model was loaded in 4-bit quantization (QLoRA) to fit within GPU memory constraints. Only the LoRA adapter weights were trained; the base model weights were frozen throughout.
Framework Versions
- PEFT 0.18.1
- TRL 0.23.0
- Transformers 4.57.2
- PyTorch 2.10.0
- Datasets 4.6.0
- Tokenizers 0.22.2
Context
Fine-tuned as part of a Red Hat AI workshop demonstrating the model adaptation step in an escalation pipeline: RAG โ inference-time scaling (Best-of-N) โ LoRA SFT. This adapter represents the final step, targeting knowledge gaps that retrieval and sampling could not resolve.
- Downloads last month
- 1
Model tree for FrankDigsData/basic-fantasy-granite-lora-adapter
Base model
ibm-granite/granite-3.1-8b-base