Text Generation
Transformers
Safetensors
granite_switch
granite
granite-switch
lora
adapters
mixture-of-adapters
conversational
Instructions to use barha/granite-switch-4.0-350m-demo with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use barha/granite-switch-4.0-350m-demo with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="barha/granite-switch-4.0-350m-demo") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("barha/granite-switch-4.0-350m-demo", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use barha/granite-switch-4.0-350m-demo with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "barha/granite-switch-4.0-350m-demo" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "barha/granite-switch-4.0-350m-demo", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/barha/granite-switch-4.0-350m-demo
- SGLang
How to use barha/granite-switch-4.0-350m-demo 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 "barha/granite-switch-4.0-350m-demo" \ --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": "barha/granite-switch-4.0-350m-demo", "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 "barha/granite-switch-4.0-350m-demo" \ --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": "barha/granite-switch-4.0-350m-demo", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use barha/granite-switch-4.0-350m-demo with Docker Model Runner:
docker model run hf.co/barha/granite-switch-4.0-350m-demo
Granite Switch Composed Model
Base Model
- Identifier: ibm-granite/granite-4.0-350m
- Model type: granitemoehybrid
- Architectures: GraniteMoeHybridForCausalLM
- Hidden size: 1024
- Hidden layers: 28
- Attention heads: 16
- Vocab size: 100352
Embedded Adapters
Total adapters: 3
| # | Name | Technology | Control Token | Token ID | Rank | Alpha | Target Modules | Source |
|---|---|---|---|---|---|---|---|---|
| 1 | cti-technique-mapping | alora | <|cti-technique-mapping|> |
100352 | 32 | 64 | input_linear, k_proj, o_proj, output_linear, q_proj, v_proj | cti-technique-mapping |
| 2 | text-to-json | alora | <|text-to-json|> |
100353 | 32 | 64 | input_linear, k_proj, o_proj, output_linear, q_proj, v_proj | text-to-json |
| 3 | genai-attack-vector | alora | <|genai-attack-vector|> |
100354 | 32 | 64 | input_linear, k_proj, o_proj, output_linear, q_proj, v_proj | genai-attack-vector |
Composition Details
- base_param_count: 352,379,904
- composed_param_count: 395,046,912
- Param delta: +12.11%
- compose_settings:
- technology: "alora"
- adapter_substitute_token_ids:
- 100264
- 100264
- 100264
- target_model: "granite-4.0-350m"