Image-Text-to-Text
Transformers
Safetensors
English
llava_next
vision
conversational
text-generation-inference
Instructions to use llava-hf/llava-v1.6-mistral-7b-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use llava-hf/llava-v1.6-mistral-7b-hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="llava-hf/llava-v1.6-mistral-7b-hf") 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("llava-hf/llava-v1.6-mistral-7b-hf") model = AutoModelForMultimodalLM.from_pretrained("llava-hf/llava-v1.6-mistral-7b-hf", 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use llava-hf/llava-v1.6-mistral-7b-hf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "llava-hf/llava-v1.6-mistral-7b-hf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "llava-hf/llava-v1.6-mistral-7b-hf", "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/llava-hf/llava-v1.6-mistral-7b-hf
- SGLang
How to use llava-hf/llava-v1.6-mistral-7b-hf 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 "llava-hf/llava-v1.6-mistral-7b-hf" \ --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": "llava-hf/llava-v1.6-mistral-7b-hf", "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 "llava-hf/llava-v1.6-mistral-7b-hf" \ --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": "llava-hf/llava-v1.6-mistral-7b-hf", "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 llava-hf/llava-v1.6-mistral-7b-hf with Docker Model Runner:
docker model run hf.co/llava-hf/llava-v1.6-mistral-7b-hf
<\s> token in the chat template instead of the </s> EOS token
4
#41 opened almost 2 years ago
by
fabric
Fine Tuning results into ValueError: Number of image tokens in input_ids different from num_images.
#40 opened almost 2 years ago
by deleted
all the outputs from the llava-hf/llava-v1.6-mistral-7b-hf model are showing as <unk> when prompted with an image. kindly clarify if there is an issue or I’m doing something incorrectly?
🤯 1
#39 opened almost 2 years ago
by
Abdrabu
Potential ways to accelerate for image to text tasks?
9
#38 opened almost 2 years ago
by
triscuiter
Processor config change leads to errors
9
#37 opened almost 2 years ago
by
7AtAri
Inference without images
4
#36 opened almost 2 years ago
by
psologub
Evaluation
1
#35 opened almost 2 years ago
by
russwang
Expanding inputs for image tokens in LLaVa-NeXT should be done in processing.
5
#34 opened almost 2 years ago
by
miniTsl
Index out of range errors
1
#32 opened about 2 years ago
by
manas03
Can the model be used for commercial purposes?
1
#28 opened about 2 years ago
by
ssh6lq
PLZ!😭When I run the template, I get the error“Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained."
5
#26 opened over 2 years ago
by
wenyilll
How to set the temperature
1
#25 opened over 2 years ago
by
aakash1307
Unable to test inference on SageMaker
1
#23 opened over 2 years ago
by
AleksandarC
deploy on sagemaker
1
#20 opened over 2 years ago
by
bk2000
Support for multiple images..
8
#19 opened over 2 years ago
by
wamozart
New LLaVA-NeXT (2024-05 Release)
2
#18 opened over 2 years ago
by
longphann
Does this support PEFT API for fine-tuning?
2
#16 opened over 2 years ago
by
larry5
How to run on M3 MAX on macbook?
#13 opened over 2 years ago
by
Arthurvaz
works quite good actually using the Tag-Gui, but....
#12 opened over 2 years ago
by
U-ID
Embedding Function
1
#11 opened over 2 years ago
by
dandre0102
Few Shot Example
➕ 2
2
#9 opened over 2 years ago
by
chaydaroglu
Several issues loading and using the model with transformers==4.39.2
2
#7 opened over 2 years ago
by
csegalin
Does llava supports multi-gpu inference?
3
#6 opened over 2 years ago
by
ZealLin
Will you make a VIP version of llava 1.6 models?
1
#4 opened over 2 years ago
by
barleyspectacular
wrong padding token
2
#2 opened over 2 years ago
by
aliencaocao