MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / annotate_dataset

Function annotate_dataset

camel/benchmarks/ragbench.py:36–62  ·  view source on GitHub ↗

r"""Annotate the dataset by adding context and answers using the provided functions. Args: dataset (Dataset): The input dataset to annotate. context_call (Optional[Callable[[Dict[str, Any]], List[str]]]): Function to generate context for each example. ans

(
    dataset: Dataset,
    context_call: Optional[Callable[[Dict[str, Any]], List[str]]],
    answer_call: Optional[Callable[[Dict[str, Any]], str]],
)

Source from the content-addressed store, hash-verified

34
35
36def annotate_dataset(
37 dataset: Dataset,
38 context_call: Optional[Callable[[Dict[str, Any]], List[str]]],
39 answer_call: Optional[Callable[[Dict[str, Any]], str]],
40) -> Dataset:
41 r"""Annotate the dataset by adding context and answers using the provided
42 functions.
43
44 Args:
45 dataset (Dataset): The input dataset to annotate.
46 context_call (Optional[Callable[[Dict[str, Any]], List[str]]]):
47 Function to generate context for each example.
48 answer_call (Optional[Callable[[Dict[str, Any]], str]]): Function to
49 generate answer for each example.
50
51 Returns:
52 Dataset: The annotated dataset with added contexts and/or answers.
53 """
54
55 def process_example(example: Dict[str, Any]) -> Dict[str, Any]:
56 if context_call:
57 example["contexts"] = context_call(example)
58 if answer_call:
59 example["answer"] = answer_call(example)
60 return example
61
62 return dataset.map(process_example)
63
64
65def rmse(

Callers 1

runMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected