Skip to content

Commit cfcb439

Browse files
authored
Merge pull request #1585 from PAIR-code/dev
Merge dev onto main for v1.3 release
2 parents 61faeb6 + 7c3000c commit cfcb439

File tree

136 files changed

+2896
-9866
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+2896
-9866
lines changed

.github/workflows/ci.yml

+4-7
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,10 @@ jobs:
4545
uses: actions/setup-python@v4
4646
with:
4747
python-version: ${{ matrix.python-version }}
48-
- name: Install Python dependencies
49-
run: python -m pip install -r requirements.txt
50-
- name: Install LIT package
51-
run: python -m pip install -e .
48+
- name: Install LIT package with testing dependencies
49+
run: python -m pip install -e '.[test]'
5250
- name: Test LIT
53-
run: |
54-
python -m pip install pytest
55-
pytest -v
51+
run: pytest -v
5652
- name: Setup Node ${{ matrix.node-version }}
5753
uses: actions/setup-node@v2
5854
with:
@@ -73,4 +69,5 @@ jobs:
7369
- name: Build Docker image
7470
uses: docker/build-push-action@v4
7571
with:
72+
target: lit-nlp-prod
7673
tags: lit-nlp:ci-${{ github.sha }}

Dockerfile

+34-12
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,62 @@
1414
# ==============================================================================
1515
# Use the official lightweight Python image.
1616
# https://hub.docker.com/_/python
17-
FROM python:3.10-slim
17+
18+
# ---- LIT Base Container ----
19+
20+
FROM python:3.11-slim AS lit-nlp-base
1821

1922
# Update Ubuntu packages and install basic utils
2023
RUN apt-get update
2124
RUN apt-get install -y wget curl gnupg2 gcc g++ git
2225

26+
# Copy local code to the container image.
27+
ENV APP_HOME=/app
28+
WORKDIR $APP_HOME
29+
30+
COPY ./lit_nlp/examples/gunicorn_config.py ./
31+
32+
33+
34+
# ---- LIT Container for Hosted Demos ----
35+
36+
FROM lit-nlp-base AS lit-nlp-prod
37+
38+
RUN python -m pip install 'lit-nlp[examples-discriminative-ai]'
39+
40+
WORKDIR $APP_HOME
41+
ENTRYPOINT ["gunicorn", "--config=gunicorn_config.py"]
42+
43+
44+
45+
# ---- LIT Container for Developing and Testing Hosted Demos ----
46+
47+
FROM lit-nlp-base AS lit-nlp-dev
48+
2349
# Install yarn
2450
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
2551
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | \
2652
tee /etc/apt/sources.list.d/yarn.list
2753
RUN apt update && apt -y install yarn
2854

29-
# Copy local code to the container image.
30-
ENV APP_HOME /app
31-
WORKDIR $APP_HOME
32-
3355
# Set up python environment with production dependencies
3456
# This step is slow as it installs many packages.
35-
COPY ./requirements*.txt ./
36-
RUN python -m pip install -r requirements.txt
57+
COPY requirements.txt \
58+
requirements_examples_common.txt \
59+
requirements_examples_discriminative_ai.txt \
60+
./
61+
RUN python -m pip install -r requirements_examples_discriminative_ai.txt
3762

3863
# Copy the rest of the lit_nlp package
3964
COPY . ./
4065

4166
# Build front-end with yarn
4267
WORKDIR $APP_HOME/lit_nlp/client
43-
ENV NODE_OPTIONS "--openssl-legacy-provider"
68+
ENV NODE_OPTIONS="--openssl-legacy-provider"
4469
RUN yarn && yarn build && rm -rf node_modules/*
4570

4671
# Run LIT server
4772
# Note that the config file supports configuring the LIT demo that is launched
4873
# via the DEMO_NAME and DEMO_PORT environment variables.
4974
WORKDIR $APP_HOME
50-
ENTRYPOINT [ \
51-
"gunicorn", \
52-
"--config=lit_nlp/examples/gunicorn_config.py" \
53-
]
75+
ENTRYPOINT ["gunicorn", "--config=gunicorn_config.py"]

README.md

+55-55
Original file line numberDiff line numberDiff line change
@@ -51,91 +51,81 @@ For a broader overview, check out [our paper](https://arxiv.org/abs/2008.05122)
5151

5252
## Download and Installation
5353

54-
LIT can be run via container image, installed via `pip` or built from source.
55-
Building from source is necessary if you update any of the front-end or core
56-
back-end code.
54+
LIT can be installed via `pip` or built from source. Building from source is
55+
necessary if you want to make code changes.
5756

58-
### Build container image
57+
### Install from PyPI with pip
5958

60-
Build the image using `docker` or `podman`:
6159
```sh
62-
git clone https://github.com/PAIR-code/lit.git && cd lit
63-
docker build --file Dockerfile --tag lit-nlp .
60+
pip install lit-nlp
6461
```
6562

66-
See the [advanced guide](https://pair-code.github.io/lit/documentation/docker) for detailed instructions on using the
67-
default LIT Docker image, running LIT as a containerized web app in different
68-
scenarios, and how to creating your own LIT images.
69-
70-
### pip installation
63+
The default `pip` installation will install all required packages to use the LIT
64+
Python API, built-in interpretability components, and web application. To
65+
install dependencies for the provided demos or test suite, install LIT with the
66+
appropriate optional dependencies.
7167

7268
```sh
73-
pip install lit-nlp
74-
```
69+
# To install dependencies for the discriminative AI examples (GLUE, Penguin)
70+
pip install 'lit-nlp[examples-discriminative-ai]'
7571

76-
The `pip` installation will install all necessary prerequisite packages for use
77-
of the core LIT package.
72+
# To install dependencies for the generative AI examples (Prompt Debugging)
73+
pip install 'lit-nlp[examples-generative-ai]'
7874

79-
It **does not** install the prerequisites for the provided demos, so you need to
80-
install those yourself. See
81-
[requirements_examples.txt](./requirements_examples.txt) for the list of
82-
packages required to run the demos.
75+
# To install dependencies for all examples plus the test suite
76+
pip install 'lit-nlp[test]'
77+
```
8378

8479
### Install from source
8580

8681
Clone the repo:
8782

8883
```sh
89-
git clone https://github.com/PAIR-code/lit.git && cd lit
84+
git clone https://github.com/PAIR-code/lit.git
85+
cd lit
9086
```
9187

92-
9388
Note: be sure you are running Python 3.9+. If you have a different version on
9489
your system, use the `conda` instructions below to set up a Python 3.9
9590
environment.
9691

97-
Set up a Python environment with `venv`:
92+
Set up a Python environment with `venv` (or your preferred environment manager).
93+
Note that these instructions assume you will be making code changes to LIT and
94+
includes the full requirements for all examples and the test suite. See the
95+
other optional dependency possibilities in the install with pip section.
9896

9997
```sh
10098
python -m venv .venv
10199
source .venv/bin/activate
100+
python -m pip install -e '.[test]'
102101
```
103102

104-
Or set up a Python environment using `conda`:
103+
The LIT repo does not include a distributable version of the LIT app. You must
104+
build it from source.
105105

106106
```sh
107-
conda create --name lit-nlp
108-
conda activate lit-nlp
109-
conda install python=3.9
110-
conda install pip
111-
```
112-
113-
Once you have the environment, install LIT's dependencies:
114-
```sh
115-
python -m pip install -r requirements.txt
116-
python -m pip install cudnn cupti # optional, for GPU support
117-
python -m pip install torch # optional, for PyTorch
118-
119-
# Build the frontend
120107
(cd lit_nlp; yarn && yarn build)
121108
```
122109

123-
Note: Use the `-r requirements.txt` option to install every dependency required
124-
for the LIT library, its test suite, and the built-in examples. You can also
125-
install subsets of these using the `-r requirements_core.txt` (core library),
126-
`-r requirements_test.txt` (test suite), `-r requirements_examples.txt`
127-
(examples), and/or any combination thereof.
128-
129110
Note: if you see [an error](https://github.com/yarnpkg/yarn/issues/2821)
130111
running `yarn` on Ubuntu/Debian, be sure you have the
131112
[correct version installed](https://yarnpkg.com/en/docs/install#linux-tab).
132113

133-
134114
## Running LIT
135115

136116
Explore a collection of hosted demos on the
137117
[demos page](https://pair-code.github.io/lit/demos).
138118

119+
### Using container images
120+
121+
See the [containerization guide](https://pair-code.github.io/lit/documentation/docker) for instructions on using LIT
122+
locally in Docker, Podman, etc.
123+
124+
LIT also provides pre-built images that can take advantage of accelerators,
125+
making Generative AI and LLM use cases easier to work with. Check out the
126+
[LIT on GCP docs](https://codelabs.developers.google.com/codelabs/responsible-ai/lit-on-gcp)
127+
for more.
128+
139129
### Quick-start: classification and regression
140130

141131
To explore classification and regression models tasks from the popular
@@ -154,7 +144,6 @@ but you can switch to
154144
[STS-B](http://ixa2.si.ehu.es/stswiki/index.php/STSbenchmark) or
155145
[MultiNLI](https://cims.nyu.edu/~sbowman/multinli/) using the toolbar or the
156146
gear icon in the upper right.
157-
```
158147

159148
And navigate to http://localhost:5432 for the UI.
160149

@@ -220,18 +209,19 @@ Google's [Python](https://google.github.io/styleguide/pyguide.html) and
220209

221210
```sh
222211
# Run Pylint on your code using the following command from the root of this repo
223-
pushd lit_nlp & pylint & popd
212+
(cd lit_nlp; pylint)
224213

225214
# Run ESLint on your code using the following command from the root of this repo
226-
pushd lit_nlp & yarn lint & popd
215+
(cd lit_nlp; yarn lint)
227216
```
228217

229218
## Citing LIT
230219

231-
If you use LIT as part of your work, please cite
232-
[our EMNLP paper](https://arxiv.org/abs/2008.05122):
220+
If you use LIT as part of your work, please cite the
221+
[EMNLP paper](https://arxiv.org/abs/2008.05122) or the
222+
[Sequence Salience paper](https://arxiv.org/abs/2404.07498)
233223

234-
```
224+
```BibTeX
235225
@misc{tenney2020language,
236226
title={The Language Interpretability Tool: Extensible, Interactive Visualizations and Analysis for {NLP} Models},
237227
author={Ian Tenney and James Wexler and Jasmijn Bastings and Tolga Bolukbasi and Andy Coenen and Sebastian Gehrmann and Ellen Jiang and Mahima Pushkarna and Carey Radebaugh and Emily Reif and Ann Yuan},
@@ -243,12 +233,22 @@ If you use LIT as part of your work, please cite
243233
}
244234
```
245235

236+
```BibTeX
237+
@article{tenney2024interactive,
238+
title={Interactive prompt debugging with sequence salience},
239+
author={Tenney, Ian and Mullins, Ryan and Du, Bin and Pandya, Shree and Kahng, Minsuk and Dixon, Lucas},
240+
journal={arXiv preprint arXiv:2404.07498},
241+
year={2024}
242+
}
243+
```
244+
246245
## Disclaimer
247246

248247
This is not an official Google product.
249248

250-
LIT is a research project and under active development by a small team. There
251-
will be some bugs and rough edges, but we're releasing at an early stage because
252-
we think it's pretty useful already. We want LIT to be an open platform, not a
253-
walled garden, and we would love your suggestions and feedback - drop us a line
254-
in the [issues](https://github.com/pair-code/lit/issues).
249+
LIT is a research project and under active development by a small team. We want
250+
LIT to be an open platform, not a walled garden, and would love your suggestions
251+
and feedback – please
252+
[report any bugs](https://github.com/pair-code/lit/issues) and reach out on the
253+
[Discussions page](https://github.com/PAIR-code/lit/discussions/landing).
254+

RELEASE.md

+41-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,45 @@
11
# Learning Interpretability Tool Release Notes
22

3+
## Release 1.3
4+
5+
This release updates how the Learning Interpretability Tool (LIT) can be
6+
deployed on Google Cloud. You can now use LIT to interpret foundation
7+
models—including
8+
[Gemini](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference),
9+
[Gemma](https://ai.google.dev/gemma), [Llama](https://www.llama.com/), and
10+
[Mistral](https://mistral.ai/technology/#models)—using LIT's prompt
11+
debugging workflows. LIT now provides public container images to make it easier
12+
to deploy on your hosting platform of choice, with an updated
13+
[tutorial](https://codelabs.developers.google.com/codelabs/responsible-ai/lit-on-gcp)
14+
for deploying LIT with [Cloud Run](https://cloud.google.com/run).
15+
16+
### New Stuff
17+
* LIT on GCP -
18+
[1075325](https://github.com/PAIR-code/lit/commit/1075325c6a08d8fdef3bcf66f193b8d5aef673fb),
19+
[1acc868](https://github.com/PAIR-code/lit/commit/1acc868d4a5fa0fd2a135f132f56bb4cb8ba3990),
20+
[55bfc99](https://github.com/PAIR-code/lit/commit/55bfc993cc27fd25ae5089d58ae822bfeca296a3),
21+
[180f68a](https://github.com/PAIR-code/lit/commit/180f68ad3774f8b276e262c0dcb7307ad87e42a3),
22+
[64114d5](https://github.com/PAIR-code/lit/commit/64114d553ffd2c0ffd7bc674fb32a36e564ea0f4),
23+
[2488aa7](https://github.com/PAIR-code/lit/commit/2488aa7cf8f8a112607ca0c8b40870efde73ec24),
24+
[9baac29](https://github.com/PAIR-code/lit/commit/9baac29b96970ef7fa64f2f36ce2c79ff73707b7),
25+
[60bdc7c](https://github.com/PAIR-code/lit/commit/60bdc7cf382bd0c5ead2576c119277230a6080c9),
26+
[7681476](https://github.com/PAIR-code/lit/commit/7681476d5056d927905f24333b890501a36df040),
27+
[4c81182](https://github.com/PAIR-code/lit/commit/4c81182a7db1fda7f8ba071a9542876f462a13fa),
28+
[4e5e8e2](https://github.com/PAIR-code/lit/commit/4e5e8e25c2abb658dc141f0d9c6059dd41e14535),
29+
[b9a0b82](https://github.com/PAIR-code/lit/commit/b9a0b8210263da9ee6d741e4e0f0444849e3a141),
30+
[424adce](https://github.com/PAIR-code/lit/commit/424adce9cf8c9cbabdf5d89d485cdc5f3fd098ed),
31+
[1d019c7](https://github.com/PAIR-code/lit/commit/1d019c7a1bf5f135ea42104889167b79c3f795cd),
32+
[f4436a2](https://github.com/PAIR-code/lit/commit/f4436a26ed79f481e16e2c53c0551703e7ba8c4f),
33+
34+
### Non-breaking Changes, Bug Fixes, and Enhancements
35+
* Upgrade LIT to MobX v6. - [c1f5055](https://github.com/PAIR-code/lit/commit/c1f5055eb7ee8b3671484c863a0967c05fa58338)
36+
* Fix indexing issue in Sequence Salience module. - [58b1d2](https://github.com/PAIR-code/lit/commit/58b1d2b6d0d27c6dca086520cef45bf75466a101)
37+
* Load multiple model wrappers with shared model. - [ba4d975](https://github.com/PAIR-code/lit/commit/ba4d975a90612b0c41a02b3dcb4dbb548261fdd7)
38+
* Add the custom model and dataset loaders to prompt debugging notebook. - [338c6b](https://github.com/PAIR-code/lit/commit/338c6b12de98b61287a25650ad2c6ad7f7bb80cd)
39+
* Convert hosted demos images to multi-stage builds. - [4bf1f8](https://github.com/PAIR-code/lit/commit/4bf1f81666fe546357f00c86a2315d2852346ebe)
40+
* Adding testing instructions to README. - [f24b841](https://github.com/PAIR-code/lit/commit/f24b841959f0402498a056a5164a86ecae6dbb94)
41+
* More LIT documentation updates. - [2e9d267](https://github.com/PAIR-code/lit/commit/2e9d26738d9344cde0eebd66d49dfc14cd800e74)
42+
343
## Release 1.2
444

545
This release covers clean-ups on various obsolete demos, as well as improved
@@ -270,7 +310,7 @@ A full list of contributors to this repo can be found at https://github.com/PAIR
270310
[a95ed67](https://github.com/PAIR-code/lit/commit/a95ed67100f24163624edb4bb659ccfa871dc9bf)
271311
* Add output embeddings and attention options to GlueConfig -
272312
[6e0df41](https://github.com/PAIR-code/lit/commit/6e0df41636405b4ee5556cbf797fcce5887c6070)
273-
* Allow downloading/copying data from the slice editor -
313+
* Allow downloading/copying data from the slice editor -
274314
[57fac3a](https://github.com/PAIR-code/lit/commit/57fac3aeb98fa49c508b20837eded3f4ec80e8f9)
275315
* Use new custom tooltip elemement in various places -
276316
[d409900](https://github.com/PAIR-code/lit/commit/d409900984336d4f8ac73735b1fff57c92623ca4),
Loading
Loading

docs/documentation/_sources/faq.md.txt

+53
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,56 @@ this, using LIT's `Dataset` objects to manage training data along with standard
171171
training APIs (such as Keras' `model.fit()`). See
172172
[`glue/models.py`](https://github.com/PAIR-code/lit/blob/main/lit_nlp/examples/glue/models.py)
173173
for examples.
174+
175+
### Debug LIT UI in Colab
176+
177+
The LIT instance launched from CLI typically has helpful error messages in the
178+
UI. However, this is not the case for the LIT UI in Colab and the error message
179+
does not report any stacktrace, which makes debugging very difficult.
180+
181+
![LIT UI error in colab](./images/lit-ui-error-in-colab.png "LIT UI error in colab")
182+
183+
While in
184+
[Chrome developer tools](https://support.google.com/campaignmanager/answer/2828688?hl=en),
185+
you will be able to debug issues solely related to the frontend, but not so for
186+
issues related to the backend or on the HTTP request path.
187+
188+
Thus, to show the full stacktrace, you would need to find the HTTP request sent
189+
from the frontend to the backend, compose the same request in colab and send it
190+
to the server.
191+
192+
1. When rendering the UI, display it in a separate tab to make things a bit
193+
easier to work with, e.g. `lit_widget.render(open_in_new_tab=True)`.
194+
2. Open
195+
[Chrome developer tools](https://support.google.com/campaignmanager/answer/2828688?hl=en),
196+
go to "Sources" tab and find the file
197+
[client/services/api_service.ts](https://github.com/PAIR-code/lit/blob/main/lit_nlp/client/services/api_service.ts) and set a
198+
breakpoint right after where the HTTP request is set up in the `queryServer`
199+
method, e.g. after this line `const res = await fetch(url, {method: 'POST',
200+
body});`.
201+
* Note it is possible that the whole frontend source code is compiled into
202+
a `main.js` file, and the code is not exactly the same as that in LIT
203+
frontend source code. You might have to do a bit digging to find the
204+
right line.
205+
3. Go to the UI and trigger the behavior that causes the error. Now in Chrome
206+
developer tools you will be able to see the variables and their values in
207+
the `queryServer` method. Copy the values of the `url` and `body` variables
208+
in the method.
209+
4. Go back to Colab, compose your HTTP request method. Look for the main server
210+
address printed out from `lit_widget.render(open_in_new_tab=True)`.
211+
212+
![LIT colab server address](./images/lit-colab-server-address.png "LIT colab server address")
213+
214+
Let's say the server address is "https://localhost:32943/?" as shown above, the
215+
`body` variable obtained earlier has value "request_body_text" and the `url`
216+
variable has value "./get_preds?param1=value1". Then your HTTP request will be
217+
like this:
218+
219+
```sh
220+
! curl -H "Content-Type: application/json" \
221+
-d "request_body_text" \
222+
-X POST "http://localhost:32943/get_preds?param1=value1"
223+
```
224+
225+
Run this in Colab and you should be able to retrieve the full stacktrace of the
226+
error.

0 commit comments

Comments
 (0)