Update README.md
Browse files
README.md
CHANGED
|
@@ -278,4 +278,58 @@ This is a dataset built from [CommitPackFT](https://huggingface.co/datasets/bigc
|
|
| 278 |
- Scala
|
| 279 |
- Bash
|
| 280 |
|
| 281 |
-
The goal of this dataset is to evaluate the ability of models to retrieve a diff given it's instruction.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
- Scala
|
| 279 |
- Bash
|
| 280 |
|
| 281 |
+
The goal of this dataset is to evaluate the ability of models to retrieve a diff given it's instruction.
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
### Code To Produce Dataset
|
| 285 |
+
Below is the code to reproduce this dataset:
|
| 286 |
+
```py
|
| 287 |
+
import datasets
|
| 288 |
+
from tqdm import tqdm
|
| 289 |
+
import difflib
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
outrepo = "cassanof/CodeEditSearch"
|
| 293 |
+
LANGS = ["python", "javascript", "go", "ruby", "java", "php", "c", "c++", "rust", "swift",
|
| 294 |
+
"typescript", "scala", "kotlin", "r", "perl", "haskell", "lua", "shell", "dart", "julia"]
|
| 295 |
+
|
| 296 |
+
processed = []
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
def get_udiff(a, b):
|
| 300 |
+
a = a.splitlines()
|
| 301 |
+
b = b.splitlines()
|
| 302 |
+
diff = difflib.unified_diff(a, b, lineterm="")
|
| 303 |
+
return "\n".join(diff)
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
for lang in tqdm(LANGS):
|
| 307 |
+
print(f"Processing {lang}")
|
| 308 |
+
ds = datasets.load_dataset("bigcode/commitpackft", lang, split="train")
|
| 309 |
+
ds = ds.shuffle(seed=42)
|
| 310 |
+
print(f"{lang}: {len(ds)}")
|
| 311 |
+
ds = ds.filter(lambda x: len(
|
| 312 |
+
x["new_contents"] + x["old_contents"]) < 2500, num_proc=8)
|
| 313 |
+
ds = ds.filter(lambda x: len(x["new_contents"].strip()) > 0 and len(
|
| 314 |
+
x["old_contents"].strip()) > 0, num_proc=8)
|
| 315 |
+
if len(ds) < 2000:
|
| 316 |
+
print(f"Skipping {lang} due to insufficient data")
|
| 317 |
+
continue
|
| 318 |
+
print(f"{lang} after: {len(ds)}")
|
| 319 |
+
ds = ds.select(range(2000))
|
| 320 |
+
diffs = [get_udiff(a, b)
|
| 321 |
+
for a, b in zip(ds["old_contents"], ds["new_contents"])]
|
| 322 |
+
ds = {
|
| 323 |
+
"after": ds["new_contents"],
|
| 324 |
+
"before": ds["old_contents"],
|
| 325 |
+
"diff": diffs,
|
| 326 |
+
"instruction": ds["message"],
|
| 327 |
+
}
|
| 328 |
+
ds = datasets.Dataset.from_dict(ds)
|
| 329 |
+
ds = ds.filter(lambda x: len(x["diff"].splitlines()) > 10, num_proc=8)
|
| 330 |
+
print(f" ******* Final {lang}: {len(ds)} *******")
|
| 331 |
+
ds.push_to_hub(outrepo, lang)
|
| 332 |
+
processed.append(lang)
|
| 333 |
+
|
| 334 |
+
print(processed)
|
| 335 |
+
```
|