Image-Text-to-Text
Transformers
Safetensors
PyTorch
llama4
facebook
meta
llama
conversational
Eval Results
text-generation-inference
compressed-tensors
Instructions to use meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8") 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("meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8") model = AutoModelForMultimodalLM.from_pretrained("meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", 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]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", "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/meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8
- SGLang
How to use meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8 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 "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8" \ --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": "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", "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 "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8" \ --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": "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", "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 meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8 with Docker Model Runner:
docker model run hf.co/meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8
Quantizer: Running into an error with quantization "TypeError: 'dict' object is not callable"
#24
by AaronVogler - opened
I get the following error when trying to load the model on CPU...
Anyone have any idea as to what's going on?
File "/usr/local/lib/python3.10/dist-packages/transformers/pipelines/__init__.py", line 942, in pipeline
framework, model = infer_framework_load_model(
File "/usr/local/lib/python3.10/dist-packages/transformers/pipelines/base.py", line 291, in infer_framework_load_model
model = model_class.from_pretrained(model, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/transformers/models/auto/auto_factory.py", line 571, in from_pretrained
return model_class.from_pretrained(
File "/usr/local/lib/python3.10/dist-packages/transformers/modeling_utils.py", line 279, in _wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/transformers/modeling_utils.py", line 4369, in from_pretrained
hf_quantizer.preprocess_model(
File "/usr/local/lib/python3.10/dist-packages/transformers/quantizers/base.py", line 224, in preprocess_model
self._convert_model_for_quantization(model)
File "/usr/local/lib/python3.10/dist-packages/transformers/quantizers/base.py", line 313, in _convert_model_for_quantization
parent_module._modules[name] = MODULES_TO_PATCH_FOR_QUANTIZATION[module_class_name](
TypeError: 'dict' object is not callable
at ChildProcess.<anonymous> (/home/inf3rnus/api/jobRunner/library/container/createTestImage/index.js:61:18)
at ChildProcess.emit (/home/inf3rnus/api/lib/events.js:519:28)
at maybeClose (/home/inf3rnus/api/lib/internal/child_process.js:1105:16)
at ChildProcess._handle.onexit (/home/inf3rnus/api/lib/internal/child_process.js:305:5)
at Process.callbackTrampoline (node:internal/async_hooks:130:17) {stack: "Error: ERROR: pip's dependency resolver does …Trampoline (node:internal/async_hooks:130:17)", message: "ERROR: pip's dependency resolver does not cu…](
TypeError: 'dict' object is not callable
"}
Thanks,
Aaron
I got the same error. Were you able to fix it?
@zhuokai No, I have been unable to fix it, the non quant versions of the model work on CPU, so I don't know what the deal is, presumably some conflict between compressed-tensors and transformers==4.51.3
yeah, install from source is the fix.