lpgcast.bench.score¶
Score a cast episode against its expected graph.
No model judges. Entities match by identity: the primary key of a natural type, the digest of a hash type, or any complete secondary identity. A type with no identity of its own (assigned, blank) matches by equal property values or by a quote overlapping the expected one. Edges match by relation and matched endpoints; an edge between the right endpoints the wrong way round counts as reversed. Property values compare after coercion by their field, strings ignoring case and runs of whitespace.
Every figure is a pair of integer counts, so cases pool by summing and a rate is read off the pooled counts.
Attributes¶
NOT_CONFORMANCE = frozenset({'quote_not_found', 'value_not_in_quote'}) | CONSEQUENTIAL
module-attribute
¶
Classes¶
Counts
¶
Bases: BaseModel
Additive counts for one episode, a case, a family or a run.
Source code in lpgcast/bench/score.py
Attributes¶
billed_input_tokens = 0
class-attribute
instance-attribute
¶
billed_output_tokens = 0
class-attribute
instance-attribute
¶
direction_fixed = 0
class-attribute
instance-attribute
¶
edges_expected = 0
class-attribute
instance-attribute
¶
edges_first = 0
class-attribute
instance-attribute
¶
edges_matched = 0
class-attribute
instance-attribute
¶
edges_produced = 0
class-attribute
instance-attribute
¶
edges_reversed = 0
class-attribute
instance-attribute
¶
emitted_final = 0
class-attribute
instance-attribute
¶
emitted_first = 0
class-attribute
instance-attribute
¶
entities_expected = 0
class-attribute
instance-attribute
¶
entities_matched = 0
class-attribute
instance-attribute
¶
entities_produced = 0
class-attribute
instance-attribute
¶
episodes = 0
class-attribute
instance-attribute
¶
failed = 0
class-attribute
instance-attribute
¶
forbidden_expected = 0
class-attribute
instance-attribute
¶
forbidden_written = 0
class-attribute
instance-attribute
¶
gold_edges = 0
class-attribute
instance-attribute
¶
gold_edges_in_slice = 0
class-attribute
instance-attribute
¶
gold_types = 0
class-attribute
instance-attribute
¶
gold_types_in_slice = 0
class-attribute
instance-attribute
¶
gold_types_seeded = 0
class-attribute
instance-attribute
¶
input_tokens = 0
class-attribute
instance-attribute
¶
mention_agree = 0
class-attribute
instance-attribute
¶
nonconforming_final = 0
class-attribute
instance-attribute
¶
nonconforming_first = 0
class-attribute
instance-attribute
¶
output_tokens = 0
class-attribute
instance-attribute
¶
properties_first = 0
class-attribute
instance-attribute
¶
props_expected = 0
class-attribute
instance-attribute
¶
props_matched = 0
class-attribute
instance-attribute
¶
props_produced = 0
class-attribute
instance-attribute
¶
recast_added = 0
class-attribute
instance-attribute
¶
recast_duplicated = 0
class-attribute
instance-attribute
¶
recast_minted = 0
class-attribute
instance-attribute
¶
recast_vertices = 0
class-attribute
instance-attribute
¶
repairs = 0
class-attribute
instance-attribute
¶
requests = 0
class-attribute
instance-attribute
¶
sliced = 0
class-attribute
instance-attribute
¶
spans_checked = 0
class-attribute
instance-attribute
¶
spans_hit = 0
class-attribute
instance-attribute
¶
undeclared_edge_first = 0
class-attribute
instance-attribute
¶
undeclared_property_first = 0
class-attribute
instance-attribute
¶
unfaithful_value_first = 0
class-attribute
instance-attribute
¶
ungrounded_first = 0
class-attribute
instance-attribute
¶
unknown_type_first = 0
class-attribute
instance-attribute
¶
vertices_first = 0
class-attribute
instance-attribute
¶
Methods:¶
Functions:¶
gold_vertices(graph, schema, text, context=None)
¶
Expected vertices with coerced properties, identity keys and spans.
Raises:
| Type | Description |
|---|---|
ValueError
|
a type or property the schema does not declare, or a value its field refuses. |
Source code in lpgcast/bench/score.py
identity_keys(vertex, props)
¶
Every identity props complete: the primary first, then secondaries.
Source code in lpgcast/bench/score.py
score_episode(outcome, expected, schema, text, usage=None, context=None)
¶
Counts for one cast episode; context maps context source ids to text.
Source code in lpgcast/bench/score.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | |
score_recast(first, second, schema)
¶
What a second cast of the same episode would add to a store that upserts.
A natural or hash identity the first cast lacked is an added vertex; an assigned or blank one is a duplicate, since nothing ties it to the first.