Instructions to use liuhaotian/llava-v1.5-13b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use liuhaotian/llava-v1.5-13b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="liuhaotian/llava-v1.5-13b")# Load model directly from transformers import AutoProcessor, AutoModelForCausalLM processor = AutoProcessor.from_pretrained("liuhaotian/llava-v1.5-13b") model = AutoModelForCausalLM.from_pretrained("liuhaotian/llava-v1.5-13b", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use liuhaotian/llava-v1.5-13b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "liuhaotian/llava-v1.5-13b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "liuhaotian/llava-v1.5-13b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/liuhaotian/llava-v1.5-13b
- SGLang
How to use liuhaotian/llava-v1.5-13b 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 "liuhaotian/llava-v1.5-13b" \ --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": "liuhaotian/llava-v1.5-13b", "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 "liuhaotian/llava-v1.5-13b" \ --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": "liuhaotian/llava-v1.5-13b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use liuhaotian/llava-v1.5-13b with Docker Model Runner:
docker model run hf.co/liuhaotian/llava-v1.5-13b
| import sagemaker | |
| import boto3 | |
| from sagemaker.huggingface import HuggingFace | |
| try: | |
| role = sagemaker.get_execution_role() | |
| except ValueError: | |
| iam = boto3.client('iam') | |
| role = iam.get_role(RoleName='sagemaker_execution_role')['Role']['Arn'] | |
| hyperparameters = { | |
| 'model_name_or_path':'liuhaotian/llava-v1.5-13b', | |
| 'output_dir':'/opt/ml/model' | |
| # add your remaining hyperparameters | |
| # more info here https://github.com/huggingface/transformers/tree/v4.26.0/examples/pytorch/language-modeling | |
| } | |
| # git configuration to download our fine-tuning script | |
| git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.26.0'} | |
| # creates Hugging Face estimator | |
| huggingface_estimator = HuggingFace( | |
| entry_point='run_mlm.py', | |
| source_dir='./examples/pytorch/language-modeling', | |
| instance_type='ml.p3.2xlarge', | |
| instance_count=1, | |
| role=role, | |
| git_config=git_config, | |
| transformers_version='4.26.0', | |
| pytorch_version='1.13.1', | |
| py_version='py39', | |
| hyperparameters = hyperparameters | |
| ) | |
| # starting the train job | |
| huggingface_estimator.fit() |