MCPcopy Create free account
hub / github.com/Sphere-AI-Lab/FormalMATH-Bench / process_data

Function process_data

generate_answers.py:122–240  ·  view source on GitHub ↗

Process data using vLLM to generate answers. This function provides compatibility with the original pipeline interface. Args: model_path (str): Path to the model input_file (str): Path to input JSON file output_file (str): Path to output JSON file ap

(
    model_path,
    input_file,
    output_file,
    api_port=8012,  # Not used but kept for compatibility
    num_processes=96,  # Not used but kept for compatibility
    batch_size=200,  # This will be used as 'n' (answers per batch)
    save_interval=16,  # Not used but kept for compatibility
    resume=True,  # Will be handled via checkpoint mechanism
    mode=None,  # Not used but kept for compatibility
    num_answers=3200  # This will be used as 'nums_answer' (total answers)
)

Source from the content-addressed store, hash-verified

120 return all_results
121
122def process_data(
123 model_path,
124 input_file,
125 output_file,
126 api_port=8012, # Not used but kept for compatibility
127 num_processes=96, # Not used but kept for compatibility
128 batch_size=200, # This will be used as 'n' (answers per batch)
129 save_interval=16, # Not used but kept for compatibility
130 resume=True, # Will be handled via checkpoint mechanism
131 mode=None, # Not used but kept for compatibility
132 num_answers=3200 # This will be used as 'nums_answer' (total answers)
133):
134 """
135 Process data using vLLM to generate answers.
136 This function provides compatibility with the original pipeline interface.
137
138 Args:
139 model_path (str): Path to the model
140 input_file (str): Path to input JSON file
141 output_file (str): Path to output JSON file
142 api_port (int): Not used with vLLM, kept for compatibility
143 num_processes (int): Not used with vLLM, kept for compatibility
144 batch_size (int): Used as 'n' - number of answers per batch
145 save_interval (int): Not used with vLLM, kept for compatibility
146 resume (bool): Will use checkpoint mechanism
147 mode (str): Not used with vLLM, kept for compatibility
148 num_answers (int): Total number of answers to generate per theorem
149
150 Returns:
151 list: The processed data
152 """
153 # Setup checkpoint directory
154 current_directory = os.getcwd()
155 checkpoint_dir = os.path.join(current_directory, 'checkpoint_mp')
156 os.makedirs(checkpoint_dir, exist_ok=True)
157
158 # Read data
159 print(f"Reading data from {input_file}...")
160 data = []
161 with jsonlines.open(input_file) as reader:
162 for obj in reader:
163 data.append(obj)
164
165 # Calculate num_batches
166 n = batch_size # Use batch_size as 'n'
167 nums_answer = num_answers
168 num_batches = math.ceil(nums_answer / n)
169
170 # Set sampling parameters
171 sampling_params = SamplingParams(
172 temperature=1.0,
173 max_tokens=2048,
174 top_p=0.95,
175 n=n,
176 )
177
178 # Get available GPUs
179 available_gpus = os.environ.get("CUDA_VISIBLE_DEVICES", "").split(",")

Callers 2

mainFunction · 0.90
mainFunction · 0.85

Calls 1

merge_checkpointsFunction · 0.85

Tested by

no test coverage detected