ronantakizawa commited on
Commit
61e408e
·
verified ·
1 Parent(s): 694d155

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +139 -0
README.md ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ task_categories:
4
+ - text-generation
5
+ - text2text-generation
6
+ language:
7
+ - en
8
+ - code
9
+ tags:
10
+ - code-review
11
+ - code-generation
12
+ - software-engineering
13
+ - pull-requests
14
+ - github
15
+ size_categories:
16
+ - 100K<n<1M
17
+ ---
18
+
19
+ # Code Review Diffs
20
+
21
+ A large-scale dataset of **(before_code, reviewer_comment, after_code)** triplets extracted from merged pull requests on top GitHub repositories.
22
+
23
+ ## Dataset Description
24
+
25
+ Each row captures a moment where a human code reviewer left an inline comment on a pull request, and the author subsequently modified the code in response. This provides a natural signal for training models to:
26
+
27
+ - **Generate code review comments** given a code diff
28
+ - **Apply review feedback** by modifying code based on reviewer suggestions
29
+ - **Understand code quality patterns** across languages and projects
30
+
31
+ ### Key Features
32
+
33
+ - **500K+ triplets** from 10,000+ top GitHub repositories
34
+ - **10+ programming languages** (Python, JavaScript, TypeScript, Java, Go, Rust, C++, C#, Ruby, PHP, and more)
35
+ - **Quality-filtered**: bot comments, noise ("LGTM", "+1"), and auto-generated content removed
36
+ - **Chunk-focused**: ~50 lines of context around the reviewed code, not entire files
37
+ - **Permissive licenses only**: all source repos use MIT, Apache-2.0, BSD, or similar licenses
38
+ - **Verified changes**: only includes triplets where the code chunk actually changed after the review
39
+
40
+ ## Schema
41
+
42
+ | Column | Type | Description |
43
+ |--------|------|-------------|
44
+ | `before_chunk` | string | ~50 lines of code around the comment, before the fix |
45
+ | `reviewer_comment` | string | The inline review comment text |
46
+ | `after_chunk` | string | ~50 lines of code around the comment, after the fix |
47
+ | `diff_hunk` | string | The PR diff hunk where the comment was placed |
48
+ | `file_path` | string | File path within the repo |
49
+ | `comment_line` | int | Line number where the comment was placed |
50
+ | `language` | string | Programming language |
51
+ | `quality_score` | float | Comment quality score (0.0-1.0) |
52
+ | `comment_length` | int | Character count of reviewer comment |
53
+ | `before_line_count` | int | Lines in before chunk |
54
+ | `after_line_count` | int | Lines in after chunk |
55
+ | `pr_title` | string | Pull request title |
56
+ | `pr_number` | int | PR number |
57
+ | `repo_name` | string | Full repo name (owner/repo) |
58
+ | `repo_stars` | int | GitHub stars |
59
+ | `repo_language` | string | Primary repo language |
60
+ | `reviewer_username` | string | Reviewer's GitHub username |
61
+ | `author_username` | string | PR author's GitHub username |
62
+
63
+ ## Usage
64
+
65
+ ```python
66
+ from datasets import load_dataset
67
+
68
+ ds = load_dataset("ronantakizawa/code-review-diffs")
69
+
70
+ # Get a training example
71
+ example = ds["train"][0]
72
+ print(f"Review comment: {example['reviewer_comment']}")
73
+ print(f"Language: {example['language']}")
74
+ print(f"Before:\n{example['before_chunk'][:200]}")
75
+ print(f"After:\n{example['after_chunk'][:200]}")
76
+ ```
77
+
78
+ ### Filter by language
79
+
80
+ ```python
81
+ python_reviews = ds["train"].filter(lambda x: x["language"] == "Python")
82
+ ```
83
+
84
+ ### Filter by quality
85
+
86
+ ```python
87
+ high_quality = ds["train"].filter(lambda x: x["quality_score"] >= 0.3)
88
+ ```
89
+
90
+ ## Collection Methodology
91
+
92
+ 1. **Repo selection**: Top 10,000 GitHub repos by stars with permissive licenses from [ronantakizawa/github-top-projects](https://huggingface.co/datasets/ronantakizawa/github-top-projects)
93
+ 2. **PR discovery**: Paginate merged PRs, filter bot authors, fetch inline review comments
94
+ 3. **Comment filtering**: Remove bots, noise patterns, auto-generated comments, non-English text, non-code files, reply comments
95
+ 4. **Triplet extraction**: Fetch file contents at the review commit (before) and PR head (after), extract focused chunks around the comment line
96
+ 5. **Change verification**: Only keep triplets where the code chunk around the comment actually changed
97
+
98
+ ### Quality Filters Applied
99
+
100
+ - Bot authors excluded (dependabot, renovate, codecov, etc.)
101
+ - Comments < 30 characters excluded
102
+ - Noise patterns excluded (LGTM, +1, emoji-only, etc.)
103
+ - Auto-generated comments excluded (coverage reports, CI output)
104
+ - Non-English comments excluded (ASCII ratio < 70%)
105
+ - Non-source-code files excluded
106
+ - Reply comments excluded (only top-level review comments)
107
+ - Files > 512 KB excluded
108
+ - PRs with < 10 or > 500 changed lines excluded
109
+
110
+ ## Splits
111
+
112
+ | Split | Percentage | Description |
113
+ |-------|-----------|-------------|
114
+ | train | 90% | Training data |
115
+ | test | 5% | Test data |
116
+ | validation | 5% | Validation data |
117
+
118
+ Splits are deterministic by repository — all triplets from the same repo appear in the same split.
119
+
120
+ ## Limitations
121
+
122
+ - Review comments may address style/formatting rather than substantive logic changes
123
+ - The "after" code may include changes unrelated to the specific review comment
124
+ - Line number alignment may be imprecise when multiple commits occur between review and merge
125
+ - Some `original_commit_id` SHAs may be unavailable due to force-pushes; in these cases, the PR merge base is used as the "before" state
126
+
127
+ ## Citation
128
+
129
+ If you use this dataset, please cite:
130
+
131
+ ```bibtex
132
+ @dataset{takizawa2026codereviewdiffs,
133
+ title={Code Review Diffs: A Large-Scale Dataset of Review-Driven Code Changes},
134
+ author={Takizawa, Ronan},
135
+ year={2026},
136
+ publisher={Hugging Face},
137
+ url={https://huggingface.co/datasets/ronantakizawa/code-review-diffs}
138
+ }
139
+ ```