lczerolens 🔍
Leela Chess Zero (lc0) Lens (lczerolens) makes lc0-family models portable and operable in PyTorch, then expresses their evaluator and search behavior as chess-domain evidence. It provides the model and chess-analysis boundary; interpretability methods remain external integrations. See the scope and compatibility policy.
Getting Started
Installs
pip install lczerolens
Loading or publishing models through Hugging Face Hub requires the hub extra:
pip install "lczerolens[hub]"
Tests
After just test-fixtures has fetched and checksummed the lc0 fixtures, just tests runs the complete fast, offline suite (unit and conformance tests) and
produces the coverage report. just tests-unit and just tests-conformance
select either tier for diagnosis. The native Lczero bindings are a test-only
conformance oracle, installed through the conformance dependency group rather
than exposed as library API. Notebook and release checks are opt-in with
just tests-slow; the notebook suite executes every maintained .ipynb page.
just tests-wheel builds and installs the wheel in a fresh virtual
environment before running the maintained workflow. CI retains JUnit and
coverage artifacts to make failures inspectable.
Evaluate a position
Get the best move predicted by a model:
import chess
from lczerolens import LczeroEvaluator, LczeroModel
model = LczeroModel.from_hf("lczerolens/maia-1100")
evaluator = LczeroEvaluator(model)
board = chess.Board()
evaluation = evaluator.evaluate(board)
print(evaluation.policy.best_move)
print(evaluation.policy["e2e4"].probability)
External Interpretability Integrations
Use lczerolens with your preferred PyTorch interpretability framework
(tdhook, captum, zennit, or nnsight). These packages own their methods;
they are not lczerolens abstractions or dependencies of its evaluator contract.
import chess
from lczerolens import LczeroEvaluator, LczeroKeys, LczeroModel
from tdhook.attribution import Saliency
from tensordict import TensorDict
model = LczeroModel.from_hf("lczerolens/maia-1100")
evaluator = LczeroEvaluator(model)
board = chess.Board()
def best_logit_init_targets(td: TensorDict, _):
policy = td[LczeroKeys.NETWORK_POLICY_LOGITS]
best_logit = policy.max(dim=-1).values
return TensorDict(out=best_logit, batch_size=td.batch_size)
saliency_context = Saliency(init_attr_targets=best_logit_init_targets)
with saliency_context.prepare(evaluator.model) as hooked_model:
tensors = hooked_model(evaluator.prepare([board]))
evaluation = evaluator.finish([board], tensors)[0]
attr = tensors.get(("attr", "input", "planes"))
Define and grade a puzzle
Puzzle correctness comes from an authored solution tree rather than from model preference or chess terminality:
import chess
from lczerolens import Puzzle, PuzzleContinuation, PuzzleSolution
board = chess.Board("7k/8/5KQ1/8/8/8/8/8 w - - 0 1")
solution = PuzzleSolution((PuzzleContinuation("g6g7"),))
puzzle = Puzzle.from_board(board, solution)
attempt = puzzle.grade(["g6g7"])
print(attempt.status) # PuzzleStatus.SOLVED
Solution trees can retain alternative accepted moves and authored opponent replies. Provider-specific dataset ingestion remains outside the core package.
Decision-analysis documentation
The maintained documentation covers the evaluator and position contract, exact facts and move/variation evidence, authored puzzles, constrained counterfactuals, typed search traces, and concrete decision comparisons. Start with the scope and compatibility policy, then follow the facts, search, and use cases guides.
Interpretability techniques remain external integrations rather than lczerolens APIs.
Maintained demos
The executable decision-analysis tutorial composes evaluator, search, exact line analysis, and counterfactual comparison against a deterministic fixture. Seven maintained feature and tutorial notebooks cover model loading and inputs, evaluation, chess evidence, search and replay, complete decision analysis, model comparison, and authored-puzzle analysis. Sphinx renders and executes them, and the integration tier executes the source notebooks directly. Historical notebooks built on removed APIs are not shipped.
Full Documentation
See the full documentation.
Contribute
See the guidelines in CONTRIBUTING.md.
Citation
If you're using lczerolens in your research, please cite it using the following BibTeX entry:
@software{poupart_lczerolens_2026,
author = {Poupart, Yoann},
title = {LCZeroLens},
version = {0.4.0},
year = {2026},
url = {https://github.com/Xmaster6y/lczerolens}
}
License
lczerolens is licensed under the MIT License. See LICENSE for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lczerolens-0.5.0.tar.gz.
File metadata
- Download URL: lczerolens-0.5.0.tar.gz
- Upload date:
- Size: 77.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f358b107c513b9df736ad1a9fd6a5a77d62726e820abdaaf28292e1c11baf44d
|
|
| MD5 |
33bc5e09ade73a78e459d8e32bb1344c
|
|
| BLAKE2b-256 |
4240f2287a32764aa243bb623eff7a06d0da8f4a372caaa735cdb754dcf80ddb
|
Provenance
The following attestation bundles were made for lczerolens-0.5.0.tar.gz:
Publisher:
publish.yml on Xmaster6y/lczerolens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lczerolens-0.5.0.tar.gz -
Subject digest:
f358b107c513b9df736ad1a9fd6a5a77d62726e820abdaaf28292e1c11baf44d - Sigstore transparency entry: 2343438432
- Sigstore integration time:
-
Permalink:
Xmaster6y/lczerolens@a013c856f5e47790cf59f6f8970de6a639874c7c -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/Xmaster6y
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a013c856f5e47790cf59f6f8970de6a639874c7c -
Trigger Event:
release
-
Statement type:
File details
Details for the file lczerolens-0.5.0-py3-none-any.whl.
File metadata
- Download URL: lczerolens-0.5.0-py3-none-any.whl
- Upload date:
- Size: 84.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
039bc56961561242c7c2a3f8c66cb47ee670716c747713d9e5e8564517cff6de
|
|
| MD5 |
5fb440933a923502ac9df620f74137f8
|
|
| BLAKE2b-256 |
62ef97e1a1ba6210c3acb8f98c7dd66ee28f9ed00c276bf49dbeab0586a93f15
|
Provenance
The following attestation bundles were made for lczerolens-0.5.0-py3-none-any.whl:
Publisher:
publish.yml on Xmaster6y/lczerolens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lczerolens-0.5.0-py3-none-any.whl -
Subject digest:
039bc56961561242c7c2a3f8c66cb47ee670716c747713d9e5e8564517cff6de - Sigstore transparency entry: 2343438463
- Sigstore integration time:
-
Permalink:
Xmaster6y/lczerolens@a013c856f5e47790cf59f6f8970de6a639874c7c -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/Xmaster6y
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a013c856f5e47790cf59f6f8970de6a639874c7c -
Trigger Event:
release
-
Statement type: