Update README.md
Browse files
README.md
CHANGED
@@ -1,199 +1,150 @@
|
|
1 |
---
|
2 |
-
|
3 |
-
|
|
|
4 |
---
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
- **
|
26 |
-
- **
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
- **
|
33 |
-
- **
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
## Model Card Contact
|
198 |
-
|
199 |
-
[More Information Needed]
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
pipeline_tag: text-generation
|
5 |
---
|
6 |
|
7 |
+
<p align="center">
|
8 |
+
<img src="./Bespoke-Labs-Logo.png" width="550">
|
9 |
+
</p>
|
10 |
+
|
11 |
+
# Bespoke-MiniChart-7B
|
12 |
+
|
13 |
+
[](https://colab.research.google.com/drive/1FEmlwGgn9209iQO-rs2-9UHPLoytwZMH?usp=sharing)
|
14 |
+
|
15 |
+
This is an open‑source chart‑understanding Vision‑Language Model (VLM) developed at **Bespoke Labs** and maintained by **Liyan Tang** and **Bespoke Labs**. It sets a new state‑of‑the‑art in chart question‑answering (Chart‑QA) for 7 billion‑parameter models, outperforming much larger closed models such as Gemini‑1.5‑Pro and Claude‑3.5 on seven public benchmarks.
|
16 |
+
|
17 |
+
Please check our blog for more information about how we trained the model <Blog Post Link>
|
18 |
+
|
19 |
+
# Model Performance
|
20 |
+
|
21 |
+
Our model achieves state-of-the-art performance on chart understanding among models with similar sizes. In addition to that, our models can even surpass closed-models such as Gemini-1.5-Pro and Claude-3.5.
|
22 |
+
|
23 |
+
| Model / Category | ChartQAPro (1637) | ChartQA (2500) | EvoChart (1250) | CharXiv (4000) | ChartX (1152) | ChartBench (2100) | MMC (808) | Average |
|
24 |
+
|----------------------------------------|------------------:|---------------:|----------------:|---------------:|--------------:|------------------:|----------:|--------:|
|
25 |
+
| **Open-Models (11 B and less)** | | | | | | | | |
|
26 |
+
| InternVL-2.5-8B | –| **78.2** | 53.0 | 55.7 | 49.5 | 44.7 | **85.5** | – |
|
27 |
+
| Qwen2-VL-7B | –| **82.1** | 54.5 | 53.5 | 50.8 | 50.8 | **83.9** | – |
|
28 |
+
| Qwen2.5-VL-7B | **53.5** | **86.0** | 67.9 | 60.9 | 67.0 | 61.4 | **86.0** | **69.0**|
|
29 |
+
| **Ours** | | | | | | | | |
|
30 |
+
| Bespoke-MiniChart-7B | **56.7** | **89.5** | **71.8** | **66.4** | **68.9** | **66.1** | **88.4** | **72.5**|
|
31 |
+
| **Open-Models (32 B and more)** | | | | | | | | |
|
32 |
+
| QVQ-72B-Preview | –| **84.2** | 65.0 | 59.0 | 60.9 | 53.8 | **83.4** | – |
|
33 |
+
| Qwen2.5-VL-32B | **58.4** | **89.5** | 74.3 | 66.9 | 64.5 | 59.8 | **89.6** | **71.9**|
|
34 |
+
| Qwen2.5-VL-72B | **59.0** | **90.0** | **76.8** | 67.1 | **67.2** | 61.5 | **91.2** | **73.3**|
|
35 |
+
| **Closed-Models** | | | | | | | | |
|
36 |
+
| GPT-4o | **53.6** | 85.7 | 71.7 | 67.8 | 54.3 | 46.1 | **89.1** | 66.9 |
|
37 |
+
| Gemini-1.5-flash | **53.8** | 85.6 | 67.5 | 67.7 | 63.5 | 58.1 | 82.1 | 68.3 |
|
38 |
+
| Gemini-1.5-pro | **59.2** | **89.0** | 72.0 | **69.9** | 65.4 | 62.4 | 87.9 | **72.3**|
|
39 |
+
| Claude-3.5 | **56.6** | 85.7 | **78.1** | **69.7** | 64.7 | 60.9 | **89.9** | **72.2**|
|
40 |
+
| Claude-3.7 | **63.0** | 86.1 | **80.1** | **69.7** | **69.2** | **65.0** | 88.4 | **74.5**|
|
41 |
+
|
42 |
+
|
43 |
+
# Model Use:
|
44 |
+
|
45 |
+
```python
|
46 |
+
import requests
|
47 |
+
from PIL import Image
|
48 |
+
from io import BytesIO
|
49 |
+
import base64
|
50 |
+
import matplotlib.pyplot as plt
|
51 |
+
from vllm import LLM, SamplingParams
|
52 |
+
|
53 |
+
QA_PROMPT = """Please answer the question using the chart image.
|
54 |
+
|
55 |
+
Question: [QUESTION]
|
56 |
+
|
57 |
+
Please first generate your reasoning process and then provide the user with the answer. Use the following format:
|
58 |
+
|
59 |
+
<think>
|
60 |
+
... your thinking process here ...
|
61 |
+
</think>
|
62 |
+
<answer>
|
63 |
+
... your final answer (entity(s) or number) ...
|
64 |
+
</answer>"""
|
65 |
+
|
66 |
+
def get_image_from_url(image_url):
|
67 |
+
try:
|
68 |
+
response = requests.get(image_url, stream=True)
|
69 |
+
response.raise_for_status()
|
70 |
+
return Image.open(BytesIO(response.content))
|
71 |
+
except Exception as e:
|
72 |
+
print(f"Error with image: {e}")
|
73 |
+
return None
|
74 |
+
|
75 |
+
def get_answer(image_url, question, display=True):
|
76 |
+
image = get_image_from_url(image_url)
|
77 |
+
|
78 |
+
if display:
|
79 |
+
plt.figure(figsize=(10, 8))
|
80 |
+
plt.imshow(image)
|
81 |
+
plt.axis('off')
|
82 |
+
plt.show()
|
83 |
+
|
84 |
+
if not image:
|
85 |
+
return "Error downloading image"
|
86 |
+
|
87 |
+
buffered = BytesIO()
|
88 |
+
image.save(buffered, format=image.format or 'JPEG')
|
89 |
+
encoded_image = base64.b64encode(buffered.getvalue()).decode('utf-8')
|
90 |
+
|
91 |
+
messages = [{
|
92 |
+
"role": "user",
|
93 |
+
"content": [
|
94 |
+
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{encoded_image}"}},
|
95 |
+
{"type": "text", "text": QA_PROMPT.replace("[QUESTION]", question)}
|
96 |
+
]
|
97 |
+
}]
|
98 |
+
|
99 |
+
response = llm.chat([messages], sampling_params=SamplingParams(temperature=0, max_tokens=500))
|
100 |
+
return response[0].outputs[0].text
|
101 |
+
|
102 |
+
# Initialize the LLM
|
103 |
+
llm = LLM(
|
104 |
+
model="bespokelabs/Bespoke-MiniChart-7B",
|
105 |
+
tokenizer_mode="auto",
|
106 |
+
max_model_len=15000,
|
107 |
+
tensor_parallel_size=1,
|
108 |
+
gpu_memory_utilization=0.9,
|
109 |
+
mm_processor_kwargs={"max_pixels": 1600*28*28},
|
110 |
+
seed=2025,
|
111 |
+
trust_remote_code=True,
|
112 |
+
)
|
113 |
+
|
114 |
+
# Running inference
|
115 |
+
image_url = "https://github.com/bespokelabsai/chartqa-examples/blob/main/images/ilyc9wk4jf8b1.png?raw=true"
|
116 |
+
question = "How many global regions maintained their startup funding losses below 30% in 2022?"
|
117 |
+
|
118 |
+
print("\n\n=================Model Output:===============\n\n", get_answer(image_url, question))
|
119 |
+
```
|
120 |
+
|
121 |
+
# Licence
|
122 |
+
|
123 |
+
This work is licensed under [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/).
|
124 |
+
For commercial licensing, please contact company@bespokelabs.ai.
|
125 |
+
|
126 |
+
# Citation
|
127 |
+
|
128 |
+
```
|
129 |
+
@misc{bespoke_minichart_7b,
|
130 |
+
title = {Bespoke-MiniChart-7B: pushing the frontiers of open VLMs for chart understanding},
|
131 |
+
author = {Liyan Tang and Shreyas Pimpalgaonkar and Kartik Sharma and Alexandros G. Dimakis and Mahesh Sathiamoorthy and Greg Durrett},
|
132 |
+
howpublished = {blog post},
|
133 |
+
year = {2025},
|
134 |
+
url={https://huggingface.co/bespokelabs/Bespoke-MiniChart-7B},
|
135 |
+
}
|
136 |
+
```
|
137 |
+
|
138 |
+
# Acknowledgements
|
139 |
+
|
140 |
+
**Bespoke Labs** team:
|
141 |
+
|
142 |
+
- Liyan Tang
|
143 |
+
- Shreyas Pimpalgaonkar
|
144 |
+
- Kartik Sharma
|
145 |
+
- Alex Dimakis
|
146 |
+
- Mahesh Sathiamoorthy
|
147 |
+
- Greg Durrett
|
148 |
+
|
149 |
+
|
150 |
+
*Model perfected at Bespoke Labs — where careful curation meets cutting‑edge modeling.*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|