Inserloft commited on
Commit
8ce887e
·
verified ·
1 Parent(s): 3a9133d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +158 -0
README.md CHANGED
@@ -1,3 +1,161 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ language:
4
+ - es
5
+ - en
6
+ tags:
7
+ - Dataset
8
+ - Datasets
9
+ - Esp
10
+ - Eng
11
+ - Tiny
12
+ - PyMini
13
+ - Mini
14
+ pretty_name: PyMini
15
+ size_categories:
16
+ - 10K<n<100K
17
  ---
18
+
19
+ # PyMini – A Compact Python Instruction Dataset for Small Language Models
20
+
21
+ **PyMini** is a synthetic instruction dataset built by [Inserloft](https://inserloft.com) to teach Python programming to small language models (<2B parameters). It covers fundamental Python concepts through a diverse set of tasks — code prediction, bug fixing, function completion, explanation, and conceptual Q&A. Available in **English, Spanish, or bilingual** versions.
22
+
23
+ ## Dataset Description
24
+
25
+ PyMini provides a **high-quality, compact, and fully synthetic** dataset for fine-tuning models that need a solid grasp of Python without unnecessary complexity. Every example is generated programmatically, avoiding license issues and giving exact control over difficulty and coverage.
26
+
27
+ - **Languages:** English (`en`), Spanish (`es`), or mixed (`both`)
28
+ - **Number of examples:** Configurable; default release contains **50,000 examples** (balanced across task types)
29
+ - **Format:** JSON Lines (`.jsonl`), easily convertible to Parquet
30
+ - **Generated with:** Python script (no web scraping, no copyrighted code)
31
+
32
+ ## Dataset Structure
33
+
34
+ Each example is a JSON object with three fields:
35
+
36
+ ```json
37
+ {
38
+ "instruction": "string (the task description)",
39
+ "input": "string (code snippet or empty)",
40
+ "output": "string (the expected answer/code/explanation)"
41
+ }
42
+ ```
43
+
44
+ Example (English):
45
+
46
+ ```json
47
+ {
48
+ "instruction": "What is the output of the following code?",
49
+ "input": "```python\nprint(3 + 4 * 5)\n```",
50
+ "output": "23"
51
+ }
52
+ ```
53
+
54
+ The `input` field may be empty for tasks like "Write a function...".
55
+
56
+ ## Task Types and Distribution
57
+
58
+ | Task Type | Description | Approx. Weight |
59
+ |---|---|---|
60
+ | Predict Output | Given a code snippet, predict what it prints or evaluates to. | 25% |
61
+ | Fix Bug | Correct syntax or logical errors in provided code. | 15% |
62
+ | Fill Missing Line | Complete a partially written function body to fulfill its purpose. | 15% |
63
+ | Write Function | Write a whole function from a natural language specification. | 20% |
64
+ | Explain Code | Explain in plain language what a piece of code does. | 15% |
65
+ | Concept Question | Answer a theoretical question about Python (e.g., "What is a list?"). | 10% |
66
+ | Convert Code | Transform a loop into a comprehension or vice versa. | 5% |
67
+
68
+ All code examples are self-contained and focus on core Python: variables, types, conditionals, loops, functions, lists, dictionaries, sets, file handling, exceptions, basic OOP, and comprehensions.
69
+
70
+ ## Usage
71
+
72
+ Load the dataset directly with the Hugging Face `datasets` library:
73
+
74
+ ```python
75
+ from datasets import load_dataset
76
+
77
+ dataset = load_dataset("inserloft/PyMini", split="train")
78
+ print(dataset[0])
79
+ ```
80
+
81
+ ### Loading from a local JSONL file
82
+
83
+ ```python
84
+ from datasets import load_dataset
85
+
86
+ dataset = load_dataset("json", data_files="PyMini.jsonl", split="train")
87
+ ```
88
+
89
+ ## Data Fields
90
+
91
+ - **instruction** (str): Task description in the chosen language.
92
+ - **input** (str): Optional code block (formatted with ` ```python ` fences) or empty string.
93
+ - **output** (str): Expected response (may contain code blocks, explanations, or short answers).
94
+
95
+ ## Data Splits
96
+
97
+ The default release includes a single training split. For evaluation, we recommend either:
98
+
99
+ - Holding out a random 5–10% of the data, or
100
+ - Using a separate, handcrafted test set of real-world Python problems.
101
+
102
+ ## Generation Process
103
+
104
+ PyMini is entirely synthetic, generated by a Python script that randomly combines templates and safe code evaluation to produce diverse examples. Key aspects of the generation:
105
+
106
+ - **Deduplication:** A hash-based deduplication step prevents exact duplicate examples.
107
+ - **Reproducibility:** The script uses a fixed random seed (42) for reproducible generation.
108
+ - **Safety:** All code snippets are evaluated in a restricted environment (no file system access, limited built-ins).
109
+ - **Customization:** Adjust the number of examples, language (`--lang es/en/both`), and task weights by modifying the script.
110
+
111
+ The generation script is included in the repository (`generate_pymini.py`).
112
+
113
+ ## Intended Use
114
+
115
+ This dataset is intended for fine-tuning small language models (under ~2 billion parameters) to improve their Python understanding and code generation abilities. It is particularly suitable for:
116
+
117
+ - Code assistants that must explain or fix Python code.
118
+ - Educational tools that teach Python basics.
119
+ - Lightweight models running in resource-constrained environments (edge, mobile).
120
+
121
+ ## Out-of-Scope Use
122
+
123
+ PyMini is not designed for:
124
+
125
+ - Large-scale production code generation.
126
+ - Mastering advanced Python libraries (NumPy, pandas, Django, etc.).
127
+ - Security-sensitive code auditing.
128
+
129
+ The examples are deliberately simple and may not cover edge cases of real-world software.
130
+
131
+ ## Bias, Risks, and Limitations
132
+
133
+ - **Synthetic nature:** The dataset was generated from templates, so it may lack the stylistic variance of human-written code.
134
+ - **Language coverage:** While bilingual, the vocabulary is limited to common Python terminology. Colloquial expressions or complex natural language instructions may be underrepresented.
135
+ - **No malicious code:** The dataset does not include security vulnerabilities or harmful patterns; it is purely educational.
136
+ - **Potential overfitting:** Because of the templated generation, models may memorize patterns rather than generalizing to unseen code. Evaluate on diverse, real-world test sets.
137
+
138
+ ## License
139
+
140
+ This dataset is released under the MIT License. You are free to use, modify, and distribute it for both research and commercial purposes.
141
+
142
+ ## Citation
143
+
144
+ If you use PyMini in your work, please cite it as:
145
+
146
+ ```bibtex
147
+ @misc{pymini2025,
148
+ title = {PyMini: A Compact Python Instruction Dataset for Small Language Models},
149
+ author = {Inserloft},
150
+ year = 2025,
151
+ howpublished = {\url{https://huggingface.co/datasets/inserloft/PyMini}}
152
+ }
153
+ ```
154
+
155
+ ## Contributing
156
+
157
+ Feel free to open issues or pull requests if you have suggestions for new task types, additional languages, or improvements to the generation script.
158
+
159
+ ## Contact
160
+
161
+ For questions, reach out via the Hugging Face community tab or through [Pixel](https://inserloft.com/contact/pixel).