build_prompt()
A few-shot prompt asking a model to annotate text in CANE.
Usage
build_prompt(
text,
*,
examples,
variant,
labels=None,
context=1,
handles=False,
on_unrepresentable="raise",
on_mismatch="warn",
parse_options=None,
lossy="warn",
dialect=ENGLISH
)The layout follows the CANE paper: task, entity types, format and guideline, the ‘Important’ instruction, the worked examples, then the input. Examples are written with dumps and the same options, so the prompt teaches exactly what loads expects.
Parameters
text: str-
The text to annotate.
examples: Sequence[Document]-
Annotated documents shown as few-shot examples.
variant: Variant | str-
The CANE variant.
labels: Iterable[str] | None = None-
The entity types in the order to list them (a set is sorted); by default the examples’ labels, sorted. Required when there are no examples.
context, handles, on_unrepresentable, on_mismatch, parse_options, lossy, dialect- As for dumps.