File size: 2,398 Bytes
ecf4588
 
 
 
 
 
 
 
 
 
 
 
 
934736a
 
 
 
ecf4588
 
 
 
 
271ceae
 
 
 
 
 
 
 
 
1c0ab39
ecf4588
271ceae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f4bf16f
271ceae
ce28e5d
271ceae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
dataset_info:
  features:
  - name: instruction
    dtype: string
  - name: code
    dtype: string
  - name: response
    dtype: string
  - name: file
    dtype: string
  splits:
  - name: train
    num_bytes: 247832934
    num_examples: 16440
  download_size: 86431840
  dataset_size: 247832934
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*
license: mit
task_categories:
- text-generation
language:
- en
tags:
- code
pretty_name: python docstring dataset
size_categories:
- 10K<n<100K
---
# Python Docstring Diff Dataset

This dataset contains training samples for models that generate Python documentation patches.
Each example provides a Python source file with its docstrings removed and a corresponding unified diff patch that restores the documentation.

The dataset is designed for training or evaluating language models that assist with:

* Automatic code documentation
* Docstring generation
* Code review automation
* Developer tooling
* Dataset Structure

Each entry contains the following fields:

Field	Description
-------------------
instruction|	Task instruction given to the model
code|	Python source code with docstrings removed
response|	A unified diff patch that adds the correct docstrings
file|	Original file path from the source project

## Task Format

The model receives a Python file missing its documentation and must produce a unified diff that adds appropriate docstrings.

Example input:

```python
def load_json(path):
    with open(path) as f:
        return json.load(f)
```

Example expected output:
```diff
--- a/file.py
+++ b/file.py
@@
 def load_json(path):
+    """Load JSON data from a file path."""
     with open(path) as f:
         return json.load(f)
```

## Data Sources

The dataset was generated by scanning Python packages in github.
Docstrings were extracted from functions, classes, async functions, methods, and modules using Python's AST parser.
Low-quality documentation was filtered out using heuristics such as:

* Minimum docstring length
* Removal of TODO or placeholder documentation
* Deduplication of similar examples

## Intended Use

This dataset is useful for training models that perform:

* automatic docstring generation
* documentation patch creation
* codebase documentation improvement tools
* AI-assisted code review systems

## License

This dataset is released under the MIT License.