π Extract In Json FormatΒΆ
templates.key_value_extraction.extract_in_json_format
InputOutputTemplate
(
instruction="Extract the key value pairs from the input. Return a valid json object with the following keys: {keys}. Return only the json representation, no additional text or explanations.",
input_format="{input}",
output_format="{key_value_pairs_answer}",
postprocessors=[
PostProcess
(
operator=JsonStrToDict
(),
),
],
serializer=MultiTypeSerializer
(
serializers=[
ImageSerializer
(),
DictAsJsonSerializer
(),
ListSerializer
(),
],
),
)
[source]from unitxt.processors import PostProcess
from unitxt.serializers import DictAsJsonSerializer, ImageSerializer, ListSerializer, MultiTypeSerializer
from unitxt.struct_data_operators import JsonStrToDict
Explanation about InputOutputTemplateΒΆ
Generate field βsourceβ from fields designated as input, and fields βtargetβ and βreferencesβ from fields designated as output, of the processed instance.
Args specify the formatting strings with which to glue together the input and reference fields of the processed instance into one string (βsourceβ and βtargetβ), and into a list of strings (βreferencesβ).
Explanation about JsonStrToDictΒΆ
Convert a Json string of representing key value as dictionary.
Ensure keys and values are strings, and there are no None values.
Read more about catalog usage here.