|
|
|
@@ -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 |
|
|
|
|