liuhaotian/LLaVA-Instruct-150K
Preview • Updated • 7.13k • 601
How to use SkyAsl/Nanbeige4.1-VLM with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="SkyAsl/Nanbeige4.1-VLM", trust_remote_code=True)
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 AutoModel
model = AutoModel.from_pretrained("SkyAsl/Nanbeige4.1-VLM", trust_remote_code=True, dtype="auto")How to use SkyAsl/Nanbeige4.1-VLM with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "SkyAsl/Nanbeige4.1-VLM"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "SkyAsl/Nanbeige4.1-VLM",
"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 run hf.co/SkyAsl/Nanbeige4.1-VLM
How to use SkyAsl/Nanbeige4.1-VLM with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "SkyAsl/Nanbeige4.1-VLM" \
--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": "SkyAsl/Nanbeige4.1-VLM",
"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 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 "SkyAsl/Nanbeige4.1-VLM" \
--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": "SkyAsl/Nanbeige4.1-VLM",
"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"
}
}
]
}
]
}'How to use SkyAsl/Nanbeige4.1-VLM with Docker Model Runner:
docker model run hf.co/SkyAsl/Nanbeige4.1-VLM
Full vision-language model after Stage 2 instruction fine-tuning on LLaVA-Instruct-150K. LoRA weights have been merged into the base model for easy inference.
Image → SigLIP so400m → AvgPool(729→196) → MLP Projector → Nanbeige4.1-3B → Text
from transformers import AutoModel, AutoTokenizer
from PIL import Image
model = AutoModel.from_pretrained(
"SkyAsl/Nanbeige4.1-VLM",
trust_remote_code=True,
)
model.to("cuda")
tokenizer = AutoTokenizer.from_pretrained(
"SkyAsl/Nanbeige4.1-VLM",
trust_remote_code=True,
)
model.set_tokenizer(tokenizer)
image = Image.open("photo.jpg")
result = model.describe(image, prompt="What do you see in this image?")
print(result)
| Stage 1 | Stage 2 | |
|---|---|---|
| Dataset | LLaVA-CC3M-595K | LLaVA-Instruct-150K |
| Trainable | Projector only | Projector + LoRA (r=64) |
| LR | 2e-3 | 2e-5 |
| Hardware | A100 80GB | A100 80GB |
| Duration | ~6 hours | ~5 hours |