MCPcopy Create free account
hub / github.com/google-deepmind/alphageometry / main

Function main

alphageometry.py:604–647  ·  view source on GitHub ↗
(_)

Source from the content-addressed store, hash-verified

602
603
604def main(_):
605 global DEFINITIONS
606 global RULES
607
608 # definitions of terms used in our domain-specific language.
609 DEFINITIONS = pr.Definition.from_txt_file(_DEFS_FILE.value, to_dict=True)
610 # load inference rules used in DD.
611 RULES = pr.Theorem.from_txt_file(_RULES_FILE.value, to_dict=True)
612
613 # when using the language model,
614 # point names will be renamed to alphabetical a, b, c, d, e, ...
615 # instead of staying with their original names,
616 # in order to match the synthetic training data generation.
617 need_rename = _MODE.value != 'ddar'
618
619 # load problems from the problems_file,
620 problems = pr.Problem.from_txt_file(
621 _PROBLEMS_FILE.value, to_dict=True, translate=need_rename
622 )
623
624 if _PROBLEM_NAME.value not in problems:
625 raise ValueError(
626 f'Problem name `{_PROBLEM_NAME.value}` '
627 + f'not found in `{_PROBLEMS_FILE.value}`'
628 )
629
630 this_problem = problems[_PROBLEM_NAME.value]
631
632 if _MODE.value == 'ddar':
633 g, _ = gh.Graph.build_problem(this_problem, DEFINITIONS)
634 run_ddar(g, this_problem, _OUT_FILE.value)
635
636 elif _MODE.value == 'alphageometry':
637 model = get_lm(_CKPT_PATH.value, _VOCAB_PATH.value)
638 run_alphageometry(
639 model,
640 this_problem,
641 _SEARCH_DEPTH.value,
642 _BEAM_SIZE.value,
643 _OUT_FILE.value,
644 )
645
646 else:
647 raise ValueError(f'Unknown FLAGS.mode: {_MODE.value}')
648
649
650if __name__ == '__main__':

Callers

nothing calls this directly

Calls 5

run_ddarFunction · 0.85
get_lmFunction · 0.85
run_alphageometryFunction · 0.85
build_problemMethod · 0.80
from_txt_fileMethod · 0.45

Tested by

no test coverage detected