MCPcopy Create free account
hub / github.com/THUDM/AgentTuning / post_process_generation

Function post_process_generation

eval_heldout/science-world/eval_utils.py:867–883  ·  view source on GitHub ↗
(raw_pred)

Source from the content-addressed store, hash-verified

865
866
867def post_process_generation(raw_pred):
868 ans_match = re.match(r".*<extra_id_0>(.*)<extra_id_1>.*", raw_pred)
869 if ans_match is not None:
870 result = ans_match.group(1)
871 else:
872 result = raw_pred
873
874 # remove extra <*>'s left in
875 result = result.replace("<", " <")
876 out = ""
877 for token in result.split(" "):
878 if (len(token.strip()) > 0):
879 if (token[0] != "<"):
880 out += token + " "
881 result = out
882
883 return result.strip()
884
885
886def gpt_select_valid(action, candidates, look, inventory, goal, logger, n=1, gpt_version="gpt-4", llm=None):

Callers 1

get_model_outputFunction · 0.85

Calls 1

matchMethod · 0.45

Tested by

no test coverage detected