MCPcopy Create free account
hub / github.com/InternScience/SciReason / LogicTree

Class LogicTree

opencompass/datasets/musr/tree.py:158–517  ·  view source on GitHub ↗

Main datastructure used when creating a MuSR example. It's basically a standard tree with some parameters controlling the shape.

Source from the content-addressed store, hash-verified

156
157
158class LogicTree:
159 """Main datastructure used when creating a MuSR example.
160
161 It's basically a standard tree with some parameters controlling the shape.
162 """
163
164 nodes: List[LogicNode]
165
166 chance_of_or: float
167 chance_of_cs_fact: float
168 depth: int
169 chance_to_prune: float
170 chance_to_prune_all: float
171 bf_factor: Dict[int, float]
172 deduction_type_sample_rate: Dict[LogicNodeDeductionType, float]
173 root_structure: List[List[LogicNode]] = ()
174
175 def __init__(self,
176 chance_of_or: float = 0.3,
177 chance_of_cs_fact: float = 0.1,
178 depth: int = 2,
179 chance_to_prune: float = 0.6,
180 chance_to_prune_all: float = 0.2,
181 bf_factor: Dict[int, float] = None,
182 deduction_type_sample_rate: Dict[LogicNodeDeductionType,
183 float] = None,
184 enforce_cs_fact_per_level: bool = False,
185 root_structure: List[Any] = (),
186 nodes: List[LogicNode] = (),
187 populate: bool = True,
188 prune: bool = True):
189 """
190 :param chance_of_or: (not used) how often should a node with children be an OR
191 :param chance_of_cs_fact: (not used) how often should there be a commonsense node
192 :param depth: How deep should a tree go
193 :param chance_to_prune: Percentage chance of pruning a node
194 :param chance_to_prune_all: Percentage chance of pruning all children from a node.
195 :param bf_factor: Branching factor (dictionary of percentages {1: 0.33, 2:0.33, 3:0.33} for example.
196 :param deduction_type_sample_rate: (not used, see bf_factor and LogicNodeDeductionType)
197 :param enforce_cs_fact_per_level: Enforce 1 commonsense fact per level in the tree (we use this instead of chance_of_cs_fact)
198 :param root_structure: List of LogicNodes to build off of.
199 :param nodes: List of LogicNodes to define the LogicTree on (we will not populate/prune the tree if this is filled)
200 :param populate: Should we populate children for the tree according to the other parameters?
201 :param prune: Should we prune the children for the tree according to the other parameters?
202 """
203 self.chance_of_or = chance_of_or
204 self.chance_of_cs_fact = chance_of_cs_fact
205 self.depth = depth
206 self.chance_to_prune = chance_to_prune
207 self.chance_to_prune_all = chance_to_prune_all
208 self.bf_factor = bf_factor
209 self.enforce_cs_fact_per_level = enforce_cs_fact_per_level
210
211 if not bf_factor:
212 self.bf_factor = {2: 0.8, 3: 0.2}
213 if not deduction_type_sample_rate:
214 deduction_type_sample_rate = {
215 LogicNodeDeductionType.SYLLOGISM: 1.0

Callers 4

tv_scene_exFunction · 0.85
eb_exFunction · 0.85
murder_mystery_exFunction · 0.85
action_exFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected