Instructions to use nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K", dtype="auto") - llama-cpp-python
How to use nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K", filename="llava-v1.5-7b-ocr-pretrain.Q2_K.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K:Q2_K # Run inference directly in the terminal: llama-cli -hf nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K:Q2_K
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K:Q2_K # Run inference directly in the terminal: llama-cli -hf nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K:Q2_K
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K:Q2_K # Run inference directly in the terminal: ./llama-cli -hf nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K:Q2_K
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K:Q2_K # Run inference directly in the terminal: ./build/bin/llama-cli -hf nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K:Q2_K
Use Docker
docker model run hf.co/nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K:Q2_K
- LM Studio
- Jan
- vLLM
How to use nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K:Q2_K
- SGLang
How to use nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K 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 "nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K" \ --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": "nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K", "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 "nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K" \ --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": "nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Ollama
How to use nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K with Ollama:
ollama run hf.co/nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K:Q2_K
- Unsloth Studio
How to use nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K to start chatting
- Docker Model Runner
How to use nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K with Docker Model Runner:
docker model run hf.co/nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K:Q2_K
- Lemonade
How to use nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull nnethercott/llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K:Q2_K
Run and chat with the model
lemonade run user.llava-v1.5-7b-gpt4OCR-hf-GGUF_Q2_K-Q2_K
List all available models
lemonade list
Model Card for Model ID
Model Details
Model Description
Finetuned version of liuhaotian/llava-v1.5-7b on ocr and object detection data using LoRA (adapter config at bottom) to improve OCR captioning abilities and bounding box generation.
The two datasets used for fine tuning are:
We use 10k samples from GRIT where each sample has an image-caption CLIP similarity larger than 0.35 and where the caption does not contain any proper nouns (filtered using spaCy).
How to Get Started with the Model
Use the code below to get started with the model:
from llama_cpp import Llama
from llama_cpp.llama_chat_format import Llava15ChatHandler
import io
from PIL import Image
import base64
import os
import json
import argparse
import time
from pathlib import Path
chat_handler = Llava15ChatHandler(clip_model_path="your-path-to-mmproj-model-f16.gguf")
llm = Llama(
model_path="your-path-to-llava-v1.5-7b-ocr-pretrain.Q2_K.gguf",
chat_handler=chat_handler,
n_ctx=2048, # n_ctx should be increased to accomodate the image embedding
logits_all=True,# needed to make llava work
n_gpu_layers=-1,
)
def inference(url, question):
start = time.perf_counter()
output = llm.create_chat_completion(
messages = [
{"role": "system", "content": "You are an assistant who answers user questions"},
{
"role": "user",
"content": [
{"type": "image_url",
"image_url": {
"url": url
}
},
{"type" : "text", "text": question}
]
}
],
temperature=1.0,
)
stop = time.perf_counter()
return {
**output,
"completion_time": stop-start,
"tokens-per-second": output["usage"]["completion_tokens"]/(stop-start),
}
def img_base64(path):
ext = path.suffix
path = str(path)
with open(str(path), 'rb') as f:
data = f.read()
return f'data:image/{ext};base64,' + base64.b64encode(data).decode('utf8')
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--url', help="url of an image for inference", type=str, default = "https://adquick-public.imgix.net/landing+images/media_formats/billboard-carvana.png?auto=format")
parser.add_argument('--question', '-q', type=str, default="generate a descriptive caption for this image.")
args = parser.parse_args()
url = args.url
# hope this works for local images
if url.startswith('/') or url.startswith('./') or url.startswith("../"):
url = img_base64(Path(url))
# print(url)
outputs = inference(url, args.question)
print(json.dumps(outputs, indent=4))
Output:
The image features an advertisement billboard with a vibrant red car being transported by trucks, set against a clear sky backdrop. Emblazoned across the top is the phrase \"Buy your next CAR from your COUCH.\" Below, the text reads \"CARVANA\" on the left and \"carvana\" on the right side, while a smaller \"Bluegrass Outdoor\" logo is noted at the bottom center.
- Downloads last month
- 151
2-bit