Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite using Insight #26

Merged
merged 3 commits into from
Jul 2, 2024
Merged

Rewrite using Insight #26

merged 3 commits into from
Jul 2, 2024

Conversation

Xmaster6y
Copy link
Owner

@Xmaster6y Xmaster6y commented Jun 30, 2024

Closes #24

Summary by Sourcery

This pull request refactors the codebase to replace the ModelWrapper class with the new LczeroModel class, which extends NNsight. It also introduces new XAI lenses (ProbingLens, ActivationLens, and PatchingLens) and removes deprecated files and modules.

  • New Features:
    • Introduced LczeroModel class extending NNsight for model handling.
    • Added ProbingLens class for probing-based XAI methods.
    • Added ActivationLens class for activation-based XAI methods.
    • Added PatchingLens class for patching-based XAI methods.
  • Enhancements:
    • Replaced ModelWrapper with LczeroModel across the codebase for improved model handling.
    • Refactored lens compatibility checks and analysis methods to use LczeroModel.
    • Updated Flow class to extend LczeroModel instead of ModelWrapper.
  • Chores:
    • Removed deprecated files and modules related to the old model wrapper and XAI lenses.

Copy link
Contributor

sourcery-ai bot commented Jun 30, 2024

Reviewer's Guide by Sourcery

This pull request refactors the LCZero model wrapper to use the NNsight library, renaming the main class from ModelWrapper to LczeroModel. It also updates various parts of the codebase to accommodate this change, including the XAI lenses and concepts. Additionally, it introduces new lenses and removes deprecated files.

File-Level Changes

Files Changes
src/lczerolens/model/wrapper.py
src/lczerolens/xai/lenses/lrp.py
src/lczerolens/xai/lenses/crp.py
src/lczerolens/xai/probe.py
src/lczerolens/xai/lens.py
src/lczerolens/game/play.py
src/lczerolens/xai/concepts/move.py
src/lczerolens/__init__.py
Refactored to use LczeroModel instead of ModelWrapper and updated method signatures and logic accordingly.
src/lczerolens/xai/concept.py
src/lczerolens/xai/concepts/material.py
src/lczerolens/xai/concepts/threat.py
Updated method decorators and imports for concepts.
src/lczerolens/xai/lenses/__init__.py
src/lczerolens/lenses/activation.py
src/lczerolens/lenses/patching.py
src/lczerolens/lenses/crp/__init__.py
src/lczerolens/lenses/lrp/__init__.py
Added new lenses and updated imports.
src/lczerolens/_native_builder/constants.py
src/lczerolens/_native_builder/senet.py
src/lczerolens/_native_builder/builder.py
src/lczerolens/xai/hook.py
src/lczerolens/xai/lenses/policy.py
src/lczerolens/xai/lenses/probing.py
src/lczerolens/xai/lenses/patching.py
src/lczerolens/xai/lenses/activation.py
src/lczerolens/xai/__init__.py
src/lczerolens/game/__init__.py
src/lczerolens/model/__init__.py
src/lczerolens/_native_builder/__init__.py
Removed deprecated files.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Xmaster6y - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 5 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

src/lczerolens/model/wrapper.py Show resolved Hide resolved
src/lczerolens/model/wrapper.py Show resolved Hide resolved
src/lczerolens/model/wrapper.py Show resolved Hide resolved
src/lczerolens/xai/lenses/lrp.py Outdated Show resolved Hide resolved
src/lczerolens/xai/concept.py Show resolved Hide resolved
src/lczerolens/lenses/activation.py Outdated Show resolved Hide resolved
@Xmaster6y Xmaster6y merged commit 0bb0b11 into main Jul 2, 2024
1 check passed
@Xmaster6y Xmaster6y deleted the nnsight branch July 2, 2024 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rewrite using NNSight
1 participant