Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,34 +1,91 @@
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# Arithmetic Puzzles Dataset
|
| 3 |
+
|
| 4 |
+
A collection of arithmetic puzzles with heavy use of variable assignment. Current LLMs struggle with variable indirection/multi-hop reasoning, this should be a tough test for them.
|
| 5 |
+
|
| 6 |
+
Inputs are a list of strings representing variable assignments (`c=a+b`), and the output is the integer answer.
|
| 7 |
+
|
| 8 |
+
Outputs are filtered to be between [-100, 100], and self-reference/looped dependencies are forbidden.
|
| 9 |
+
|
| 10 |
+
Splits include:
|
| 11 |
+
|
| 12 |
+
- `train_small/test_small` which includes 10k total examples of puzzles with up to 10 variables.
|
| 13 |
+
- `train_large/test_large` which includes 10k total examples of puzzles with up to 100 variables.
|
| 14 |
+
|
| 15 |
+
Conceptually the data looks like this:
|
| 16 |
+
|
| 17 |
+
```python
|
| 18 |
+
Input:
|
| 19 |
+
|
| 20 |
+
a=1
|
| 21 |
+
b=2
|
| 22 |
+
c=a+b
|
| 23 |
+
solve(c)=
|
| 24 |
+
|
| 25 |
+
Output:
|
| 26 |
+
3
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
In actuality it looks like this:
|
| 30 |
+
|
| 31 |
+
```python
|
| 32 |
+
{
|
| 33 |
+
"input": ['var_0=1', 'var_1=2', 'var_2=a+b', 'solve(var_2)='],
|
| 34 |
+
"output": 3
|
| 35 |
+
}
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
### Loading the Dataset
|
| 40 |
+
|
| 41 |
+
```python
|
| 42 |
+
from datasets import load_dataset
|
| 43 |
+
|
| 44 |
+
# Load the entire dataset
|
| 45 |
+
dataset = load_dataset("neurallambda/arithmetic_puzzles")
|
| 46 |
+
|
| 47 |
+
# Load specific splits
|
| 48 |
+
train_small = load_dataset("neurallambda/arithmetic_puzzles", split="train_small")
|
| 49 |
+
test_small = load_dataset("neurallambda/arithmetic_puzzles", split="test_small")
|
| 50 |
+
train_large = load_dataset("neurallambda/arithmetic_puzzles", split="train_large")
|
| 51 |
+
test_large = load_dataset("neurallambda/arithmetic_puzzles", split="test_large")
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
### Preparing Inputs
|
| 55 |
+
|
| 56 |
+
To prepare the inputs as concatenated strings, you can do this:
|
| 57 |
+
|
| 58 |
+
```python
|
| 59 |
+
def prepare_input(example):
|
| 60 |
+
return {
|
| 61 |
+
"input_text": "
|
| 62 |
+
".join(example["input"]),
|
| 63 |
+
"output": example["output"]
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
# Apply the preparation to a specific split
|
| 67 |
+
train_small_prepared = train_small.map(prepare_input)
|
| 68 |
+
|
| 69 |
+
# Example of using the prepared dataset
|
| 70 |
+
for example in train_small_prepared.select(range(5)): # Show first 5 examples
|
| 71 |
+
print("Input:", example["input_text"])
|
| 72 |
+
print("Output:", example["output"])
|
| 73 |
+
print()
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
This will produce output similar to:
|
| 77 |
+
|
| 78 |
+
```
|
| 79 |
+
Input: var_0=5
|
| 80 |
+
var_1=2
|
| 81 |
+
var_2=-2 + -8
|
| 82 |
+
var_3=3
|
| 83 |
+
var_4=4
|
| 84 |
+
var_5=var_2
|
| 85 |
+
var_6=var_3 * 10
|
| 86 |
+
var_7=var_2 - var_0
|
| 87 |
+
var_8=var_1
|
| 88 |
+
var_9=-2 - 9
|
| 89 |
+
solve(var_3)=
|
| 90 |
+
Output: 3
|
| 91 |
+
```
|