MCPcopy Create free account
hub / github.com/Bolin97/MedArk / work

Function work

evaluation/eval.py:362–414  ·  view source on GitHub ↗
(model_out)

Source from the content-addressed store, hash-verified

360 bp = 0
361 b_div = 0
362 def work(model_out):
363 global ask, tell, lev_info, auv, lock, logger, entities
364 global total_informational_div, informational, support_info
365 global br, bf, bp, b_div
366 if isinstance(model_out['model'], list):
367 model_out['model'] = model_out['model'][0]
368 r, p, f = score([
369 model_out["model"],
370 ], [model_out['src']['conversation'][-1]['doctor']], lang='zh')
371 br += r[0]
372 bf += p[0]
373 bp += f[0]
374 b_div += 1
375 logger.info(model_out)
376 if is_ask(model_out["model"]):
377 model_entities = generate_entities(model_out["model"])
378 actual_resp = model_out['src']['conversation'][-1]['doctor']
379 actual_entities = generate_entities(actual_resp)
380 t_auv = get_auv(model_out, model_entities)
381 lev_d = Levenshtein.ratio(
382 flatten_medical_ask_content(actual_entities),
383 flatten_medical_ask_content(model_entities),
384 )
385 entities.append(
386 (actual_entities, model_entities)
387 )
388 if True:
389 ask += 1
390 lev_info.append(lev_d)
391 auv.append(
392 t_auv
393 )
394 else:
395 tell += 1
396 actual_resp = model_out['src']['conversation'][-1]['doctor']
397 is_f = False
398 if get_is_informational(
399 model_out['src']['conversation'][-1]['patient'],
400 model_out["model"],
401 actual_resp,
402 model_out['src']['conversation'][:-1]):
403 informational += 1
404 is_f = True
405 total_informational_div += 1
406 if is_f:
407 if not hallucinate(
408 model_out['src']['conversation'][-1]['patient'],
409 model_out["model"],
410 actual_resp,
411 model_out['src']['conversation'][:-1]):
412 support_info.append(1)
413 else:
414 support_info.append(0)
415 futures = []
416 for i in tqdm(data[:]):
417 work(i)

Callers 1

eval.pyFile · 0.70

Calls 6

is_askFunction · 0.70
generate_entitiesFunction · 0.70
get_auvFunction · 0.70
get_is_informationalFunction · 0.70
hallucinateFunction · 0.70

Tested by

no test coverage detected