Add LNNClassifier for IBM LNN integration#132
Open
ColtonPayne wants to merge 1 commit intoadd-classifiersfrom
Open
Add LNNClassifier for IBM LNN integration#132ColtonPayne wants to merge 1 commit intoadd-classifiersfrom
ColtonPayne wants to merge 1 commit intoadd-classifiersfrom
Conversation
Introduces a bidirectional bridge between IBM Logical Neural Networks
and PyReason's graph-based reasoning engine. The LNNClassifier wraps an
LNN Model to produce PyReason Facts from logical inference, and accepts
feedback from PyReason's interpretation to tighten LNN bounds — enabling
a feedback loop where LNN reasons locally and PyReason propagates
globally.
New files:
- pyreason/scripts/learning/classification/lnn_classifier.py
- LNNClassifier: forward() runs LNN inference and emits Facts;
receive_feedback() injects PyReason bounds back into the LNN
- LNNInterfaceOptions: convergence_threshold, max_feedback_rounds,
bound_tightening_only
Modified files:
- pyreason/pyreason.py: conditional import of LNNClassifier when both
torch and lnn packages are available
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces
LNNClassifier, a bidirectional bridge between IBM Logical Neural Networks and PyReason. This enables a feedback loop where:[lower, upper]Why this matters
LNN and PyReason both operate on interval-valued truth bounds
[L, U], making them natural integration partners. But they have complementary blind spots:expert ∧ endorsed → reliable)The
LNNClassifierbridges this gap, enabling multi-hop reasoning that combines local logical inference with global graph propagation.Verified with POC
Check it out here
Changes
New files
pyreason/scripts/learning/classification/lnn_classifier.pyLNNClassifier— wraps an IBM LNNModel;forward()runs inference and emits PyReasonFactobjects;receive_feedback()injects PyReason bounds back as LNN evidenceLNNInterfaceOptions— configuresconvergence_threshold,max_feedback_rounds,bound_tightening_onlyModified files
pyreason/pyreason.py— conditional import ofLNNClassifier/LNNInterfaceOptionswhen bothtorchandlnnpackages are installed (graceful fallback toNoneotherwise)Design decisions
LogicIntegrationBase— LNNModelis not atorch.nn.Module, butLNNClassifierfollows the sameforward(data, t1, t2) → (raw, postproc, List[Fact])interface contractpredicate_mapbridges LNN's statefulPredicateobjects to string names;node_groundingsmaps LNN grounding names to PyReason node namestarget_predicatescontrols which LNN predicates export as PyReason Facts (not all need exporting)Dependencies
lnnpackage:pip install git+https://github.com/IBM/LNNTest plan
lnnnot installed (LNNClassifier = None)🤖 Generated with Claude Code