Glazkov commited on
Commit
82ec2cd
·
verified ·
1 Parent(s): f47e0d2

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +123 -0
README.md ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ tags:
4
+ - vision-language-model
5
+ - table-extraction
6
+ - financial-documents
7
+ - qwen2.5-vl
8
+ - fine-tuned
9
+ pipeline_tag: image-to-text
10
+ license: other
11
+ ---
12
+
13
+ # Glazkov/qwen2.5-vl-table-extraction-ru-v0.1-bnb-4bit
14
+
15
+ Fine-tuned Qwen2.5-VL-3B model for extracting structured data from financial and economic table images. This model has been trained on synthetic table data to convert table images into JSON format with parameter, date, value, and measurement fields.
16
+
17
+ ## Model Details
18
+
19
+ - **Base Model**: Qwen/Qwen2.5-VL-3B-Instruct
20
+ - **Model Type**: Vision-Language Model (VLM)
21
+ - **Task**: Table Extraction from Images
22
+ - **Architecture**: Qwen2.5-VL with LoRA fine-tuning
23
+
24
+ ## Intended Use
25
+
26
+ This model is designed to extract structured data from financial and economic table images. It can handle various table formats including:
27
+ - Simple tables with rows and columns
28
+ - Tables with additional notes/comments
29
+ - Pivot table layouts
30
+ - Tables with multi-level headers
31
+
32
+ ## How to Use
33
+
34
+ ### Installation
35
+ ```bash
36
+ pip install transformers torch accelerate Pillow qwen-vl-utils
37
+ ```
38
+
39
+ ### Basic Usage
40
+ ```python
41
+ from transformers import AutoModelForImageTextToText, AutoProcessor
42
+ from PIL import Image
43
+ import torch
44
+
45
+ model_id = "Glazkov/qwen2.5-vl-table-extraction-ru-v0.1-bnb-4bit"
46
+ model = AutoModelForImageTextToText.from_pretrained(model_id, device_map="auto", torch_dtype=torch.bfloat16)
47
+ processor = AutoProcessor.from_pretrained(model_id)
48
+
49
+ # Load image
50
+ image = Image.open("table_image.png")
51
+
52
+ # Create conversation
53
+ conversation = [
54
+ {
55
+ "role": "user",
56
+ "content": [
57
+ {"type": "image", "image": image},
58
+ {"type": "text", "text": "Extract the data from this table image and return it as a JSON array where each object has the keys: 'parameter', 'date', 'value', and 'measurement'."},
59
+ ],
60
+ }
61
+ ]
62
+
63
+ # Process and generate
64
+ text = processor.apply_chat_template(conversation, tokenize=False, add_generation_prompt=True)
65
+ image_inputs, _ = process_vision_info(conversation)
66
+ inputs = processor(text=[text], images=image_inputs, return_tensors="pt", padding=True)
67
+
68
+ # Generate
69
+ with torch.no_grad():
70
+ outputs = model.generate(**inputs, max_new_tokens=4096)
71
+
72
+ response = processor.batch_decode(outputs[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)[0]
73
+ print(response)
74
+ ```
75
+
76
+ ## Model Input
77
+
78
+ The model expects:
79
+ - **Image**: Table images in any common format (PNG, JPEG, etc.)
80
+ - **Text Prompt**: Instructions for table extraction
81
+ - **Output Format**: JSON array with parameter, date, value, and measurement fields
82
+
83
+ ## Model Output
84
+
85
+ The model generates structured JSON output in the following format:
86
+ ```json
87
+ [
88
+ {
89
+ "parameter": "指标名称",
90
+ "date": "年份",
91
+ "value": "数值",
92
+ "measurement": "单位"
93
+ }
94
+ ]
95
+ ```
96
+
97
+ ## Training Details
98
+
99
+
100
+ ### Training Data
101
+ The model was trained on synthetic financial and economic table data with various table formats including simple tables, tables with extra columns, pivot tables, and combined header tables. Training data includes tables in multiple languages (English, Russian, Chinese) with realistic financial metrics and formatting.
102
+
103
+ ## Limitations
104
+
105
+ - The model is specifically trained for financial and economic tables
106
+ - Performance may vary with table layouts not seen during training
107
+ - Handwritten text or highly stylized tables may be challenging
108
+ - The model assumes tables contain structured financial/economic data
109
+
110
+ ## Ethical Considerations
111
+
112
+ This model is intended for legitimate document processing and data extraction tasks. Users should ensure they have appropriate rights to process any documents and comply with relevant data protection regulations.
113
+
114
+ ## Technical Specifications
115
+
116
+ - **Framework**: PyTorch
117
+ - **Hardware**: Trained on GPU with mixed precision
118
+ - **Quantization**: 4-bit quantization support available
119
+ - **Memory Requirements**: ~8GB GPU memory (4-bit quantized), ~16GB GPU memory (full precision)
120
+
121
+ ## Citation
122
+
123
+ If you use this model in your research or applications, please cite the original Qwen2.5-VL model and acknowledge any specific modifications made during fine-tuning.