Datasets:
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,55 +1,163 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
-
|
| 11 |
-
|
| 12 |
-
-
|
| 13 |
-
|
| 14 |
-
-
|
| 15 |
-
|
| 16 |
-
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
- name: has_type_hints
|
| 21 |
-
dtype: bool
|
| 22 |
-
- name: complexity
|
| 23 |
-
dtype: int32
|
| 24 |
-
- name: quality_score
|
| 25 |
-
dtype: float32
|
| 26 |
-
- name: repo_name
|
| 27 |
-
dtype: string
|
| 28 |
-
- name: repo_stars
|
| 29 |
-
dtype: int32
|
| 30 |
-
- name: docstring_style
|
| 31 |
-
dtype: string
|
| 32 |
-
- name: is_async
|
| 33 |
-
dtype: bool
|
| 34 |
-
splits:
|
| 35 |
-
- name: train
|
| 36 |
-
num_bytes: 14568245
|
| 37 |
-
num_examples: 10684
|
| 38 |
-
- name: val
|
| 39 |
-
num_bytes: 1852301
|
| 40 |
-
num_examples: 1334
|
| 41 |
-
- name: test
|
| 42 |
-
num_bytes: 1867302
|
| 43 |
-
num_examples: 1340
|
| 44 |
-
download_size: 8227994
|
| 45 |
-
dataset_size: 18287848
|
| 46 |
-
configs:
|
| 47 |
-
- config_name: default
|
| 48 |
-
data_files:
|
| 49 |
-
- split: train
|
| 50 |
-
path: data/train-*
|
| 51 |
-
- split: val
|
| 52 |
-
path: data/val-*
|
| 53 |
-
- split: test
|
| 54 |
-
path: data/test-*
|
| 55 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: mit
|
| 3 |
+
task_categories:
|
| 4 |
+
- text-generation
|
| 5 |
+
- text2text-generation
|
| 6 |
+
language:
|
| 7 |
+
- code
|
| 8 |
+
tags:
|
| 9 |
+
- code
|
| 10 |
+
- documentation
|
| 11 |
+
- docstring
|
| 12 |
+
- code-to-text
|
| 13 |
+
- python
|
| 14 |
+
- java
|
| 15 |
+
- javascript
|
| 16 |
+
- typescript
|
| 17 |
+
- cpp
|
| 18 |
+
size_categories:
|
| 19 |
+
- 10K<n<100K
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
---
|
| 21 |
+
|
| 22 |
+
# Code2Doc: Function-Documentation Pairs Dataset
|
| 23 |
+
|
| 24 |
+
A curated dataset of **13,358** high-quality function-documentation pairs extracted from popular open-source repositories on GitHub. Designed for training models to generate documentation from code.
|
| 25 |
+
|
| 26 |
+
## Dataset Description
|
| 27 |
+
|
| 28 |
+
This dataset contains functions paired with their docstrings/documentation comments from 5 programming languages, extracted from well-maintained, highly-starred GitHub repositories.
|
| 29 |
+
|
| 30 |
+
### Languages Distribution
|
| 31 |
+
|
| 32 |
+
| Language | Train | Val | Test | Total |
|
| 33 |
+
|----------|-------|-----|------|-------|
|
| 34 |
+
| Java | 6,560 (61.4%) | 820 | 820 | 8,200 |
|
| 35 |
+
| Python | 2,885 (27.0%) | 360 | 362 | 3,607 |
|
| 36 |
+
| TypeScript | 681 (6.4%) | 85 | 86 | 852 |
|
| 37 |
+
| JavaScript | 428 (4.0%) | 53 | 55 | 536 |
|
| 38 |
+
| C++ | 130 (1.2%) | 16 | 17 | 163 |
|
| 39 |
+
| **Total** | **10,684** | **1,334** | **1,340** | **13,358** |
|
| 40 |
+
|
| 41 |
+
### Source Repositories
|
| 42 |
+
|
| 43 |
+
The data was extracted from high-quality open-source projects including:
|
| 44 |
+
|
| 45 |
+
**Python:** Django, PyTorch, Pandas, NumPy, scikit-learn, FastAPI, Flask, Celery, Airflow, Requests
|
| 46 |
+
|
| 47 |
+
**Java:** Guava, Elasticsearch, Spring Framework, Spring Boot, Apache Kafka, Commons-Lang
|
| 48 |
+
|
| 49 |
+
**TypeScript:** TypeScript, VS Code, Angular, Prisma, Grafana, Storybook, NestJS
|
| 50 |
+
|
| 51 |
+
**JavaScript:** React, Node.js, Lodash, Axios, Express
|
| 52 |
+
|
| 53 |
+
**C++:** OpenCV, Protobuf, Folly, gRPC, LLVM, TensorFlow
|
| 54 |
+
|
| 55 |
+
## Dataset Structure
|
| 56 |
+
|
| 57 |
+
### Data Fields
|
| 58 |
+
|
| 59 |
+
| Field | Type | Description |
|
| 60 |
+
|-------|------|-------------|
|
| 61 |
+
| `function_name` | string | Name of the function/method |
|
| 62 |
+
| `function_code` | string | Complete source code of the function |
|
| 63 |
+
| `documentation` | string | Extracted docstring/documentation |
|
| 64 |
+
| `language` | string | Programming language |
|
| 65 |
+
| `file_path` | string | Original file path in repository |
|
| 66 |
+
| `line_number` | int | Line number where function starts |
|
| 67 |
+
| `parameters` | list[string] | List of parameter names |
|
| 68 |
+
| `return_type` | string | Return type annotation (if available) |
|
| 69 |
+
| `has_type_hints` | bool | Whether function has type annotations |
|
| 70 |
+
| `complexity` | int | Cyclomatic complexity score |
|
| 71 |
+
| `quality_score` | float | Documentation quality score (0-10) |
|
| 72 |
+
| `repo_name` | string | Source repository (owner/repo) |
|
| 73 |
+
| `repo_stars` | int | Repository star count at extraction time |
|
| 74 |
+
| `docstring_style` | string | Documentation style (google, numpy, sphinx, jsdoc, javadoc, doxygen) |
|
| 75 |
+
| `is_async` | bool | Whether function is async |
|
| 76 |
+
|
| 77 |
+
### Data Splits
|
| 78 |
+
|
| 79 |
+
- **Train:** 10,684 samples (80%)
|
| 80 |
+
- **Validation:** 1,334 samples (10%)
|
| 81 |
+
- **Test:** 1,340 samples (10%)
|
| 82 |
+
|
| 83 |
+
Splits are stratified by language to maintain consistent distribution across sets.
|
| 84 |
+
|
| 85 |
+
## Data Processing Pipeline
|
| 86 |
+
|
| 87 |
+
The dataset was created through a multi-stage pipeline:
|
| 88 |
+
|
| 89 |
+
1. **Extraction:** Used tree-sitter parsers to accurately extract functions with documentation
|
| 90 |
+
2. **Basic Filtering:** Removed test functions, trivial functions, and applied length constraints
|
| 91 |
+
3. **Quality Scoring:** Scored documentation completeness (parameters, returns, examples)
|
| 92 |
+
4. **Deduplication:** Removed exact and near-duplicates using MinHash LSH
|
| 93 |
+
5. **AI Detection:** Filtered potentially AI-generated documentation
|
| 94 |
+
|
| 95 |
+
### Quality Criteria
|
| 96 |
+
|
| 97 |
+
- Minimum documentation length: 20 characters
|
| 98 |
+
- Maximum documentation length: 10,000 characters
|
| 99 |
+
- Minimum code length: 50 characters
|
| 100 |
+
- Excluded test functions and trivial getters/setters
|
| 101 |
+
- Required meaningful documentation structure
|
| 102 |
+
|
| 103 |
+
## Usage
|
| 104 |
+
|
| 105 |
+
```python
|
| 106 |
+
from datasets import load_dataset
|
| 107 |
+
|
| 108 |
+
dataset = load_dataset("kaanrkaraman/code2doc")
|
| 109 |
+
|
| 110 |
+
# Access splits
|
| 111 |
+
train_data = dataset["train"]
|
| 112 |
+
val_data = dataset["val"]
|
| 113 |
+
test_data = dataset["test"]
|
| 114 |
+
|
| 115 |
+
# Example: Get a Python function
|
| 116 |
+
python_samples = train_data.filter(lambda x: x["language"] == "python")
|
| 117 |
+
sample = python_samples[0]
|
| 118 |
+
|
| 119 |
+
print(f"Function: {sample['function_name']}")
|
| 120 |
+
print(f"Code:\n{sample['function_code']}")
|
| 121 |
+
print(f"Documentation:\n{sample['documentation']}")
|
| 122 |
+
```
|
| 123 |
+
|
| 124 |
+
### For Fine-tuning
|
| 125 |
+
|
| 126 |
+
```python
|
| 127 |
+
def format_for_training(example):
|
| 128 |
+
return {
|
| 129 |
+
"input": f"Generate documentation for the following {example['language']} function:\n\n{example['function_code']}",
|
| 130 |
+
"output": example["documentation"]
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
formatted_dataset = dataset.map(format_for_training)
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
## Intended Use
|
| 137 |
+
|
| 138 |
+
- **Training code documentation generation models**
|
| 139 |
+
- **Fine-tuning LLMs for code-to-text tasks**
|
| 140 |
+
- **Evaluating documentation quality metrics**
|
| 141 |
+
- **Research on code understanding and generation**
|
| 142 |
+
|
| 143 |
+
## Limitations
|
| 144 |
+
|
| 145 |
+
- Heavily weighted towards Java due to verbose documentation practices
|
| 146 |
+
- C++ representation is small due to different documentation conventions
|
| 147 |
+
- Documentation quality varies by repository coding standards
|
| 148 |
+
- Extracted from a specific snapshot in time (December 2024)
|
| 149 |
+
|
| 150 |
+
## Citation
|
| 151 |
+
|
| 152 |
+
```bibtex
|
| 153 |
+
@dataset{code2doc2024,
|
| 154 |
+
title={Code2Doc: Function-Documentation Pairs Dataset},
|
| 155 |
+
author={Kaan R. Karaman},
|
| 156 |
+
year={2024},
|
| 157 |
+
url={https://huggingface.co/datasets/kaanrkaraman/code2doc}
|
| 158 |
+
}
|
| 159 |
+
```
|
| 160 |
+
|
| 161 |
+
## License
|
| 162 |
+
|
| 163 |
+
This dataset is released under the MIT License. The source code comes from repositories with permissive licenses (MIT, Apache 2.0, BSD).
|