How to use from
vLLM
Install from pip and serve model
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "onekq-ai/granite-8b-code-base-4k-bnb-4bit"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
	-H "Content-Type: application/json" \
	--data '{
		"model": "onekq-ai/granite-8b-code-base-4k-bnb-4bit",
		"prompt": "Once upon a time,",
		"max_tokens": 512,
		"temperature": 0.5
	}'
Use Docker
docker model run hf.co/onekq-ai/granite-8b-code-base-4k-bnb-4bit
Quick Links

Bitsandbytes quantization of https://huggingface.co/ibm-granite/granite-8b-code-base-4k.

See https://huggingface.co/blog/4bit-transformers-bitsandbytes for instructions.

from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers import BitsAndBytesConfig
import torch

# Define the 4-bit configuration
nf4_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_use_double_quant=True,
    bnb_4bit_compute_dtype=torch.bfloat16
)

# Load the pre-trained model with the 4-bit quantization configuration
model = AutoModelForCausalLM.from_pretrained("ibm-granite/granite-8b-code-base-4k", quantization_config=nf4_config)

# Load the tokenizer associated with the model
tokenizer = AutoTokenizer.from_pretrained("ibm-granite/granite-8b-code-base-4k")

# Push the model and tokenizer to the Hugging Face hub
model.push_to_hub("onekq-ai/granite-8b-code-base-4k-bnb-4bit", use_auth_token=True)
tokenizer.push_to_hub("onekq-ai/granite-8b-code-base-4k-bnb-4bit", use_auth_token=True)
Downloads last month
3
Safetensors
Model size
8B params
Tensor type
F32
·
F16
·
U8
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for onekq-ai/granite-8b-code-base-4k-bnb-4bit

Quantized
(20)
this model

Collection including onekq-ai/granite-8b-code-base-4k-bnb-4bit