Instructions to use yunfanyang1/Qwen2.5-VL-7B-CSPO with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yunfanyang1/Qwen2.5-VL-7B-CSPO with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="yunfanyang1/Qwen2.5-VL-7B-CSPO") 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, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("yunfanyang1/Qwen2.5-VL-7B-CSPO") model = AutoModelForMultimodalLM.from_pretrained("yunfanyang1/Qwen2.5-VL-7B-CSPO", device_map="auto") 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yunfanyang1/Qwen2.5-VL-7B-CSPO with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yunfanyang1/Qwen2.5-VL-7B-CSPO" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yunfanyang1/Qwen2.5-VL-7B-CSPO", "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" } } ] } ] }'Use Docker
docker model run hf.co/yunfanyang1/Qwen2.5-VL-7B-CSPO
- SGLang
How to use yunfanyang1/Qwen2.5-VL-7B-CSPO 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 "yunfanyang1/Qwen2.5-VL-7B-CSPO" \ --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": "yunfanyang1/Qwen2.5-VL-7B-CSPO", "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" } } ] } ] }'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 "yunfanyang1/Qwen2.5-VL-7B-CSPO" \ --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": "yunfanyang1/Qwen2.5-VL-7B-CSPO", "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 Runner
How to use yunfanyang1/Qwen2.5-VL-7B-CSPO with Docker Model Runner:
docker model run hf.co/yunfanyang1/Qwen2.5-VL-7B-CSPO
Qwen2.5-VL-7B-CSPO
Official model weights for CSPO: Alleviating Reward Ambiguity for Structured Table-to-LaTeX Generation.
- Paper: https://arxiv.org/pdf/2604.10918
- Code: https://github.com/microsoft/CSPO
- Dataset: https://huggingface.co/datasets/yunfanyang1/TableTex
- Base Model: https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct
Model Description
Qwen2.5-VL-7B-CSPO is a multimodal model for structured table-to-LaTeX generation. It is built on top of Qwen/Qwen2.5-VL-7B-Instruct and trained to convert table images into complete, compilable LaTeX code.
The model is trained with a two-stage pipeline consisting of supervised fine-tuning (SFT) followed by reinforcement learning with Component-Specific Policy Optimization (CSPO). CSPO introduces component-specific rewards and token-level credit assignment to mitigate reward ambiguity in structured generation, enabling more reliable optimization of table structure, content, and style.
For more details, please see the full model card in the GitHub repository: https://github.com/microsoft/CSPO/blob/main/CSPO_Model_Card.md
| Component | Detail |
|---|---|
| Model | Qwen2.5-VL-7B-CSPO |
| Backbone | Qwen2.5-VL-7B-Instruct |
| Model Type | Vision-language model |
| Task | Table image-to-LaTeX generation |
| Input | Table image + text instruction |
| Output | LaTeX code |
| Training Data | TableTex |
| Training Pipeline | SFT + CSPO |
Training Data
The model is trained on TableTex, a dataset of paired table images and renderable LaTeX code constructed from publicly available arXiv papers under permissive licenses. The dataset contains tables from multiple academic domains, including Computer Science, Mathematics, Economics, Electrical Engineering and Systems Science, Quantitative Finance, and Statistics.
TableTex contains 19,000 table image-LaTeX pairs, split into 15,000 training samples and 4,000 test samples. Each sample includes a rendered table image and corresponding LaTeX code with necessary package declarations, table captions, and the table body.
Evaluation
Detailed evaluation results are reported in our paper.
Usage
import torch
from transformers import AutoProcessor, Qwen2_5_VLForConditionalGeneration
from qwen_vl_utils import process_vision_info
model_id = "yunfanyang1/Qwen2.5-VL-7B-CSPO"
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
attn_implementation="flash_attention_2",
)
processor = AutoProcessor.from_pretrained(model_id)
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": "file:///absolute/path/to/table_image.png"},
{
"type": "text",
"text": "Please generate complete LaTeX code for the table in the image, including the table body and the full preamble."
},
],
}
]
text = processor.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
text=[text],
images=image_inputs,
videos=video_inputs,
padding=True,
padding_side="left",
return_tensors="pt",
).to(model.device)
generated_ids = model.generate(
**inputs,
max_new_tokens=8192,
do_sample=False,
)
generated_ids_trimmed = [
out_ids[len(in_ids):]
for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed,
skip_special_tokens=True,
clean_up_tokenization_spaces=False,
)
print(output_text[0])
See the GitHub repository for full installation, evaluation, and training instructions.
License
This model is built on top of Qwen/Qwen2.5-VL-7B-Instruct; users should also comply with the license and terms of the base model.
Citation
If you find this model useful, please cite our paper:
@article{yang2026cspo,
title={CSPO: Alleviating Reward Ambiguity for Structured Table-to-LaTeX Generation},
author={Yang, Yunfan and Lan, Cuiling and Sang, Jitao and Lu, Yan},
journal={arXiv preprint arXiv:2604.10918},
year={2026}
}
- Downloads last month
- 5
Model tree for yunfanyang1/Qwen2.5-VL-7B-CSPO
Base model
Qwen/Qwen2.5-VL-7B-Instruct