πŸ“„ Berkeley Function Calling Leaderboard (Multi Turn Setup) - Multiple V3ΒΆ

The Berkeley function calling leaderboard is a live leaderboard to evaluate the ability of different LLMs to call functions (also referred to as tools). We built this dataset from our learnings to be representative of most users’ function calling use-cases, for example, in agents, as a part of enterprise workflows, etc. To this end, our evaluation dataset spans diverse categories, and across multiple languages.

Tags: annotations_creators:expert-generated, language:['en'], license:apache-2.0, size_categories:['10K<n<100K'], task_categories:['question-answering', 'reading-comprehension', 'tool-calling', 'multi-turn-tool-calling'], task_ids:['tool-calling', 'multi-turn-tool-calling', 'reading-comprehension'], category:dataset

cards.bfcl.multi_turn.multiple_v3

TaskCard(
    loader=LoadJsonFile(
        files={
            "questions": "https://raw.githubusercontent.com/ShishirPatil/gorilla/70b6a4a2144597b1f99d1f4d3185d35d7ee532a4/berkeley-function-call-leaderboard/data/BFCL_v3_multiple.json",
            "answers": "https://raw.githubusercontent.com/ShishirPatil/gorilla/70b6a4a2144597b1f99d1f4d3185d35d7ee532a4/berkeley-function-call-leaderboard/data/possible_answer/BFCL_v3_multiple.json",
        },
        lines=True,
        data_classification_policy=[
            "public",
        ],
    ),
    preprocess_steps=[
        JoinStreams(
            left_stream="questions",
            right_stream="answers",
            how="inner",
            on="id",
            new_stream_name="test",
        ),
        Copy(
            field="question/*/0",
            to_field="dialog",
        ),
        Copy(
            field="function",
            to_field="tools",
        ),
        "operators.fix_json_schema",
        ExecuteExpression(
            expression="[{"name": k, "arguments": dict(zip(v.keys(), vals))} for d in ground_truth for k, v in d.items() for vals in itertools.product(*v.values())]",
            to_field="reference_calls",
            imports_list=[
                "itertools",
            ],
        ),
    ],
    task="tasks.tool_calling.multi_turn",
    templates=[
        "templates.tool_calling.multi_turn",
    ],
    __title__="Berkeley Function Calling Leaderboard (Multi Turn Setup) - Multiple V3",
)
[source]

from unitxt.loaders import LoadJsonFile
from unitxt.operators import Copy, ExecuteExpression
from unitxt.stream_operators import JoinStreams

Explanation about TaskCardΒΆ

TaskCard delineates the phases in transforming the source dataset into model input, and specifies the metrics for evaluation of model output.

Args:
loader:

specifies the source address and the loading operator that can access that source and transform it into a unitxt multistream.

preprocess_steps:

list of unitxt operators to process the data source into model input.

task:

specifies the fields (of the already (pre)processed instance) making the inputs, the fields making the outputs, and the metrics to be used for evaluating the model output.

templates:

format strings to be applied on the input fields (specified by the task) and the output fields. The template also carries the instructions and the list of postprocessing steps, to be applied to the model output.

Explanation about JoinStreamsΒΆ

Join multiple streams into a single stream.

Args:

left_stream (str): The stream that will be considered the β€œleft” in the join operations. right_stream (str): The stream that will be considered the β€œright” in the join operations. how (Literal[β€œleft”, β€œright”, β€œinner”, β€œouter”, β€œcross”]): The type of join to be performed. on (Optional[List[str]]): Column names to join on. These must be found in both streams. left_on (Optional[List[str]]): Column names to join on in the left stream. right_on (Optional[List[str]]): Column names to join on in the right streasm. new_stream_name (str): The name of the new stream resulting from the merge.

Examples:

JoinStreams(left_stream = β€œquestions”, right_stream = β€œanswers”, how=”inner”, on=”question_id”, new_stream_name=”question_with_answers” ) Join the β€˜question’ and β€˜answer’ stream based on the β€˜question_id’ field using inner join, resulting with a new stream named β€œquestion_with_answers”. JoinStreams(left_stream = β€œquestions”, right_stream = β€œanswers”, how=”inner”, on_left=”question_id”, on_right=”question” new_stream_name=”question_with_answers” ) Join the β€˜question’ and β€˜answer’ stream based on the β€˜question_id’ field in the left stream and the β€˜question’ field in the right stream, using inner join, resulting with a new stream named β€œquestion_with_answers”. This is suitable when the fields have different labels across the streams.

Explanation about ExecuteExpressionΒΆ

Compute an expression, specified as a string to be eval-uated, over the instance’s fields, and store the result in field to_field.

Raises an error if a field mentioned in the query is missing from the instance.

Args:

expression (str): an expression to be evaluated over the fields of the instance to_field (str): the field where the result is to be stored into imports_list (List[str]): names of imports needed for the eval of the query (e.g. β€˜re’, β€˜json’)

Examples:

When instance {β€œa”: 2, β€œb”: 3} is process-ed by operator ExecuteExpression(expression=”a+b”, to_field = β€œc”) the result is {β€œa”: 2, β€œb”: 3, β€œc”: 5}

When instance {β€œa”: β€œhello”, β€œb”: β€œworld”} is process-ed by operator ExecuteExpression(expression = β€œa+’ β€˜+b”, to_field = β€œc”) the result is {β€œa”: β€œhello”, β€œb”: β€œworld”, β€œc”: β€œhello world”}

Explanation about CopyΒΆ

Copies values from specified fields to specified fields.

Args (of parent class):

field_to_field (Union[List[List], Dict[str, str]]): A list of lists, where each sublist contains the source field and the destination field, or a dictionary mapping source fields to destination fields.

Examples:

An input instance {β€œa”: 2, β€œb”: 3}, when processed by Copy(field_to_field={"a": "b"}) would yield {β€œa”: 2, β€œb”: 2}, and when processed by Copy(field_to_field={"a": "c"}) would yield {β€œa”: 2, β€œb”: 3, β€œc”: 2}

with field names containing / , we can also copy inside the field: Copy(field="a/0",to_field="a") would process instance {β€œa”: [1, 3]} into {β€œa”: 1}

Explanation about LoadJsonFileΒΆ

Loads data from JSON files.

Supports streaming and can handle large files by loading them in chunks.

Args:

files (Dict[str, str]): A dictionary mapping names to file paths. chunksize : Size of the chunks to load at a time. loader_limit: Optional integer to specify a limit on the number of records to load. streaming: Bool indicating if streaming should be used. lines: Bool indicate if it is json lines file structure. Otherwise, assumes a single json object in the file. data_field: optional field within the json object, that contains the list of instances.

Example:

Loading json lines

load_csv = LoadJsonFile(files={'train': 'path/to/train.jsonl'}, line=True, chunksize=100)

References: templates.tool_calling.multi_turn, tasks.tool_calling.multi_turn, operators.fix_json_schema

Read more about catalog usage here.