schemacast.ground¶
The model copies a quote; SchemaCast finds it in the episode and records the character offsets. Offsets are never taken from the model. A quote that cannot be found is a hallucination flag, handled by validation.
A cast's record graph carries each quote and span in graflo's evidence,
as {"quote": str, "span": {"start": int, "end": int, "context": str}}
(context only when set); :func:evidence, :func:quote_of and
:func:span_of write and read it.
Attributes¶
Span = TextSpan
module-attribute
¶
Classes¶
Grounding
¶
Bases: BaseModel
One assertion and the span of text it was read from.
A grounding names the record or relation of the cast's record graph it supports, by ref; resolution maps refs to entities. Carried in the cast result only; nothing here is written to the graph.
Source code in schemacast/ground.py
Attributes¶
char_end
instance-attribute
¶
char_start
instance-attribute
¶
edge = Field(default=None, description='Edge, for an edge or its property.')
class-attribute
instance-attribute
¶
extractor = Field(description='``schemacast/<version>``.')
class-attribute
instance-attribute
¶
in_context = Field(default=None, description="Source id of the context item the span points into; None for the episode's own text. Only key values ground in context.")
class-attribute
instance-attribute
¶
kind
instance-attribute
¶
model = Field(default=None, description='Model that produced the reply.')
class-attribute
instance-attribute
¶
property = Field(default=None, description='Property name, for a property.')
class-attribute
instance-attribute
¶
quote = Field(description='The text at the span, as it stands in the source.')
class-attribute
instance-attribute
¶
ref = Field(default=None, description='Record ref, for a vertex or its property.')
class-attribute
instance-attribute
¶
reference_time = None
class-attribute
instance-attribute
¶
schema_ref = Field(description='``<schema name>@<version>``.')
class-attribute
instance-attribute
¶
source_id = Field(description='Episode the assertion was read from.')
class-attribute
instance-attribute
¶
source_ref = Field(default=None, description="Ref of the edge's source record.")
class-attribute
instance-attribute
¶
target_ref = Field(default=None, description="Ref of the edge's target record.")
class-attribute
instance-attribute
¶
vertex = Field(default=None, description='Vertex type, for a vertex or its property.')
class-attribute
instance-attribute
¶
TextSpan
¶
Bases: BaseModel
Character offsets, end exclusive, into the episode's text, or into the
text of the context item context names.
Source code in schemacast/ground.py
UnmappedText
¶
Bases: BaseModel
Something the text states that no type covers.
Source code in schemacast/ground.py
Functions:¶
evidence(quote, span)
¶
The evidence of a record, relation or property read at span.
groundings(graph, episode, *, extractor, model=None)
¶
One grounding per record, relation and stated property of graph whose
evidence holds a span; none for a known entity's record.
Source code in schemacast/ground.py
locate(quote, text, *, near=None)
¶
Find quote in text: exactly, then ignoring case, accents, whitespace runs and typographic quotes and dashes, then also without surrounding punctuation. Of several occurrences, the one nearest near wins, else the first.
Source code in schemacast/ground.py
quote_of(evidence)
¶
span_of(evidence)
¶
The span an evidence holds, if any.