Instructions to use webAI-Official/granite-4.2-8b-builder-lora-peft with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use webAI-Official/granite-4.2-8b-builder-lora-peft with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("ibm-granite/granite-4.2-8b") model = PeftModel.from_pretrained(base_model, "webAI-Official/granite-4.2-8b-builder-lora-peft") - Transformers
How to use webAI-Official/granite-4.2-8b-builder-lora-peft with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="webAI-Official/granite-4.2-8b-builder-lora-peft") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("webAI-Official/granite-4.2-8b-builder-lora-peft", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use webAI-Official/granite-4.2-8b-builder-lora-peft with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "webAI-Official/granite-4.2-8b-builder-lora-peft" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "webAI-Official/granite-4.2-8b-builder-lora-peft", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/webAI-Official/granite-4.2-8b-builder-lora-peft
- SGLang
How to use webAI-Official/granite-4.2-8b-builder-lora-peft 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 "webAI-Official/granite-4.2-8b-builder-lora-peft" \ --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": "webAI-Official/granite-4.2-8b-builder-lora-peft", "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 "webAI-Official/granite-4.2-8b-builder-lora-peft" \ --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": "webAI-Official/granite-4.2-8b-builder-lora-peft", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use webAI-Official/granite-4.2-8b-builder-lora-peft with Docker Model Runner:
docker model run hf.co/webAI-Official/granite-4.2-8b-builder-lora-peft
granite-4.2-8b-builder-lora-peft
PEFT LoRA adapter for the builder persona, trained on ibm-granite/granite-4.2-8b. A llama.cpp version of the same weights is at webAI-Official/granite-4.2-8b-builder-lora-GGUF.
Usage (Transformers + PEFT)
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base = AutoModelForCausalLM.from_pretrained("ibm-granite/granite-4.2-8b", torch_dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(base, "webAI-Official/granite-4.2-8b-builder-lora-peft")
tokenizer = AutoTokenizer.from_pretrained("webAI-Official/granite-4.2-8b-builder-lora-peft")
messages = [{"role": "user", "content": "Hello!"}]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
print(tokenizer.decode(model.generate(inputs, max_new_tokens=256)[0][inputs.shape[-1]:], skip_special_tokens=True))
Call model.merge_and_unload() to fold the adapter into the base weights. The adapter was saved with PEFT 0.21.0; the tokenizer config uses the Transformers v5 format.
Files
adapter_model.safetensors,adapter_config.json: LoRA weights (fp32) and configtokenizer.json,tokenizer_config.json,chat_template.jinja: tokenizer and chat template used in trainingpersona.json,run_config.json,train_metrics.json: persona settings, training config, and training metrics
Adapter details
- Type: LoRA, rank 16, alpha 32, dropout 0.05
- Target modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
- Thinking mode:
thinking - Training: 2776 examples, 3 epochs, lr 0.0001, cosine schedule, max seq len 8192, packing
- Final step 522; train loss 0.3201; eval loss 0.3395
- Downloads last month
- 14
Model tree for webAI-Official/granite-4.2-8b-builder-lora-peft
Base model
ibm-granite/granite-4.1-8b-base Finetuned
ibm-granite/granite-4.2-8b