PAPOGalaxy/PAPO_ViRL39K_train
Viewer • Updated • 38.9k • 793 • 3
How to use PAPOGalaxy/PAPO-G-H-Qwen2.5-VL-7B with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="PAPOGalaxy/PAPO-G-H-Qwen2.5-VL-7B")
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 AutoProcessor, AutoModelForImageTextToText
processor = AutoProcessor.from_pretrained("PAPOGalaxy/PAPO-G-H-Qwen2.5-VL-7B")
model = AutoModelForImageTextToText.from_pretrained("PAPOGalaxy/PAPO-G-H-Qwen2.5-VL-7B")
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=40)
print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use PAPOGalaxy/PAPO-G-H-Qwen2.5-VL-7B with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "PAPOGalaxy/PAPO-G-H-Qwen2.5-VL-7B"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "PAPOGalaxy/PAPO-G-H-Qwen2.5-VL-7B",
"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/PAPOGalaxy/PAPO-G-H-Qwen2.5-VL-7B
How to use PAPOGalaxy/PAPO-G-H-Qwen2.5-VL-7B with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "PAPOGalaxy/PAPO-G-H-Qwen2.5-VL-7B" \
--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": "PAPOGalaxy/PAPO-G-H-Qwen2.5-VL-7B",
"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 "PAPOGalaxy/PAPO-G-H-Qwen2.5-VL-7B" \
--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": "PAPOGalaxy/PAPO-G-H-Qwen2.5-VL-7B",
"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 PAPOGalaxy/PAPO-G-H-Qwen2.5-VL-7B with Docker Model Runner:
docker model run hf.co/PAPOGalaxy/PAPO-G-H-Qwen2.5-VL-7B
This is the official model released for the paper Perception-Aware Policy Optimization for Multimodal Reasoning.
Project Page: https://mikewangwzhl.github.io/PAPO/ Code: https://github.com/mikewangwzhl/PAPO
PAPO (γ=0.02)
This model can be loaded and used with the transformers library.
from transformers import AutoProcessor, AutoModelForCausalLM
from PIL import Image
import requests
# Load the processor and model
# Note: Replace "PAPOGalaxy/PAPO-Qwen2.5-7B" with the actual model ID if different
processor = AutoProcessor.from_pretrained("PAPOGalaxy/PAPO-Qwen2.5-7B", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("PAPOGalaxy/PAPO-Qwen2.5-7B", trust_remote_code=True)
# Example image (replace with your image URL or local path)
image_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/preprocessor_config_vln.png"
image = Image.open(requests.get(image_url, stream=True).raw).convert("RGB")
# Define your prompt
prompt = "What are the main objects in this image?"
# Format messages for the model
messages = [
{"role": "user", "content": [{"type": "image", "content": image}, {"type": "text", "text": prompt}]}
]
# Apply chat template and tokenize
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
input_ids = processor(text, return_tensors="pt").input_ids
# Generate response
output_ids = model.generate(
input_ids,
max_new_tokens=100,
do_sample=True,
temperature=0.7,
top_p=0.9,
)
# Decode and print the generated text
generated_text = processor.decode(output_ids[0], skip_special_tokens=True)
print(generated_text)