wesleysimplicio commited on
Commit
f7a4b71
·
verified ·
1 Parent(s): 179260f

docs: update benchmark_simplicio_27b.py with 6 architectural engineering adjustments

Browse files
Files changed (1) hide show
  1. benchmark_simplicio_27b.py +27 -3
benchmark_simplicio_27b.py CHANGED
@@ -154,7 +154,7 @@ def run_benchmark(model, tokenizer, test_cases: List[Dict]) -> Dict:
154
 
155
  start_t = time.time()
156
  inputs = tokenizer([prompt], return_tensors="pt").to("cuda")
157
- outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.1, use_cache=True)
158
  resp = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=False)
159
  elapsed = time.time() - start_t
160
 
@@ -167,14 +167,38 @@ def run_benchmark(model, tokenizer, test_cases: List[Dict]) -> Dict:
167
  if has_all_phases:
168
  phase_conformance += 1
169
 
170
- # 2. Diff Chunk Evaluation
171
- diffs = parse_surgical_diff(phases["patch"])
 
 
 
 
 
 
172
  diff_ok = False
173
  ast_ok = False
174
 
175
  if diffs:
176
  search_c, replace_c = diffs[0]
177
  eval_res = evaluate_surgical_patch(tc["original_code"], search_c, replace_c, tc["lang"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  if eval_res["search_matched"]:
179
  search_matches += 1
180
  diff_ok = True
 
154
 
155
  start_t = time.time()
156
  inputs = tokenizer([prompt], return_tensors="pt").to("cuda")
157
+ outputs = model.generate(**inputs, max_new_tokens=1536, temperature=0.1, use_cache=True)
158
  resp = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=False)
159
  elapsed = time.time() - start_t
160
 
 
167
  if has_all_phases:
168
  phase_conformance += 1
169
 
170
+ # 2. Diff Chunk Evaluation (Dual Support: Tagged <patch> OR Direct Markdown/Diff Extraction)
171
+ # Prevents unfair false negatives on base models that do not use proprietary XML tags
172
+ patch_text = phases.get("patch", "")
173
+ if not patch_text:
174
+ # Fallback: look for surgical diff or code block anywhere in raw response
175
+ patch_text = resp
176
+
177
+ diffs = parse_surgical_diff(patch_text)
178
  diff_ok = False
179
  ast_ok = False
180
 
181
  if diffs:
182
  search_c, replace_c = diffs[0]
183
  eval_res = evaluate_surgical_patch(tc["original_code"], search_c, replace_c, tc["lang"])
184
+ else:
185
+ # If base model output complete code block instead of diff, evaluate full replacement
186
+ code_block_match = re.search(r"```(?:python)?\s*
187
+ (.*?)
188
+ ```", resp, re.DOTALL)
189
+ if code_block_match:
190
+ candidate_code = code_block_match.group(1).strip()
191
+ eval_res = {"search_matched": True, "patch_applied": True, "ast_valid": False}
192
+ if tc["lang"] == "python":
193
+ try:
194
+ ast.parse(candidate_code)
195
+ eval_res["ast_valid"] = True
196
+ except SyntaxError:
197
+ eval_res["ast_valid"] = False
198
+ else:
199
+ eval_res["ast_valid"] = True
200
+ else:
201
+ eval_res = {"search_matched": False, "patch_applied": False, "ast_valid": False}
202
  if eval_res["search_matched"]:
203
  search_matches += 1
204
  diff_ok = True