Registry / ai-ml / lit-nlp

lit-nlp

JSON →
library1.3.1pypypi✓ verified 85d ago

LIT (Learning Interpretability Tool) is an open-source platform from PAIR (People + AI Research) at Google for visualizing and understanding machine learning models. Version 1.3.1 supports interpretability of generative AI, including sequence salience for LLMs, and can be deployed on Google Cloud with public container images. Releases occur approximately every 6 months.

pip install lit-nlp
INSTALL
IMPORT
SIG · LIT-NLP
L
lit-nlp
ai-mlpythonv1.3.1
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LitApp
from lit_nlp import dev_server
from lit_nlp import developer_server
The correct module is dev_server (not developer_server). Using the wrong name will cause ImportError.
SimpleMultilabelPreds
from lit_nlp.api.types import SimpleMultilabelPreds
from lit_nlp.lib.types import SimpleMultilabelPreds
The types module is under lit_nlp.api, not lit_nlp.lib. Incorrect import leads to ModuleNotFoundError.

Launches LIT server with a CoSE dataset and a BERT classifier. Open http://localhost:5432 to interact.

import lit_nlp from lit_nlp import dev_server from lit_nlp.examples.datasets import CoSEDataset from lit_nlp.examples.models import BertClassifier datasets = {'cose': CoSEDataset()} models = {'bert': BertClassifier(version='bert-base-uncased')} dev_server.serve(datasets, models, port=5432)
lit --version
Debug
Known issues
breakingAs of v1.0, the Model class has been refactored: _with_metadata methods are removed. Subclasses must implement get_metadata() directly.
fix
Replace calls to predict_with_metadata() with separate calls to predict() and get_metadata().
affects: >=1.0.0
breakingIn v0.5, the package name was changed from LIT to LIT (Learning Interpretability Tool). Some internal module paths may differ from older v0.4.x versions.
fix
If migrating from v0.4, update imports to use the new lit_nlp namespace and check for removed functions.
affects: >=0.5
deprecatedThe 'transformer' salience method is deprecated in favor of 'gradient' and 'attention' for sequence salience.
fix
Use 'gradient' or 'attention' salience methods instead of 'transformer' when calling model.salience().
affects: >=1.1
gotchaLIT's default salience computation can be slow on CPU for large models. Users often report that the UI appears frozen.
fix
Run LIT on a machine with GPU. For development, reduce the dataset size or model complexity.
affects: all
Errors
Common errors & fixes
ImportError: No module named 'lit_nlp'
The package was installed as 'lit-nlp' but Python expects 'lit_nlp' (underscore).
fix
Use: pip install lit-nlp and then import lit_nlp (underscore). Or check installation with: pip list | grep lit
ModuleNotFoundError: No module named 'lit_nlp.lib'
After v1.0, some internal modules were moved; 'lit_nlp.lib' no longer exists.
fix
Use correct import paths, e.g., from lit_nlp.api.types import ...
Upgrade
Version history
1.3.1latest on PyPI · released Dec 20, 2024
Audit
Dependencies
piprequiredLIT requires a relatively recent version of pip to resolve complex dependencies.
Agent activity
10 hits · last 30 days
node
10
Resources
lit-nlp — pip install lit-nlp · libregistry