You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Basics.rst 4.4 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. **Learn the Basics** ||
  2. `Quick Start <Quick-Start.html>`_ ||
  3. `Dataset & Data Structure <Datasets.html>`_ ||
  4. `Learning Part <Learning.html>`_ ||
  5. `Reasoning Part <Reasoning.html>`_ ||
  6. `Evaluation Metrics <Evaluation.html>`_ ||
  7. `Bridge <Bridge.html>`_
  8. Learn the Basics
  9. ================
  10. Modules in ABL kit
  11. ----------------------
  12. ABL kit is an efficient toolkit for `Abductive Learning <../Overview/Abductive-Learning.html>`_ (ABL),
  13. a paradigm which integrates machine learning and logical reasoning in a balanced-loop.
  14. ABL kit comprises three primary parts: **Data**, **Learning**, and
  15. **Reasoning**, corresponding to the three pivotal components of current
  16. AI: data, models, and knowledge. Below is an overview of the ABL kit.
  17. .. image:: ../_static/img/ABLkit.png
  18. **Data** part manages the storage, operation, and evaluation of data efficiently.
  19. It includes the ``ListData`` class, which defines the data structures used in
  20. ABL, and comprises common data operations like insertion, deletion,
  21. retrieval, slicing, etc. Additionally, it contains a series of evaluation metrics
  22. such as ``SymbolAccuracy`` and ``ReasoningMetric`` (both specialized metrics
  23. inherited from the ``BaseMetric`` class), for evaluating model quality from a
  24. data perspective.
  25. :blue-bold:`Learning` part focuses on the construction, training, and
  26. prediction of machine learning models. The ``ABLModel`` class is the
  27. central class that encapsulates the machine learning model. This class is
  28. compatible with various frameworks, including those based on Scikit-learn
  29. or PyTorch neural networks constructed by the ``BasicNN`` class.
  30. :green-bold:`Reasoning` part concentrates on constructing domain knowledge and
  31. performing reasoning. The ``KBBase`` class allows users to define a
  32. domain knowledge base. For diverse types of knowledge, we also offer
  33. implementations like ``GroundKB`` and ``PrologKB`` (both inherited
  34. from the ``KBBase`` class). The latter, for instance, enables
  35. knowledge bases to be imported in the form of Prolog files.
  36. Upon building the knowledge base, the ``Reasoner`` class is
  37. responsible for minimizing the inconsistency between the knowledge base
  38. and data.
  39. The integration of these three parts is achieved through the
  40. :yellow-bold:`Bridge` part, which features the ``SimpleBridge`` class (derived
  41. from the ``BaseBridge`` class). The Bridge part synthesizes data,
  42. learning, and reasoning, facilitating the training and testing
  43. of the entire ABL framework.
  44. Use ABL kit Step by Step
  45. ----------------------------
  46. In a typical ABL process, as illustrated below,
  47. data inputs are first predicted by the learning model ``ABLModel.predict``, and the outcomes are pseudo-labels.
  48. These labels then pass through deductive reasoning of the domain knowledge base ``KBBase.logic_forward``
  49. to obtain the reasoning result. During training,
  50. alongside the aforementioned forward flow (i.e., prediction --> deduction reasoning),
  51. there also exists a reverse flow, which starts from the reasoning result and
  52. involves abductive reasoning ``KBBase.abduce_candidates`` to generate possible revised pseudo-labels.
  53. Subsequently, these pseudo-labels are processed to minimize inconsistencies with the learning part.
  54. They in turn revise the outcomes of the learning model, which are then
  55. fed back for further training ``ABLModel.train``.
  56. .. image:: ../_static/img/usage.png
  57. To implement this process, the following five steps are necessary:
  58. 1. Prepare **datasets**
  59. Prepare the data's input, ground truth for pseudo-labels (optional), and ground truth for reasoning results.
  60. 2. :blue:`Build the` :blue-bold:`learning` :blue:`part`
  61. Build a machine learning base model that can predict inputs to pseudo-labels.
  62. Then, use ``ABLModel`` to encapsulate the base model.
  63. 3. :green:`Build the` :green-bold:`reasoning` :green:`part`
  64. Define a knowledge base by building a subclass of ``KBBase``, specifying how to
  65. process pseudo-labels to reasoning results.
  66. Also, create a ``Reasoner`` for minimizing inconsistencies
  67. between the knowledge base and data.
  68. 4. Define evaluation metrics
  69. Define the metrics by building a subclass of ``BaseMetric``. The metrics will
  70. specify how to measure performance during the training and testing of the ABL framework.
  71. 5. :yellow-bold:`Bridge` :yellow:`learning and reasoning`
  72. Use ``SimpleBridge`` to bridge the learning and reasoning part
  73. for integrated training and testing.

An efficient Python toolkit for Abductive Learning (ABL), a novel paradigm that integrates machine learning and logical reasoning in a unified framework.