Datasets:

Modalities:
Text
Formats:
parquet
Size:
< 1K
ArXiv:
Libraries:
Datasets
pandas
File size: 3,105 Bytes
b2d4397
27bb966
c5dda6e
b2d4397
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c5dda6e
 
b2d4397
 
c5dda6e
b2d4397
c5dda6e
 
b2d4397
 
 
 
 
 
7bd012c
 
 
 
 
20d2c2b
7bd012c
 
 
 
 
 
 
c1d718d
7bd012c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75cd224
 
7bd012c
 
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
---
source_datasets:
- zai-org/humaneval-x
dataset_info:
  features:
  - name: instance_id
    dtype: string
  - name: number_spans
    dtype: int64
  - name: prompt
    dtype: string
  - name: declaration
    dtype: string
  - name: splits
    sequence: string
  - name: removed_spans
    sequence: string
  - name: canonical_solution
    dtype: string
  - name: test
    dtype: string
  splits:
  - name: test
    num_bytes: 834118
    num_examples: 473
  download_size: 148031
  dataset_size: 834118
configs:
- config_name: default
  data_files:
  - split: test
    path: data/test-*
---

## HumanEval/MRI/C++

This is a multi-region infilling version of the [C++ translation of HumanEval](https://huggingface.co/datasets/zai-org/humaneval-x). It was generated by randomly removing between 1 and 3 spans from the canonical solution in the dataset.

This dataset was used for evaluation in the paper [Constrained Decoding of Diffusion LLMs with Context-Free Grammars](https://arxiv.org/abs/2508.10111). You can find the corresponding evaluation code on [the project GitHub Repository](https://github.com/eth-sri/constrained-diffusion).

### Example Usage

```python
from datasets import load_dataset
import json

dataset = load_dataset('eth-sri/HumanEval-MRI-Cpp')
for instance in dataset['test']:
    print(json.dumps(instance, indent=2))
    break
```

### Example Instance
```json
{
  "instance_id": "CPP/0_spans_1",
  "number_spans": 1,
  "prompt": "/*\nCheck if in given vector of numbers, are any two numbers closer to each other than\ngiven threshold.\n>>> has_close_elements({1.0, 2.0, 3.0}, 0.5)\nfalse\n>>> has_close_elements({1.0, 2.8, 3.0, 4.0, 5.0, 2.0}, 0.3)\ntrue\n*/\n#include<stdio.h>\n#include<vector>\n#include<math.h>\nusing namespace std;\nbool has_close_elements(vector<float> numbers, float threshold){\n",
  "declaration": "#include<stdio.h>\n#include<vector>\n#include<math.h>\nusing namespace std;\n#include<algorithm>\n#include<stdlib.h>\nbool has_close_elements(vector<float> numbers, float threshold){\n",
  "splits": [
    "    int i,j;\n    \n    for (i=0;i<numbers.size();i++)\n    for (j=i+1;j<numbers.size();j++)\n    if ",
    ";\n\n    return false;\n}\n\n"
  ],
  "removed_spans": [
    "(abs(numbers[i]-numbers[j])<threshold)\n    return true"
  ],
  "canonical_solution": "    int i,j;\n    \n    for (i=0;i<numbers.size();i++)\n    for (j=i+1;j<numbers.size();j++)\n    if (abs(numbers[i]-numbers[j])<threshold)\n    return true;\n\n    return false;\n}\n\n",
  "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n    vector<float> a={1.0, 2.0, 3.9, 4.0, 5.0, 2.2};\n    assert (has_close_elements(a, 0.3)==true);\n    assert (has_close_elements(a, 0.05) == false);\n\n    assert (has_close_elements({1.0, 2.0, 5.9, 4.0, 5.0}, 0.95) == true);\n    assert (has_close_elements({1.0, 2.0, 5.9, 4.0, 5.0}, 0.8) ==false);\n    assert (has_close_elements({1.0, 2.0, 3.0, 4.0, 5.0}, 2.0) == true);\n    assert (has_close_elements({1.1, 2.2, 3.1, 4.1, 5.1}, 1.0) == true);\n    assert (has_close_elements({1.1, 2.2, 3.1, 4.1, 5.1}, 0.5) == false);\n    \n}\n"
}
```