dyval.DAG.code_dag

class promptbench.dyval.DAG.code_dag.CodeDAG(num_nodes, min_links_per_node=1, max_links_per_node=3)

Bases: GeneralDAG

A specialized Directed Acyclic Graph (DAG) for representing and analyzing code structures.

This class extends GeneralDAG and provides additional functionality specific to code analysis, including reachability and maximum sum path calculations.

Parameters:

num_nodesint

The number of nodes in the DAG.

min_links_per_nodeint, optional

The minimum number of links per node (default is 1).

max_links_per_nodeint, optional

The maximum number of links per node (default is 3).

Methods:

reachability(start, end)

Determines whether there is a path from the start node to the end node.

max_sum_path(start, end)

Finds the path from start to end having the maximum sum of node values.

max_sum_path(start, end)
reachability(start, end)
class promptbench.dyval.DAG.code_dag.CodeDAGDescriber(dag_obj, dataset_type, add_rand_desc=0)

Bases: GeneralDAGDescriber

Describer class for CodeDAG, providing natural language descriptions of various DAG properties and questions.

This class extends GeneralDAGDescriber to work specifically with CodeDAG instances.

Parameters:

dag_objCodeDAG

The CodeDAG instance to describe.

dataset_typestr

The type of dataset for the DAG (e.g., ‘reachability’, ‘max_sum_path’).

add_rand_descint, optional

Random description addition parameter (default is 0).

Methods:

describe_reachability()

Generates a natural language description of a reachability question in the DAG.

describe_max_sum_path()

Generates a natural language description of a maximum sum path question in the DAG.

describe_question()

Generates a natural language description based on the dataset type.

describe_answer()

Returns the answer to the described question.

describe_inference_steps()

Returns the natural language inference steps for the described question.

describe_answer()
describe_inference_steps()
describe_max_sum_path()
describe_question()
describe_reachability()