Commit 4cdef35
committed
fix(inference): unpack structured records per sample, not all-or-nothing
infer_data_job() only splits the prediction / extra_records columns when
EVERY sample is a structured record:
if all(_is_structured_record(data_all[x]) for x in data['index']):
But a sample that exhausts its retries comes back from BaseAPI.generate as
a plain string (`return self.fail_msg if answer in ['', None] else answer`),
while a successful one returns {"prediction": ..., "extra_records": ...}.
A single failed sample therefore makes all(...) False, and every successful
record in the run is stringified into its own dict repr - the extra_records
column is never created, and the prediction column holds
"{'prediction': ..., 'extra_records': {...}}" for downstream scoring.
Unpack each sample on its own via a shared helper, and gate on any(...) so
that a run with no structured records at all still takes the old path.
Fully homogeneous runs (all structured, none structured) are unchanged.
The SPLIT_THINK branch had the same all-or-nothing gate and is fixed too;
there the corruption is worse, because split_thinking() then cuts the dict
repr at '</think>' and leaves the tail glued to the answer.
Fixes #16651 parent 5a91183 commit 4cdef35
1 file changed
Lines changed: 26 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
209 | 229 | | |
210 | 230 | | |
211 | 231 | | |
| |||
245 | 265 | | |
246 | 266 | | |
247 | 267 | | |
248 | | - | |
249 | | - | |
250 | | - | |
| 268 | + | |
| 269 | + | |
251 | 270 | | |
252 | 271 | | |
253 | 272 | | |
| |||
274 | 293 | | |
275 | 294 | | |
276 | 295 | | |
277 | | - | |
278 | | - | |
279 | | - | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
280 | 300 | | |
281 | 301 | | |
282 | 302 | | |
| |||
0 commit comments