pimpalgaonkar commited on
Commit
d5866e5
·
verified ·
1 Parent(s): 5dc2230

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +147 -196
README.md CHANGED
@@ -1,199 +1,150 @@
1
  ---
2
- library_name: transformers
3
- tags: []
 
4
  ---
5
 
6
- # Model Card for Model ID
7
-
8
- <!-- Provide a quick summary of what the model is/does. -->
9
-
10
-
11
-
12
- ## Model Details
13
-
14
- ### Model Description
15
-
16
- <!-- Provide a longer summary of what this model is. -->
17
-
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
-
28
- ### Model Sources [optional]
29
-
30
- <!-- Provide the basic links for the model. -->
31
-
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
-
36
- ## Uses
37
-
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
-
46
- ### Downstream Use [optional]
47
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
-
52
- ### Out-of-Scope Use
53
-
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
-
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
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
+ [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](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&nbsp;(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&nbsp;(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.*