Image-Text-to-Text
Transformers
Safetensors
PyTorch
llama4
facebook
meta
llama
llama-4
conversational
text-generation-inference
4-bit precision
bitsandbytes
Instructions to use unsloth/Llama-4-Scout-17B-16E-Instruct-unsloth-bnb-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unsloth/Llama-4-Scout-17B-16E-Instruct-unsloth-bnb-4bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="unsloth/Llama-4-Scout-17B-16E-Instruct-unsloth-bnb-4bit") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("unsloth/Llama-4-Scout-17B-16E-Instruct-unsloth-bnb-4bit") model = AutoModelForMultimodalLM.from_pretrained("unsloth/Llama-4-Scout-17B-16E-Instruct-unsloth-bnb-4bit", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use unsloth/Llama-4-Scout-17B-16E-Instruct-unsloth-bnb-4bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "unsloth/Llama-4-Scout-17B-16E-Instruct-unsloth-bnb-4bit" # 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/Llama-4-Scout-17B-16E-Instruct-unsloth-bnb-4bit", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/unsloth/Llama-4-Scout-17B-16E-Instruct-unsloth-bnb-4bit
- SGLang
How to use unsloth/Llama-4-Scout-17B-16E-Instruct-unsloth-bnb-4bit 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/Llama-4-Scout-17B-16E-Instruct-unsloth-bnb-4bit" \ --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/Llama-4-Scout-17B-16E-Instruct-unsloth-bnb-4bit", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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/Llama-4-Scout-17B-16E-Instruct-unsloth-bnb-4bit" \ --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/Llama-4-Scout-17B-16E-Instruct-unsloth-bnb-4bit", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use unsloth/Llama-4-Scout-17B-16E-Instruct-unsloth-bnb-4bit with Docker Model Runner:
docker model run hf.co/unsloth/Llama-4-Scout-17B-16E-Instruct-unsloth-bnb-4bit
Commit ·
df0ad74
1
Parent(s): dbaaceb
Add files using upload-large-folder tool
Browse files- config.json +2 -10
- generation_config.json +1 -1
- model.safetensors.index.json +0 -0
- tokenizer_config.json +1 -4
config.json
CHANGED
|
@@ -3,12 +3,9 @@
|
|
| 3 |
"Llama4ForConditionalGeneration"
|
| 4 |
],
|
| 5 |
"boi_token_index": 200080,
|
| 6 |
-
"bos_token_id": 200000,
|
| 7 |
"eoi_token_index": 200081,
|
| 8 |
-
"eos_token_id": 200008,
|
| 9 |
"image_token_index": 200092,
|
| 10 |
"model_type": "llama4",
|
| 11 |
-
"pad_token_id": 201134,
|
| 12 |
"quantization_config": {
|
| 13 |
"_load_in_4bit": true,
|
| 14 |
"_load_in_8bit": false,
|
|
@@ -19,12 +16,8 @@
|
|
| 19 |
"llm_int8_enable_fp32_cpu_offload": false,
|
| 20 |
"llm_int8_has_fp16_weight": false,
|
| 21 |
"llm_int8_skip_modules": [
|
| 22 |
-
"
|
| 23 |
-
"multi_modal_projector"
|
| 24 |
-
"merger",
|
| 25 |
-
"modality_projection",
|
| 26 |
-
"vision_model.model.layers.33.mlp",
|
| 27 |
-
"language_model.model.layers.43.self_attn"
|
| 28 |
],
|
| 29 |
"llm_int8_threshold": 6.0,
|
| 30 |
"load_in_4bit": true,
|
|
@@ -181,7 +174,6 @@
|
|
| 181 |
"tie_word_embeddings": false,
|
| 182 |
"torch_dtype": "bfloat16",
|
| 183 |
"transformers_version": "4.51.0",
|
| 184 |
-
"unsloth_fixed": true,
|
| 185 |
"vision_config": {
|
| 186 |
"_attn_implementation_autoset": true,
|
| 187 |
"attention_dropout": 0.0,
|
|
|
|
| 3 |
"Llama4ForConditionalGeneration"
|
| 4 |
],
|
| 5 |
"boi_token_index": 200080,
|
|
|
|
| 6 |
"eoi_token_index": 200081,
|
|
|
|
| 7 |
"image_token_index": 200092,
|
| 8 |
"model_type": "llama4",
|
|
|
|
| 9 |
"quantization_config": {
|
| 10 |
"_load_in_4bit": true,
|
| 11 |
"_load_in_8bit": false,
|
|
|
|
| 16 |
"llm_int8_enable_fp32_cpu_offload": false,
|
| 17 |
"llm_int8_has_fp16_weight": false,
|
| 18 |
"llm_int8_skip_modules": [
|
| 19 |
+
"vision_model",
|
| 20 |
+
"multi_modal_projector"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
],
|
| 22 |
"llm_int8_threshold": 6.0,
|
| 23 |
"load_in_4bit": true,
|
|
|
|
| 174 |
"tie_word_embeddings": false,
|
| 175 |
"torch_dtype": "bfloat16",
|
| 176 |
"transformers_version": "4.51.0",
|
|
|
|
| 177 |
"vision_config": {
|
| 178 |
"_attn_implementation_autoset": true,
|
| 179 |
"attention_dropout": 0.0,
|
generation_config.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
| 6 |
200007,
|
| 7 |
200008
|
| 8 |
],
|
| 9 |
-
"pad_token_id":
|
| 10 |
"temperature": 0.6,
|
| 11 |
"top_p": 0.9,
|
| 12 |
"transformers_version": "4.51.0"
|
|
|
|
| 6 |
200007,
|
| 7 |
200008
|
| 8 |
],
|
| 9 |
+
"pad_token_id": 200018,
|
| 10 |
"temperature": 0.6,
|
| 11 |
"top_p": 0.9,
|
| 12 |
"transformers_version": "4.51.0"
|
model.safetensors.index.json
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
{
|
| 2 |
-
"add_bos_token": true,
|
| 3 |
"added_tokens_decoder": {
|
| 4 |
"200000": {
|
| 5 |
"content": "<|begin_of_text|>",
|
|
@@ -9093,8 +9092,6 @@
|
|
| 9093 |
],
|
| 9094 |
"model_max_length": 10485760,
|
| 9095 |
"pad_token": "<|finetune_right_pad_id|>",
|
| 9096 |
-
"padding_side": "left",
|
| 9097 |
"processor_class": "Llama4Processor",
|
| 9098 |
-
"tokenizer_class": "PreTrainedTokenizer"
|
| 9099 |
-
"unk_token": null
|
| 9100 |
}
|
|
|
|
| 1 |
{
|
|
|
|
| 2 |
"added_tokens_decoder": {
|
| 3 |
"200000": {
|
| 4 |
"content": "<|begin_of_text|>",
|
|
|
|
| 9092 |
],
|
| 9093 |
"model_max_length": 10485760,
|
| 9094 |
"pad_token": "<|finetune_right_pad_id|>",
|
|
|
|
| 9095 |
"processor_class": "Llama4Processor",
|
| 9096 |
+
"tokenizer_class": "PreTrainedTokenizer"
|
|
|
|
| 9097 |
}
|