Skip to content

Commit 2395732

Browse files
Merge pull request #98 from LogicNet-Subnet/pre-release
Pre release to main
2 parents ef1ac99 + 9c1f1ca commit 2395732

File tree

7 files changed

+32
-70
lines changed

7 files changed

+32
-70
lines changed

logicnet/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from . import miner
66
from . import utils
77

8-
__version__ = "1.5.4"
8+
__version__ = "1.5.5"
99
version_split = __version__.split(".")
1010
__spec_version__ = (
1111
(1000 * int(version_split[0]))

logicnet/utils/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ def add_args(cls, parser):
151151
"--proxy.proxy_client_url",
152152
type=str,
153153
help="The url initialize credentials for proxy.",
154-
default="https://logicnet.aitprotocol.ai/proxy_client",
154+
default="https://proxy-client.logicnet.ai/",
155155
)
156156

157157
parser.add_argument(
158158
"--storage.storage_url",
159159
type=str,
160160
help="The url initialize to store miner's information.",
161-
default="https://logicnet.aitprotocol.ai/proxy_client/store_miner_information",
161+
default="https://proxy-client.logicnet.ai/store_miner_information",
162162
)
163163

164164
parser.add_argument(

logicnet/validator/challenger/challenger.py

Lines changed: 14 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -55,63 +55,23 @@ def get_atom_logic_problem(self) -> Tuple[str, str]:
5555
Returns:
5656
(atom_logic_question, atom_logic_answer) as a tuple of strings.
5757
"""
58-
resources = ['mathgenerator', 'gsm8k', 'mmlustem']
59-
60-
if len(self.dataset_weight) == 3:
61-
selected_resource = random.choices(resources, weights=self.dataset_weight, k=1)[0]
62-
else:
63-
bt.logging.warning("Invalid dataset weight configuration provided. Using default weights.")
64-
selected_resource = random.choices(resources, weights=DATASET_WEIGHT, k=1)[0]
65-
66-
bt.logging.debug(f"Selected resource: {selected_resource}")
6758
try:
6859
# Select an atom question and answer from the Mathgenerator
69-
if selected_resource == 'mathgenerator':
70-
selected_topic = random.choice(topics)
71-
subtopic = selected_topic["subtopic"]
72-
topic = selected_topic["topic"]
73-
atom_question, atom_answer = eval(f"mathgenerator.{topic}.{subtopic}()")
74-
if atom_question is None or atom_answer is None:
75-
raise ValueError("Failed to get atom logic problem")
76-
bt.logging.debug("Generating math problem using Mathgenerator.")
77-
subtopic = subtopic.replace("_", " ").capitalize()
78-
topic = topic.replace("_", " ").capitalize()
79-
atom_question = atom_question.replace("$", "").strip()
80-
atom_question = (
81-
f"Find the solution of this math problem:\n---\n"
82-
f"Topic: {topic}, Subtopic: {subtopic}.\n{atom_question}\n---\n"
83-
)
84-
85-
# Select an atom question and answer from the GSM8K
86-
elif selected_resource == 'gsm8k':
87-
ds = load_dataset("openai/gsm8k", "main")
88-
bt.logging.debug("Generating problem using GSM8K dataset.")
89-
data_set = ds['train']
90-
bt.logging.info(f"Loaded GSM8K dataset with {len(data_set['question'])} entries")
91-
random_index = random.randint(0, len(data_set['question']) - 1)
92-
question = data_set['question'][random_index]
93-
answer = data_set['answer'][random_index]
94-
if "####" in answer:
95-
answer = answer.split("####")[1]
96-
atom_question = f"Find the solution of this question:\n---\n{question}\n---\n"
97-
atom_answer = answer
98-
99-
# Select an atom question and answer from the MMLU-STEM
100-
else:
101-
ds = load_dataset("TIGER-Lab/MMLU-STEM")
102-
bt.logging.debug("Generating problem using MMLU-STEM dataset.")
103-
data_set = ds['test']
104-
data_set = data_set.filter(lambda x: "Statement" not in x['question'])
105-
bt.logging.info(f"Loaded MMLU-STEM dataset with {len(data_set['question'])} entries")
106-
random_index = random.randint(0, len(data_set['question']) - 1)
107-
question = data_set['question'][random_index]
108-
answer_id = data_set['answer'][random_index]
109-
answer_choice = data_set['choices'][random_index]
110-
atom_question = f"Find the solution of this question:\n---\n{question}\n---\n"
111-
atom_answer = answer_choice[answer_id]
112-
60+
selected_topic = random.choice(topics)
61+
subtopic = selected_topic["subtopic"]
62+
topic = selected_topic["topic"]
63+
atom_question, atom_answer = eval(f"mathgenerator.{topic}.{subtopic}()")
64+
if atom_question is None or atom_answer is None:
65+
raise ValueError("Failed to get atom logic problem")
66+
bt.logging.debug("Generating math problem using Mathgenerator.")
67+
subtopic = subtopic.replace("_", " ").capitalize()
68+
topic = topic.replace("_", " ").capitalize()
69+
atom_question = atom_question.replace("$", "").strip()
70+
atom_question = (
71+
f"Find the solution of this math problem:\n---\n"
72+
f"Topic: {topic}, Subtopic: {subtopic}.\n{atom_question}\n---\n"
73+
)
11374
except Exception as e:
114-
bt.logging.error(f"Error accessing dataset {selected_resource}: {e}. Attempting to load an alternative dataset.")
11575
self.retry_count += 1
11676
if self.retry_count > 3:
11777
bt.logging.error("Max retries reached. Returning a default question and answer.")

logicnet/validator/challenger/math_generator/topics.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
("trig_differentiation", "calculus"),
7373
("definite_integral", "calculus"),
7474
("is_prime", "basic_math"),
75-
("bcd_to_decimal", "computer_science"),
7675
("complex_to_polar", "misc"),
7776
("set_operation", "misc"),
7877
("base_conversion", "misc"),
@@ -84,13 +83,11 @@
8483
("complex_quadratic", "algebra"),
8584
("is_leap_year", "misc"),
8685
("minutes_to_hours", "misc"),
87-
("decimal_to_bcd", "computer_science"),
8886
("circumference", "geometry"),
8987
("combine_like_terms", "algebra"),
9088
("signum_function", "misc"),
9189
("conditional_probability", "statistics"),
9290
("arc_length", "geometry"),
93-
# ("binomial_distribution", "misc"),
9491
("stationary_points", "calculus"),
9592
("expanding", "algebra"),
9693
("area_of_circle", "geometry"),

logicnet/validator/rewarder.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def __call__(self, uids, responses: list[LogicSynapse], base_synapse: LogicSynap
3838
"""
3939
# Get the unique task UID from the base_synapse
4040
task_uid = base_synapse.task_uid
41-
4241
valid_uids = [
4342
uid for uid, response in zip(uids, responses) if response.is_success
4443
]
@@ -311,7 +310,7 @@ def _get_correctness_by_llm(self, question: str, ground_truth: str, response: st
311310
def _compare_numerical_answers(self, ground_truth: str, miner_answer: str):
312311
try:
313312
# Remove formatting characters from the answers
314-
formatting_chars = ['$', '$$', '\\[', '\\]', '%']
313+
formatting_chars = ['$', '$$', '\\[', '\\]', '%', 'm^2', 'm^3']
315314
for char in formatting_chars:
316315
ground_truth = ground_truth.replace(char, '')
317316
miner_answer = miner_answer.replace(char, '')
@@ -323,19 +322,26 @@ def _compare_numerical_answers(self, ground_truth: str, miner_answer: str):
323322
if len(gt_values) == 0:
324323
return None
325324

326-
if len(gt_values) > 0 and len(miner_values) == 0:
327-
return 0.0
325+
gt_value = None
326+
miner_value = None
328327

329328
if len(gt_values) == 1 and len(miner_values) == 1:
330329
# Single numerical value found in both answers
331330
gt_value = gt_values[0]
332331
miner_value = miner_values[0]
332+
else:
333+
try:
334+
if "**" not in ground_truth and "**" not in miner_answer and "^" not in ground_truth and "^" not in miner_answer:
335+
gt_value = sympy.sympify(ground_truth.strip())
336+
miner_value = sympy.sympify(miner_answer.strip())
337+
except Exception as e:
338+
return None
339+
340+
if gt_value is not None and miner_value is not None:
333341
abs_difference = abs(gt_value - miner_value)
334342
epsilon = 1e-8
335343
gt_abs = abs(gt_value) + epsilon
336344
relative_error = abs_difference / gt_abs
337-
# Logs for debugging
338-
bt.logging.info(f"[CORRECTNESS DEBUG FOR NUMERICAL COMPARISON]: Absolute difference: {abs_difference}, Relative error: {relative_error}")
339345
correctness_score = max(0.0, 1.0 - relative_error)
340346
correctness_score = min(correctness_score, 1.0)
341347
return correctness_score

neurons/validator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "1.5.4"
1+
__version__ = "1.5.5"
22
version_split = __version__.split(".")
33
__spec_version__ = (
44
(1000 * int(version_split[0]))

neurons/validator/validator.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,7 @@ def _log_wandb(self, log):
543543
"question",
544544
"logic_question",
545545
"ref_ground_truth",
546-
"ground_truth_answer",
547-
546+
"ground_truth_answer"
548547
]
549548
Each row in the table is for one UID, containing lists of their tasks, responses, scores, etc.
550549
"""
@@ -570,7 +569,7 @@ def _log_wandb(self, log):
570569
"question": log["question"],
571570
"logic_question": log["logic_question"],
572571
"ref_ground_truth": log["ref_ground_truth"],
573-
"ground_truth": log["ground_truth"],
572+
"ground_truth": log["ground_truth"]
574573
}
575574

576575
# 3) Log to wandb

0 commit comments

Comments
 (0)