Views
No views yet
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.| 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 |
1import torch
2from transformers import AutoProcessor, Qwen2_5_VLForConditionalGeneration
3from qwen_vl_utils import process_vision_info
4
5model_id = "yunfanyang1/Qwen2.5-VL-7B-CSPO"
6
7model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
8 model_id,
9 torch_dtype=torch.bfloat16,
10 device_map="auto",
11 attn_implementation="flash_attention_2",
12)
13
14processor = AutoProcessor.from_pretrained(model_id)
15
16messages = [
17 {
18 "role": "user",
19 "content": [
20 {"type": "image", "image": "file:///absolute/path/to/table_image.png"},
21 {
22 "type": "text",
23 "text": "Please generate complete LaTeX code for the table in the image, including the table body and the full preamble."
24 },
25 ],
26 }
27]
28
29text = processor.apply_chat_template(
30 messages,
31 tokenize=False,
32 add_generation_prompt=True,
33)
34
35image_inputs, video_inputs = process_vision_info(messages)
36
37inputs = processor(
38 text=[text],
39 images=image_inputs,
40 videos=video_inputs,
41 padding=True,
42 padding_side="left",
43 return_tensors="pt",
44).to(model.device)
45
46generated_ids = model.generate(
47 **inputs,
48 max_new_tokens=8192,
49 do_sample=False,
50)
51
52generated_ids_trimmed = [
53 out_ids[len(in_ids):]
54 for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
55]
56
57output_text = processor.batch_decode(
58 generated_ids_trimmed,
59 skip_special_tokens=True,
60 clean_up_tokenization_spaces=False,
61)
62
63print(output_text[0])Qwen/Qwen2.5-VL-7B-Instruct; users should also comply with the license and terms of the base model.1@article{yang2026cspo,
2 title={CSPO: Alleviating Reward Ambiguity for Structured Table-to-LaTeX Generation},
3 author={Yang, Yunfan and Lan, Cuiling and Sang, Jitao and Lu, Yan},
4 journal={arXiv preprint arXiv:2604.10918},
5 year={2026}
6}