Update README.md
Browse files
README.md
CHANGED
|
@@ -65,5 +65,78 @@ with open(out_file, 'w') as f:
|
|
| 65 |
json.dump(data, f)
|
| 66 |
```
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
If you use Simple Math o train your model, please cite on the modelcard or the paper.
|
| 69 |
-
Thank you
|
|
|
|
| 65 |
json.dump(data, f)
|
| 66 |
```
|
| 67 |
|
| 68 |
+
We have also a new community submission for a more complex dataset of 3 elements:
|
| 69 |
+
```
|
| 70 |
+
mport random
|
| 71 |
+
import json
|
| 72 |
+
import operator
|
| 73 |
+
|
| 74 |
+
# Define the number of samples you want to generate
|
| 75 |
+
num_samples = 500000
|
| 76 |
+
# Define the range for the random numbers
|
| 77 |
+
min_value = -99.99
|
| 78 |
+
max_value = 99.99
|
| 79 |
+
# Define the arithmetic operations and their corresponding functions
|
| 80 |
+
operations = {
|
| 81 |
+
'+': operator.add,
|
| 82 |
+
'-': operator.sub,
|
| 83 |
+
'*': operator.mul,
|
| 84 |
+
'/': operator.truediv
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
def generate_random_number():
|
| 88 |
+
return float("%.3f" % random.uniform(min_value, max_value))
|
| 89 |
+
|
| 90 |
+
def safe_division(numerator, denominator):
|
| 91 |
+
return numerator if denominator == 0 else numerator / denominator
|
| 92 |
+
|
| 93 |
+
# Generate complex data
|
| 94 |
+
data = []
|
| 95 |
+
for _ in range(num_samples):
|
| 96 |
+
num1 = generate_random_number()
|
| 97 |
+
num2 = generate_random_number()
|
| 98 |
+
num3 = generate_random_number()
|
| 99 |
+
# Ensure num2 and num3 are not zero if they will be used as divisors
|
| 100 |
+
if num2 == 0.0:
|
| 101 |
+
num2 = generate_random_number()
|
| 102 |
+
if num3 == 0.0:
|
| 103 |
+
num3 = generate_random_number()
|
| 104 |
+
|
| 105 |
+
# Randomly choose two operations
|
| 106 |
+
operation1 = random.choice(list(operations.keys()))
|
| 107 |
+
operation2 = random.choice(list(operations.keys()))
|
| 108 |
+
|
| 109 |
+
# Create a more complex expression
|
| 110 |
+
if random.choice([True, False]):
|
| 111 |
+
# With parentheses
|
| 112 |
+
expression = f"({num1} {operation1} {num2}) {operation2} {num3}"
|
| 113 |
+
if operation1 == '/':
|
| 114 |
+
intermediate_result = safe_division(num1, num2)
|
| 115 |
+
else:
|
| 116 |
+
intermediate_result = operations[operation1](num1, num2)
|
| 117 |
+
if operation2 == '/' and intermediate_result != 0:
|
| 118 |
+
result = safe_division(intermediate_result, num3)
|
| 119 |
+
else:
|
| 120 |
+
result = operations[operation2](intermediate_result, num3)
|
| 121 |
+
else:
|
| 122 |
+
# Without parentheses
|
| 123 |
+
expression = f"{num1} {operation1} {num2} {operation2} {num3}"
|
| 124 |
+
if operation1 == '/':
|
| 125 |
+
intermediate_result = safe_division(num1, num2)
|
| 126 |
+
else:
|
| 127 |
+
intermediate_result = operations[operation1](num1, num2)
|
| 128 |
+
if operation2 == '/':
|
| 129 |
+
result = safe_division(intermediate_result, num3)
|
| 130 |
+
else:
|
| 131 |
+
result = operations[operation2](intermediate_result, num3)
|
| 132 |
+
|
| 133 |
+
output = "%.4f" % result
|
| 134 |
+
data.append({'instruction': expression, 'output': output})
|
| 135 |
+
|
| 136 |
+
# Create the dataset
|
| 137 |
+
out_file = 'arithmetic-float-complex.json'
|
| 138 |
+
with open(out_file, 'w') as f:
|
| 139 |
+
json.dump(data, f)
|
| 140 |
+
```
|
| 141 |
If you use Simple Math o train your model, please cite on the modelcard or the paper.
|
| 142 |
+
Thank you
|