Text Generation
Transformers
Safetensors
granitemoehybrid
language
unsloth
granite-4.0
conversational
Instructions to use unsloth/granite-4.0-micro with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unsloth/granite-4.0-micro with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="unsloth/granite-4.0-micro") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("unsloth/granite-4.0-micro") model = AutoModelForCausalLM.from_pretrained("unsloth/granite-4.0-micro") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use unsloth/granite-4.0-micro with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "unsloth/granite-4.0-micro" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "unsloth/granite-4.0-micro", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/unsloth/granite-4.0-micro
- SGLang
How to use unsloth/granite-4.0-micro 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 "unsloth/granite-4.0-micro" \ --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": "unsloth/granite-4.0-micro", "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 "unsloth/granite-4.0-micro" \ --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": "unsloth/granite-4.0-micro", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio new
How to use unsloth/granite-4.0-micro 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 unsloth/granite-4.0-micro 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 unsloth/granite-4.0-micro to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for unsloth/granite-4.0-micro to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="unsloth/granite-4.0-micro", max_seq_length=2048, ) - Docker Model Runner
How to use unsloth/granite-4.0-micro with Docker Model Runner:
docker model run hf.co/unsloth/granite-4.0-micro
Update README.md
Browse files
README.md
CHANGED
|
@@ -9,8 +9,14 @@ tags:
|
|
| 9 |
- granite-4.0
|
| 10 |
---
|
| 11 |
<div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
<p style="margin-top: 0;margin-bottom: 0;">
|
| 13 |
-
|
| 14 |
</p>
|
| 15 |
<div style="display: flex; gap: 5px; align-items: center; ">
|
| 16 |
<a href="https://github.com/unslothai/unsloth/">
|
|
@@ -19,12 +25,16 @@ tags:
|
|
| 19 |
<a href="https://discord.gg/unsloth">
|
| 20 |
<img src="https://github.com/unslothai/unsloth/raw/main/images/Discord%20button.png" width="173">
|
| 21 |
</a>
|
| 22 |
-
<a href="https://docs.unsloth.ai/">
|
| 23 |
<img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="143">
|
| 24 |
</a>
|
| 25 |
</div>
|
|
|
|
| 26 |
</div>
|
| 27 |
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
# Granite-4.0-Micro
|
| 30 |
|
|
|
|
| 9 |
- granite-4.0
|
| 10 |
---
|
| 11 |
<div>
|
| 12 |
+
<p style="margin-bottom: 0; margin-top: 0;">
|
| 13 |
+
<strong>See <a href="https://huggingface.co/collections/unsloth/granite-40-68ddf64b4a8717dc22a9322d">our collection</a> for all versions of Granite-4.0 including GGUF, 4-bit & 16-bit formats.</strong>
|
| 14 |
+
</p>
|
| 15 |
+
<p style="margin-bottom: 0;">
|
| 16 |
+
<em>Learn to run gpt-oss correctly - <a href="https://docs.unsloth.ai/new/ibm-granite-4.0">Read our Guide</a>.</em>
|
| 17 |
+
</p>
|
| 18 |
<p style="margin-top: 0;margin-bottom: 0;">
|
| 19 |
+
<em>See <a href="https://docs.unsloth.ai/basics/unsloth-dynamic-v2.0-gguf">Unsloth Dynamic 2.0 GGUFs</a> for our quantization benchmarks.</em>
|
| 20 |
</p>
|
| 21 |
<div style="display: flex; gap: 5px; align-items: center; ">
|
| 22 |
<a href="https://github.com/unslothai/unsloth/">
|
|
|
|
| 25 |
<a href="https://discord.gg/unsloth">
|
| 26 |
<img src="https://github.com/unslothai/unsloth/raw/main/images/Discord%20button.png" width="173">
|
| 27 |
</a>
|
| 28 |
+
<a href="https://docs.unsloth.ai/new/ibm-granite-4.0">
|
| 29 |
<img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="143">
|
| 30 |
</a>
|
| 31 |
</div>
|
| 32 |
+
<h1 style="margin-top: 0rem;">✨ Read our Granite-4.0 Guide <a href="https://docs.unsloth.ai/new/ibm-granite-4.0">here</a>!</h1>
|
| 33 |
</div>
|
| 34 |
|
| 35 |
+
- Fine-tune Granite-4.0 for free using our [Google Colab notebook](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Granite4.0.ipynb)
|
| 36 |
+
- Read our Blog about Granite-4.0 support: https://docs.unsloth.ai/new/ibm-granite-4.0
|
| 37 |
+
- View the rest of our notebooks in our [docs here](https://docs.unsloth.ai/get-started/unsloth-notebooks).
|
| 38 |
|
| 39 |
# Granite-4.0-Micro
|
| 40 |
|