autorag.schema package

Submodules

autorag.schema.base module

class autorag.schema.base.BaseModule[source]

Bases: object

abstract cast_to_run(previous_result: DataFrame, *args, **kwargs)[source]

This function is for cast function (a.k.a decorator) only for pure function in the whole node.

abstract pure(previous_result: DataFrame, *args, **kwargs)[source]
classmethod run_evaluator(project_dir: str | Path, previous_result: DataFrame, *args, **kwargs)[source]

autorag.schema.metricinput module

class autorag.schema.metricinput.MetricInput(query: str | None = None, queries: List[str] | None = None, retrieval_gt_contents: List[List[str]] | None = None, retrieved_contents: List[str] | None = None, retrieval_gt: List[List[str]] | None = None, retrieved_ids: List[str] | None = None, prompt: str | None = None, generated_texts: str | None = None, generation_gt: List[str] | None = None, generated_log_probs: List[float] | None = None)[source]

Bases: object

classmethod from_dataframe(qa_data: DataFrame) List[MetricInput][source]

Convert a pandas DataFrame into a list of MetricInput instances. qa_data: pd.DataFrame: qa_data DataFrame containing metric data.

Returns:

List[MetricInput]: List of MetricInput objects created from DataFrame rows.

generated_log_probs: List[float] | None = None
generated_texts: str | None = None
generation_gt: List[str] | None = None
is_fields_notnone(fields_to_check: List[str]) bool[source]
prompt: str | None = None
queries: List[str] | None = None
query: str | None = None
retrieval_gt: List[List[str]] | None = None
retrieval_gt_contents: List[List[str]] | None = None
retrieved_contents: List[str] | None = None
retrieved_ids: List[str] | None = None

autorag.schema.module module

class autorag.schema.module.Module(module_type: str, module_param: Dict)[source]

Bases: object

classmethod from_dict(module_dict: Dict) Module[source]
module: Callable
module_param: Dict
module_type: str

autorag.schema.node module

class autorag.schema.node.Node(node_type: str, strategy: Dict, node_params: Dict, modules: List[autorag.schema.module.Module])[source]

Bases: object

classmethod from_dict(node_dict: Dict) Node[source]
get_param_combinations() Tuple[List[Callable], List[Dict]][source]

This method returns a combination of module and node parameters, also corresponding modules.

Returns:

Each module and its module parameters.

Return type:

Tuple[List[Callable], List[Dict]]

modules: List[Module]
node_params: Dict
node_type: str
run(previous_result: DataFrame, node_line_dir: str) DataFrame[source]
run_node: Callable
strategy: Dict
autorag.schema.node.extract_values(node: Node, key: str) List[str][source]

This function extract values from node’s modules’ module_param.

Parameters:
  • node – The node you want to extract values from.

  • key – The key of module_param that you want to extract.

Returns:

The list of extracted values. It removes duplicated elements automatically.

autorag.schema.node.extract_values_from_nodes(nodes: List[Node], key: str) List[str][source]

This function extract values from nodes’ modules’ module_param.

Parameters:
  • nodes – The nodes you want to extract values from.

  • key – The key of module_param that you want to extract.

Returns:

The list of extracted values. It removes duplicated elements automatically.

autorag.schema.node.extract_values_from_nodes_strategy(nodes: List[Node], key: str) List[Any][source]

This function extract values from nodes’ strategy.

Parameters:
  • nodes – The nodes you want to extract values from.

  • key – The key string that you want to extract.

Returns:

The list of extracted values. It removes duplicated elements automatically.

autorag.schema.node.module_type_exists(nodes: List[Node], module_type: str) bool[source]

This function check if the module type exists in the nodes.

Parameters:
  • nodes – The nodes you want to check.

  • module_type – The module type you want to check.

Returns:

True if the module type exists in the nodes.

Module contents