Instructions to use Zero-Vision/Llama-3-MixSenseV1_1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Zero-Vision/Llama-3-MixSenseV1_1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Zero-Vision/Llama-3-MixSenseV1_1", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Zero-Vision/Llama-3-MixSenseV1_1", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Zero-Vision/Llama-3-MixSenseV1_1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Zero-Vision/Llama-3-MixSenseV1_1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Zero-Vision/Llama-3-MixSenseV1_1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Zero-Vision/Llama-3-MixSenseV1_1
- SGLang
How to use Zero-Vision/Llama-3-MixSenseV1_1 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 "Zero-Vision/Llama-3-MixSenseV1_1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Zero-Vision/Llama-3-MixSenseV1_1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "Zero-Vision/Llama-3-MixSenseV1_1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Zero-Vision/Llama-3-MixSenseV1_1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Zero-Vision/Llama-3-MixSenseV1_1 with Docker Model Runner:
docker model run hf.co/Zero-Vision/Llama-3-MixSenseV1_1
Download llama3mixsense.py from Zero-Vision/Llama-3-MixSenseV1_1: direct link, hf CLI and curl.
- Browser
- Download file 1.73 kB
-
https://huggingface.co/Zero-Vision/Llama-3-MixSenseV1_1/resolve/main/llama3mixsense.py
- Command line
-
hf download hf://Zero-Vision/Llama-3-MixSenseV1_1/llama3mixsense.py
-
curl -L -o llama3mixsense.py https://huggingface.co/Zero-Vision/Llama-3-MixSenseV1_1/resolve/main/llama3mixsense.py
1.73 kB
| ''' | |
| This file if for VLMEvalKit. | |
| ''' | |
| import torch | |
| import transformers | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| from PIL import Image | |
| import warnings | |
| from .base import BaseModel | |
| from ..smp import * | |
| from ..utils import DATASET_TYPE | |
| class LLama3Mixsense(BaseModel): | |
| INSTALL_REQ = False | |
| INTERLEAVE = False | |
| def __init__(self, model_path="Zero-Vision/Llama-3-MixSenseV1_1", **kwargs): | |
| assert model_path is not None | |
| transformers.logging.set_verbosity_error() | |
| transformers.logging.disable_progress_bar() | |
| warnings.filterwarnings("ignore") | |
| self.tokenizer = AutoTokenizer.from_pretrained( | |
| model_path, trust_remote_code=True | |
| ) | |
| self.model = AutoModelForCausalLM.from_pretrained( | |
| model_path, device_map="auto", trust_remote_code=True | |
| ) | |
| self.kwargs = kwargs | |
| def generate_inner(self, message, dataset=None): | |
| prompt, image_path = self.message_to_promptimg(message) | |
| input_ids=self.model.text_process(prompt, self.tokenizer) | |
| image = Image.open(image_path).convert("RGB") | |
| image_tensor = self.model.image_process([image]).to(dtype=self.model.dtype, device=device) | |
| # generate | |
| with torch.inference_mode(): | |
| output_ids = self.model.generate( | |
| input_ids, | |
| images=image_tensor, | |
| max_new_tokens=2048, | |
| use_cache=True, | |
| eos_token_id=[ | |
| self.tokenizer.eos_token_id, | |
| self.tokenizer.convert_tokens_to_ids(["<|eot_id|>"])[0], | |
| ], | |
| ) | |
| return self.tokenizer.batch_decode(output_ids, skip_special_tokens=True)[0].strip() | |