Dataset Viewer
The dataset viewer is not available for this dataset.
Unexpected token '<', "<html>
<h"... is not valid JSON
Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
This is a dataset built from CommitPackFT, providing ~1500 commits with diffs for several programming languages:
- Python
- JavaScript
- TypeScript
- Go
- Ruby
- Java
- PHP
- C
- C++
- Rust
- Swift
- Scala
- Bash
The goal of this dataset is to evaluate the ability of models to retrieve a diff given its instruction.
Code To Produce Dataset
Below is the code to reproduce this dataset:
import datasets
from tqdm import tqdm
import difflib
outrepo = "cassanof/CodeEditSearch"
LANGS = ["python", "javascript", "go", "ruby", "java", "php", "c", "c++", "rust", "swift",
"typescript", "scala", "kotlin", "r", "perl", "haskell", "lua", "shell", "dart", "julia"]
processed = []
def get_udiff(a, b):
a = a.splitlines()
b = b.splitlines()
diff = difflib.unified_diff(a, b, lineterm="")
return "\n".join(diff)
for lang in tqdm(LANGS):
print(f"Processing {lang}")
ds = datasets.load_dataset("bigcode/commitpackft", lang, split="train")
ds = ds.shuffle(seed=42)
print(f"{lang}: {len(ds)}")
ds = ds.filter(lambda x: len(
x["new_contents"] + x["old_contents"]) < 2500, num_proc=8)
ds = ds.filter(lambda x: len(x["new_contents"].strip()) > 0 and len(
x["old_contents"].strip()) > 0, num_proc=8)
if len(ds) < 2000:
print(f"Skipping {lang} due to insufficient data")
continue
print(f"{lang} after: {len(ds)}")
ds = ds.select(range(2000))
diffs = [get_udiff(a, b)
for a, b in zip(ds["old_contents"], ds["new_contents"])]
ds = {
"after": ds["new_contents"],
"before": ds["old_contents"],
"diff": diffs,
"instruction": ds["message"],
"license": ds["license"],
"repos": ds["repos"],
"commit": ds["commit"],
}
ds = datasets.Dataset.from_dict(ds)
ds = ds.filter(lambda x: len(x["diff"].splitlines()) > 10, num_proc=8)
print(f" ******* Final {lang}: {len(ds)} *******")
ds.push_to_hub(outrepo, lang)
processed.append(lang)
print(processed)
- Downloads last month
- 5,171