diff --git a/abl/reasoning/kb.py b/abl/reasoning/kb.py index f5164d2..be41aa2 100644 --- a/abl/reasoning/kb.py +++ b/abl/reasoning/kb.py @@ -118,7 +118,9 @@ class KBBase(ABC): y : Any Ground truth of the reasoning result for the example. x : List[Any] - The corresponding input example. + The corresponding input example. If the information from the input + is not required in the reasoning process, then this parameter will not have + any effect. max_revision_num : int The upper limit on the number of revised labels for each example. require_more_revision : int @@ -169,7 +171,9 @@ class KBBase(ABC): y : Any Ground truth of the reasoning result for the example. x : List[Any] - The corresponding input example. + The corresponding input example. If the information from the input + is not required in the reasoning process, then this parameter will not have + any effect. revision_idx : List[int] A list specifying indices of where revisions should be made to the pseudo-label example. @@ -231,7 +235,9 @@ class KBBase(ABC): y : Any Ground truth of the reasoning result for the example. x : List[Any] - The corresponding input example. + The corresponding input example. If the information from the input + is not required in the reasoning process, then this parameter will not have + any effect. max_revision_num : int The upper limit on the number of revisions. require_more_revision : int @@ -523,7 +529,9 @@ class PrologKB(KBBase): y : Any Ground truth of the reasoning result for the example. x : List[Any] - The corresponding input example. + The corresponding input example. If the information from the input + is not required in the reasoning process, then this parameter will not have + any effect. revision_idx : List[int] A list specifying indices of where revisions should be made to the pseudo-label example. @@ -555,7 +563,9 @@ class PrologKB(KBBase): y : Any Ground truth of the reasoning result for the example. x : List[Any] - The corresponding input example. + The corresponding input example. If the information from the input + is not required in the reasoning process, then this parameter will not have + any effect. revision_idx : List[int] A list specifying indices of where revisions should be made to the pseudo-label example. diff --git a/docs/Intro/Reasoning.rst b/docs/Intro/Reasoning.rst index 3c1836d..2af667f 100644 --- a/docs/Intro/Reasoning.rst +++ b/docs/Intro/Reasoning.rst @@ -33,8 +33,8 @@ knowledge base. In addition, ABL-Package also offers several predefined subclasses of ``KBBase`` (e.g., ``PrologKB`` and ``GroundKB``), which we can utilize to build our knowledge base more conveniently. -Building a knowledge base from `KBBase` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Building a knowledge base from ``KBBase`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For the user-built KB from ``KBBase`` (a derived subclass), it's only required to pass the ``pseudo_label_list`` parameter in the ``__init__`` function @@ -43,8 +43,15 @@ and override the ``logic_forward`` function: - ``pseudo_label_list`` is the list of possible pseudo-labels (also, the output of the machine learning model). - ``logic_forward`` defines how to perform (deductive) reasoning, - i.e. matching each pseudo-label example (often consisting of multiple - pseudo-labels) to its reasoning result. + i.e. matching each pseudo-label example to its reasoning result. + +.. warnings:: + + Generally, the overridden function ``logic_forward`` provided by the user accepts + only one parameter, ``pseudo_label`` (a pseudo-label example), However, for certain + scenarios, deductive reasoning in the knowledge base may necessitate information + from the input. When this happens, ``logic_forward`` can also accept two parameters: + ``pseudo_label`` and ``x``. After that, other operations, including how to perform abductive reasoning, will be **automatically** set up. @@ -213,13 +220,16 @@ available, we aim to let the candidate do not largely revise the previously identified pseudo-label example. ``KBBase`` (also, ``GroundKB`` and ``PrologKB``) implement the method -``abduce_candidates(pseudo_label, y, max_revision_num, require_more_revision)`` +``abduce_candidates(pseudo_label, y, x, max_revision_num, require_more_revision)`` for performing abductive reasoning, where the parameters are: - ``pseudo_label``, the pseudo-label example to be revised by abductive reasoning, usually generated by the learning part. - ``y``, the ground truth of the reasoning result for the example. The returned candidates should be compatible with it. +- ``x``, the corresponding input example. If the information from the input + is not required in the reasoning process, then this parameter will not have + any effect. - ``max_revision_num``, an int value specifying the upper limit on the number of revised labels for each example. - ``require_more_revision``, an int value specifying additional number