baptistecolle commited on
Commit
31cccf3
·
1 Parent(s): 0de103b

update readme

Browse files
Files changed (1) hide show
  1. README.md +218 -156
README.md CHANGED
@@ -1,199 +1,261 @@
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
+ license: apache-2.0
3
  library_name: transformers
4
+ tags:
5
+ - code
6
+ - jupyter
7
+ - agent
8
+ - data-science
9
+ - qwen
10
+ - thinking
11
+ base_model: Qwen/Qwen3-4B-Thinking-2507
12
+ datasets:
13
+ - data-agents/jupyter-agent-dataset
14
+ language:
15
+ - en
16
+ - code
17
+ pipeline_tag: text-generation
18
  ---
19
 
20
+ # Jupyter Agent Qwen3-4B Thinking
21
 
22
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/650ed7adf141bc34f91a12ae/ZyF9foqe5SLECwkq0dOpT.png)
23
 
24
+ **Jupyter Agent Qwen3-4B Thinking** is a fine-tuned version of [Qwen3-4B-Thinking-2507](https://huggingface.co/Qwen/Qwen3-4B-Thinking-2507) specifically optimized for **data science agentic tasks** in Jupyter notebook environments. This model can execute Python code, analyze datasets, and provide step-by-step reasoning with intermediate computations to solve realistic data analysis problems.
25
 
26
+ - **Model type:** Causal Language Model (Thinking)
27
+ - **Language(s):** English, Python
28
+ - **License:** Apache 2.0
29
+ - **Finetuned from:** [Qwen/Qwen3-4B-Thinking-2507](https://huggingface.co/Qwen/Qwen3-4B-Thinking-2507)
30
 
31
+ ## Key Features
32
 
33
+ - **Jupyter-native agent** that lives inside notebook environments
34
+ - **Code execution** with pandas, numpy, matplotlib, and other data science libraries
35
+ - **Step-by-step reasoning** with intermediate computations and thinking traces
36
+ - **Dataset-grounded analysis** trained on real Kaggle notebook workflows
37
+ - **Tool calling** for structured code execution and final answer generation
38
+
39
+ ## Performance
40
+
41
+ On the [DABStep benchmark](https://huggingface.co/spaces/adyen/DABstep) for data science tasks:
42
+
43
+ | Model | Easy Tasks | Hard Tasks |
44
+ |-------|------------|------------|
45
+ | Qwen3-4B-Thinking-2507 (Base) | 44.0% | 2.1% |
46
+ | **Jupyter Agent Qwen3-4B Thinking** | **70.8%** | **3.4%** |
47
+
48
+ **State-of-the-art performance** for small models on realistic data analysis tasks.
49
+
50
+ ## Model Sources
51
+
52
+ - **Repository:** [jupyter-agent](https://github.com/huggingface/jupyter-agent)
53
+ - **Dataset:** [jupyter-agent-dataset](https://huggingface.co/datasets/data-agents/jupyter-agent-dataset)
54
+ - **Blog post:** [Jupyter Agents: training LLMs to reason with notebooks](https://huggingface.co/blog/jupyter-agent-2)
55
+ - **Demo:** [Jupyter Agent 2](https://huggingface.co/spaces/lvwerra/jupyter-agent-2)
56
+
57
+ ## Usage
58
+
59
+ ### Basic Usage
60
+
61
+ ```python
62
+ from transformers import AutoModelForCausalLM, AutoTokenizer
63
+
64
+ model_name = "data-agents/jupyter-agent-qwen3-4b-thinking"
65
+
66
+ # Load model and tokenizer
67
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
68
+ model = AutoModelForCausalLM.from_pretrained(
69
+ model_name,
70
+ torch_dtype="auto",
71
+ device_map="auto"
72
+ )
73
+
74
+ # Prepare input
75
+ prompt = "Analyze this sales dataset and find the top 3 performing products by revenue."
76
+ messages = [
77
+ {"role": "user", "content": prompt}
78
+ ]
79
+
80
+ text = tokenizer.apply_chat_template(
81
+ messages,
82
+ tokenize=False,
83
+ add_generation_prompt=True
84
+ )
85
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
86
+
87
+ # Generate response
88
+ generated_ids = model.generate(
89
+ **model_inputs,
90
+ max_new_tokens=16384
91
+ )
92
+ output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
93
+ ```
94
+
95
+ ### Decoding Thinking and Content
96
+
97
+ For thinking models, you can extract both the reasoning and final response:
98
+
99
+ ```python
100
+ try:
101
+ # Find the end of thinking section (</think>)
102
+ index = len(output_ids) - output_ids[::-1].index(151668)
103
+ except ValueError:
104
+ index = 0
105
+
106
+ thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")
107
+ content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")
108
+
109
+ print("Thinking:", thinking_content)
110
+ print("Response:", content)
111
+ ```
112
+
113
+ ### Agentic Usage with Tool Calling
114
+
115
+ The model works best with proper scaffolding for tool calling:
116
+
117
+ ```python
118
+ tools = [
119
+ {
120
+ "type": "function",
121
+ "function": {
122
+ "name": "execute_code",
123
+ "description": "Execute Python code in a Jupyter environment",
124
+ "parameters": {
125
+ "type": "object",
126
+ "properties": {
127
+ "code": {
128
+ "type": "string",
129
+ "description": "Python code to execute"
130
+ }
131
+ },
132
+ "required": ["code"]
133
+ }
134
+ }
135
+ },
136
+ {
137
+ "type": "function",
138
+ "function": {
139
+ "name": "final_answer",
140
+ "description": "Provide the final answer to the question",
141
+ "parameters": {
142
+ "type": "object",
143
+ "properties": {
144
+ "answer": {
145
+ "type": "string",
146
+ "description": "The final answer"
147
+ }
148
+ },
149
+ "required": ["answer"]
150
+ }
151
+ }
152
+ }
153
+ ]
154
+
155
+ # Include tools in the conversation
156
+ messages = [
157
+ {
158
+ "role": "system",
159
+ "content": "You are a data science assistant. Use the available tools to analyze data and provide insights."
160
+ },
161
+ {"role": "user", "content": prompt}
162
+ ]
163
+ ```
164
 
165
  ## Training Details
166
 
167
  ### Training Data
168
 
169
+ The model was fine-tuned on the [Jupyter Agent Dataset](https://huggingface.co/datasets/data-agents/jupyter-agent-dataset), which contains:
170
 
171
+ - **51,389 synthetic notebooks** (~2B tokens)
172
+ - **Dataset-grounded QA pairs** from real Kaggle notebooks
173
+ - **Executable reasoning traces** with intermediate computations
174
+ - **High-quality educational content** filtered and scored by LLMs
175
 
176
  ### Training Procedure
177
 
178
+ - **Base Model:** Qwen3-4B-Thinking-2507
179
+ - **Training Method:** Full-parameter fine-tuning (not PEFT)
180
+ - **Optimizer:** AdamW with cosine learning rate scheduling
181
+ - **Learning Rate:** 5e-6
182
+ - **Epochs:** 5 (optimal based on ablation study)
183
+ - **Context Length:** 32,768 tokens
184
+ - **Batch Size:** Distributed across multiple GPUs
185
+ - **Loss:** Assistant-only loss (`assistant_loss_only=True`)
186
+ - **Regularization:** NEFTune noise (α=7) for full-parameter training
187
 
188
+ ### Training Infrastructure
189
 
190
+ - **Framework:** [TRL](https://github.com/huggingface/trl) with [Transformers](https://github.com/huggingface/transformers)
191
+ - **Distributed Training:** DeepSpeed ZeRO-2 across multiple nodes
192
+ - **Hardware:** Multi-GPU setup with SLURM orchestration
 
 
 
 
193
 
194
  ## Evaluation
195
 
196
+ ### Benchmark: DABStep
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
 
198
+ The model was evaluated on [DABStep](https://huggingface.co/spaces/adyen/DABstep), a benchmark for data science agents with realistic tasks involving:
199
 
200
+ - **Dataset analysis** with pandas and numpy
201
+ - **Visualization** with matplotlib/seaborn
202
+ - **Statistical analysis** and business insights
203
+ - **Multi-step reasoning** with intermediate computations
204
 
205
+ The model achieves **26.8% improvement** over the base model and **11.1% improvement** over scaffolding alone.
206
 
207
+ <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/jupyter-agent-2/training_dabstep_easy.png" alt="DABstep Easy Score"/>
208
 
209
+ We can also see, that the hard score can increase too even though our dataset is focused on easier questions.
210
 
211
+ <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/jupyter-agent-2/training_dabstep_hard.png" alt="DABstep Hard Score"/>
212
 
213
+ ## Limitations and Bias
214
 
215
+ ### Technical Limitations
216
 
217
+ - **Context window:** Limited to 32K tokens, may struggle with very large notebooks
218
+ - **Tool calling format:** Requires specific scaffolding for optimal performance
219
+ - **Dataset domains:** Primarily trained on Kaggle-style data science tasks
220
+ - **Code execution:** Requires proper sandboxing for safe execution
221
 
222
+ ### Potential Biases
 
 
 
 
223
 
224
+ - **Domain bias:** Trained primarily on Kaggle notebooks, may not generalize to all data science workflows
225
+ - **Language bias:** Optimized for English and Python, limited multilingual support
226
+ - **Task bias:** Focused on structured data analysis, may underperform on unstructured data tasks
227
 
228
+ ### Recommendations
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
 
230
+ - Use in **sandboxed environments** like [E2B](https://e2b.dev/) for safe code execution
231
+ - **Validate outputs** before using in production systems
232
+ - **Review generated code** for security and correctness
233
+ - Consider **domain adaptation** for specialized use cases
234
 
235
+ ## Ethical Considerations
236
 
237
+ - **Code Safety:** Always execute generated code in secure, isolated environments
238
+ - **Data Privacy:** Be cautious when analyzing sensitive datasets
239
+ - **Verification:** Validate all analytical conclusions and insights
240
+ - **Attribution:** Acknowledge model assistance in data analysis workflows
241
 
242
+ ## Citation
243
 
244
+ ```bibtex
245
+ @misc{jupyteragentqwen3thinking,
246
+ title={Jupyter Agent Qwen3-4B Thinking},
247
+ author={Baptiste Colle and Hanna Yukhymenko and Leandro von Werra},
248
+ year={2025},
249
+ publisher={Hugging Face},
250
+ url={https://huggingface.co/data-agents/jupyter-agent-qwen3-4b-thinking}
251
+ }
252
+ ```
253
 
254
+ ## Related Work
255
 
256
+ - **Dataset:** [jupyter-agent-dataset](https://huggingface.co/datasets/data-agents/jupyter-agent-dataset)
257
+ - **Non-thinking version:** [jupyter-agent-qwen3-4b-instruct](https://huggingface.co/data-agents/jupyter-agent-qwen3-4b-instruct)
258
+ - **Base model:** [Qwen3-4B-Thinking-2507](https://huggingface.co/Qwen/Qwen3-4B-Thinking-2507)
259
+ - **Benchmark:** [DABStep](https://huggingface.co/spaces/adyen/DABstep)
260
 
261
+ *For more details, see our [blog post](https://huggingface.co/blog/jupyter-agent-2) and [GitHub repository](https://github.com/huggingface/jupyter-agent).*