MCPcopy Create free account
hub / github.com/LeapLabTHU/limit-of-RLVR / process_fn

Function process_fn

code/DeepCoder/scripts/data/deepcoder_dataset.py:31–68  ·  view source on GitHub ↗
(example: Dict[str, Any], idx: int, dataset_name=None)

Source from the content-addressed store, hash-verified

29 Function that processes individual dataset examples
30 """
31 def process_fn(example: Dict[str, Any], idx: int, dataset_name=None) -> Optional[Dict[str, Any]]:
32 question = example.pop('problem')
33 tests = example.pop('tests')
34
35 if example.get('metadata', {}):
36 assert 'func_name' in example['metadata'], f"Function name is not found, check if your LCB data is preprocessed correctly: {example['metadata']}"
37 if isinstance(tests, dict):
38 tests['metadata'] = example['metadata']
39 else:
40 for test in tests:
41 assert isinstance(test, dict), "Test is not a dict"
42 test['metadata'] = example['metadata']
43
44 tests = json.dumps(tests)
45
46 if dataset_name == "livecodebench":
47 starter_code = example.get("starter_code", None)
48 question = fetch_live_code_bench_system_prompt(question, starter_code)
49 if isinstance(question, dict):
50 question = json.dumps(question)
51 data = {
52 "data_source": dataset_name,
53 "prompt": [{
54 "role": "user",
55 "content": question
56 }],
57 "ability": "code",
58 "reward_model": {
59 "style": "rule",
60 "ground_truth": tests
61 },
62 "extra_info": {
63 'split': split,
64 'index': idx,
65 'reference': example.get('completion', None), # For leetcode
66 }
67 }
68 return data
69 return process_fn
70
71

Callers 1

Calls 2

popMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected