Instructions to use AlonMal/granite-4.1-3b-sr with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AlonMal/granite-4.1-3b-sr with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AlonMal/granite-4.1-3b-sr") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("AlonMal/granite-4.1-3b-sr", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use AlonMal/granite-4.1-3b-sr with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AlonMal/granite-4.1-3b-sr" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AlonMal/granite-4.1-3b-sr", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/AlonMal/granite-4.1-3b-sr
- SGLang
How to use AlonMal/granite-4.1-3b-sr 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 "AlonMal/granite-4.1-3b-sr" \ --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": "AlonMal/granite-4.1-3b-sr", "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 "AlonMal/granite-4.1-3b-sr" \ --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": "AlonMal/granite-4.1-3b-sr", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use AlonMal/granite-4.1-3b-sr with Docker Model Runner:
docker model run hf.co/AlonMal/granite-4.1-3b-sr
granite-4.1-3b-sr
ibm-granite/granite-4.1-3b converted to the Shadow Residual (SR) architecture โ the base model for training SR adapters with stock PEFT LoRA.
SR runs two streams through every decoder layer: a frozen base stream (the
unadapted base model) and a trainable adapter stream (LoRA deltas plus a per-layer
low-rank cross-stream injection from the base). The weights here are the base
model's own weights, re-laid-out for SR (fused projections split into separate
q/k/v and gate/up projections). With no adapter attached the model produces
the base model's outputs.
Usage
Loading needs the shadow-residual package installed (it registers the
shadow_residual model type with transformers; no trust_remote_code).
import shadow_residual.shadow_residual # registers the SR model type
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("AlonMal/granite-4.1-3b-sr")
tokenizer = AutoTokenizer.from_pretrained("AlonMal/granite-4.1-3b-sr")
Attach a trained SR adapter with stock PEFT:
from peft import PeftModel
model = PeftModel.from_pretrained(model, "<adapter>")
The frozen cross-stream sites are all-zero by construction and are not stored; they are re-created on load.
- Downloads last month
- 343
Model tree for AlonMal/granite-4.1-3b-sr
Base model
ibm-granite/granite-4.1-3b