Skip to content

Commit 61faeb6

Browse files
authored
Merge pull request #1530 from PAIR-code/dev
Updating website
2 parents d10bd71 + 011a02f commit 61faeb6

Some content is hidden

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

52 files changed

+1483
-1436
lines changed

docs/demos/coref.html

-5
This file was deleted.

docs/demos/images.html

-5
This file was deleted.

docs/demos/index.html

-55
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,6 @@
9898
<div class="demo-card-copy">Analyze a tabular data model with LIT, including exploring partial dependence plots and automatically finding counterfactuals.</div>
9999
<div class="demo-card-cta-button"><a href="/lit/demos/penguins.html"></a></div>
100100
</div>
101-
<div class="demo-card mdl-cell mdl-cell--6-col mdl-cell--4-col-tablet mdl-cell--4-col-phone">
102-
<div class="demo-card-title"><a href="/lit/demos/images.html" target="_blank">Image classification</a></div>
103-
<div class="demo-card-tags"> <span class="demo-tag"> images </span> <span class="demo-tag"> multiclass classification </span>
104-
</div>
105-
<div class="demo-card-data-source-title">DATA SOURCES</div>
106-
<div class="demo-card-data-source">
107-
Imagenette
108-
</div>
109-
<div class="demo-card-copy">Analyze an image classification model with LIT, including multiple image salience techniques.</div>
110-
<div class="demo-card-cta-button"><a href="/lit/demos/images.html"></a></div>
111-
</div>
112101
<div class="demo-card mdl-cell mdl-cell--6-col mdl-cell--4-col-tablet mdl-cell--4-col-phone">
113102
<div class="demo-card-title"><a href="/lit/demos/glue.html" target="_blank">Classification and regression models</a></div>
114103
<div class="demo-card-tags"> <span class="demo-tag"> BERT </span> <span class="demo-tag"> binary classification </span> <span class="demo-tag"> multi-class classification </span> <span class="demo-tag"> regression </span>
@@ -130,50 +119,6 @@
130119
</div>
131120
<div class="demo-card-copy">Use LIT directly inside a Colab notebook. Explore binary classification for sentiment analysis using SST2 from the General Language Understanding Evaluation (GLUE) benchmark suite.</div>
132121
<div class="demo-card-cta-button"><a href="https://colab.research.google.com/github/PAIR-code/lit/blob/main/lit_nlp/examples/notebooks/LIT_sentiment_classifier.ipynb"></a></div>
133-
</div>
134-
<div class="demo-card mdl-cell mdl-cell--6-col mdl-cell--4-col-tablet mdl-cell--4-col-phone">
135-
<div class="demo-card-title"><a href="/lit/demos/coref.html" target="_blank">Gender bias in coreference systems</a></div>
136-
<div class="demo-card-tags"> <span class="demo-tag"> BERT </span> <span class="demo-tag"> coreference </span> <span class="demo-tag"> fairness </span> <span class="demo-tag"> Winogender </span>
137-
</div>
138-
<div class="demo-card-data-source-title">DATA SOURCES</div>
139-
<div class="demo-card-data-source">
140-
Winogender schemas
141-
</div>
142-
<div class="demo-card-copy">Use LIT to explore gendered associations in a coreference system, which matches pronouns to their antecedents. This demo highlights how LIT can work with structured prediction models (edge classification), and its capability for disaggregated analysis.</div>
143-
<div class="demo-card-cta-button"><a href="/lit/demos/coref.html"></a></div>
144-
</div>
145-
<div class="demo-card mdl-cell mdl-cell--6-col mdl-cell--4-col-tablet mdl-cell--4-col-phone">
146-
<div class="demo-card-title"><a href="/lit/demos/lm.html" target="_blank">Fill in the blanks</a></div>
147-
<div class="demo-card-tags"> <span class="demo-tag"> BERT </span> <span class="demo-tag"> masked language model </span>
148-
</div>
149-
<div class="demo-card-data-source-title">DATA SOURCES</div>
150-
<div class="demo-card-data-source">
151-
Stanford Sentiment Treebank, Movie Reviews
152-
</div>
153-
<div class="demo-card-copy">Explore a BERT-based masked-language model. See what tokens the model predicts should fill in the blank when any token from an example sentence is masked out.</div>
154-
<div class="demo-card-cta-button"><a href="/lit/demos/lm.html"></a></div>
155-
</div>
156-
<div class="demo-card mdl-cell mdl-cell--6-col mdl-cell--4-col-tablet mdl-cell--4-col-phone">
157-
<div class="demo-card-title"><a href="/lit/demos/t5.html" target="_blank">Text generation</a></div>
158-
<div class="demo-card-tags"> <span class="demo-tag"> T5 </span> <span class="demo-tag"> generation </span>
159-
</div>
160-
<div class="demo-card-data-source-title">DATA SOURCES</div>
161-
<div class="demo-card-data-source">
162-
CNN / Daily Mail
163-
</div>
164-
<div class="demo-card-copy">Use a T5 model to summarize text. For any example of interest, quickly find similar examples from the training set, using an approximate nearest-neighbors index.</div>
165-
<div class="demo-card-cta-button"><a href="/lit/demos/t5.html"></a></div>
166-
</div>
167-
<div class="demo-card mdl-cell mdl-cell--6-col mdl-cell--4-col-tablet mdl-cell--4-col-phone">
168-
<div class="demo-card-title"><a href="/lit/demos/is_eval.html" target="_blank">Evaluating input salience methods</a></div>
169-
<div class="demo-card-tags"> <span class="demo-tag"> BERT </span> <span class="demo-tag"> salience </span> <span class="demo-tag"> evaluation </span>
170-
</div>
171-
<div class="demo-card-data-source-title">DATA SOURCES</div>
172-
<div class="demo-card-data-source">
173-
Stanford Sentiment Treebank, Toxicity
174-
</div>
175-
<div class="demo-card-copy">Explore the faithfulness of input salience methods on a BERT-base model across different datasets and artificial shortcuts.</div>
176-
<div class="demo-card-cta-button"><a href="/lit/demos/is_eval.html"></a></div>
177122
</div>
178123
</div>
179124
</div>

docs/demos/is_eval.html

-5
This file was deleted.

docs/demos/lm.html

-5
This file was deleted.

docs/demos/t5.html

-5
This file was deleted.
-184 KB
Binary file not shown.
-89.5 KB
Binary file not shown.
Loading
-144 KB
Binary file not shown.
Binary file not shown.
-248 KB
Binary file not shown.
122 KB
Loading

docs/documentation/_sources/api.md.txt

+29-31
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# LIT Python API
22

3-
<!--* freshness: { owner: 'lit-dev' reviewed: '2023-08-23' } *-->
3+
<!--* freshness: { owner: 'lit-dev' reviewed: '2024-06-24' } *-->
44

55
<!-- [TOC] placeholder - DO NOT REMOVE -->
66

@@ -349,7 +349,7 @@ list of scores for each token. The Integrated Gradients saliency method
349349
additionally requires a `TokenEmbeddings` input and corresponding output, as
350350
well as a label field `Target` to pin the gradient target to the same class as
351351
an input and corresponding output. See the
352-
[GLUE models class](https://github.com/PAIR-code/lit/blob/main/lit_nlp/examples/models/glue_models.py)
352+
[GLUE models class](https://github.com/PAIR-code/lit/blob/main/lit_nlp/examples/glue/models.py)
353353
for an example of these spec requirements.
354354

355355
The core API involves implementing the `run()` method:
@@ -675,7 +675,7 @@ Each `LitType` subclass encapsulates its own semantics (see
675675
* A field that appears in _both_ the model's input and output specs is assumed
676676
to represent the same value. This pattern is used for model-based input
677677
manipulation. For example, a
678-
[language model](https://github.com/PAIR-code/lit/blob/main/lit_nlp/examples/models/pretrained_lms.py)
678+
[language model](https://github.com/PAIR-code/lit/blob/main/lit_nlp/examples/glue/models.py)
679679
might output `'tokens': lit_types.Tokens(...)`, and accept as (optional)
680680
input `'tokens': lit_types.Tokens(required=False, ...)`. An interpretability
681681
component could take output from the former, swap one or more tokens (e.g.
@@ -712,11 +712,9 @@ this can cause jitter (UI modules appearing, disappearing, reordering, resizing,
712712
etc.) when switching between models or datasets with heterogeneous `Spec`s.
713713

714714
When implementing your own LIT components and modules, you can use
715-
[`utils.find_spec_keys()`][utils-lib]
716-
(Python) and
717-
[`findSpecKeys()`][utils-lib]
718-
(TypeScript) to identify fields of interest in a `Spec`. These methods recognize
719-
and respect subclasses. For example,
715+
[`utils.find_spec_keys()`][utils-lib-py] (Python) and
716+
[`findSpecKeys()`][utils-lib] (TypeScript) to identify fields of interest in a
717+
`Spec`. These methods recognize and respect subclasses. For example,
720718
`utils.find_spec_keys(spec, Scalar)` will also match any `RegressionScore`
721719
fields, but `utils.find_spec_keys(spec, RegressionScore)` will not return all
722720
`Scalar` fields in the `Spec`.
@@ -807,8 +805,13 @@ _See the [examples](https://github.com/PAIR-code/lit/blob/main/lit_nlp/examples)
807805

808806
### Available types
809807

810-
The full set of `LitType`s is defined in [types.py](https://github.com/PAIR-code/lit/blob/main/lit_nlp/api/types.py). Numeric types such as `Integer` and `Scalar` have predefined ranges that can be overridden using corresponding `min_val` and `max_val` attributes as seen [here](https://github.com/PAIR-code/lit/blob/main/lit_nlp/examples/datasets/penguin_data.py;l=19-22;rcl=574999438). The different types available in LIT are summarized
811-
in the table below.
808+
The full set of `LitType`s is defined in
809+
[types.py](https://github.com/PAIR-code/lit/blob/main/lit_nlp/api/types.py). Numeric types
810+
such as `Integer` and `Scalar` have predefined ranges that can be overridden
811+
using corresponding `min_val` and `max_val` attributes as seen in
812+
[penguin data](https://github.com/PAIR-code/lit/blob/main/lit_nlp/examples/penguin/data.py)
813+
`INPUT_SPEC`. The different types available in LIT are summarized in the table
814+
below.
812815

813816
Note: Bracket syntax, such as `<float>[num_tokens]`, refers to the shapes of
814817
NumPy arrays where each element inside the brackets is an integer.
@@ -859,7 +862,7 @@ naming collisions with protected TypeScript keywords.*
859862
Some properties of the LIT frontend can be configured from Python as
860863
**arguments to `dev_server.Server()`**. These include:
861864

862-
* `page_title`: set a custom page title, such as "Coreference Demo".
865+
* `page_title`: set a custom page title.
863866
* `canonical_url`: set a "canonical" URL (such as a shortlink) that will be
864867
used as the base when copying links from the LIT UI.
865868
* `default_layout`: set the default UI layout, by name. See `layout.ts` and
@@ -886,22 +889,16 @@ You can specify custom web app layouts from Python via the `layouts=` attribute.
886889
The value should be a `Mapping[str, LitCanonicalLayout]`, such as:
887890

888891
```python
889-
LM_LAYOUT = layout.LitCanonicalLayout(
892+
PENGUIN_LAYOUT = layout.LitCanonicalLayout(
890893
upper={
891-
"Main": [
892-
modules.EmbeddingsModule,
894+
'Main': [
895+
modules.DiveModule,
893896
modules.DataTableModule,
894897
modules.DatapointEditorModule,
895898
]
896899
},
897-
lower={
898-
"Predictions": [
899-
modules.LanguageModelPredictionModule,
900-
modules.ConfusionMatrixModule,
901-
],
902-
"Counterfactuals": [modules.GeneratorModule],
903-
},
904-
description="Custom layout for language models.",
900+
lower=layout.STANDARD_LAYOUT.lower,
901+
description='Custom layout for the Palmer Penguins demo.',
905902
)
906903
```
907904

@@ -912,14 +909,12 @@ lit_demo = dev_server.Server(
912909
models,
913910
datasets,
914911
# other args...
915-
layouts={"lm": LM_LAYOUT},
912+
layouts=layout.DEFAULT_LAYOUTS | {'penguins': PENGUIN_LAYOUT},
913+
default_layout='penguins',
916914
**server_flags.get_flags())
917915
return lit_demo.serve()
918916
```
919917

920-
For a full example, see
921-
[`lm_demo.py`](https://github.com/PAIR-code/lit/blob/main/lit_nlp/examples/lm_demo.py).
922-
923918
You can see the pre-configured layouts provided by LIT, as well as the list of
924919
modules that can be included in your custom layout in
925920
[`layout.py`](https://github.com/PAIR-code/lit/blob/main/lit_nlp/api/layout.py). A
@@ -989,15 +984,15 @@ needing to reload the server or click the UI.
989984
For example, to view examples in a dataset:
990985

991986
```python
992-
from lit_nlp.examples.datasets import glue
993-
dataset = glue.SST2Data('validation')
987+
from lit_nlp.examples.glue import data as glue_data
988+
dataset = glue_data.SST2Data('validation')
994989
print(dataset.examples) # list of records {"sentence": ..., "label": ...}
995990
```
996991

997992
And to run inference on a few of them:
998993

999994
```python
1000-
from lit_nlp.examples.models import glue_models
995+
from lit_nlp.examples.glue import models as glue_models
1001996

1002997
model = glue_models.SST2Model("/path/to/model/files")
1003998
preds = list(model.predict(dataset.examples[:5]))
@@ -1021,16 +1016,19 @@ For a full working example in Colab, see [LIT_components_example.ipynb](https://
10211016
<!-- Links -->
10221017

10231018
[build-metadata]: https://github.com/PAIR-code/lit/blob/main/lit_nlp/app.py
1024-
[components-py]: https://github.com/PAIR-code/lit/blob/main/lit_nlp/api/dataset.py
1019+
[components-py]: https://github.com/PAIR-code/lit/blob/main/lit_nlp/api/components.py
10251020
[curves-interp]: https://github.com/PAIR-code/lit/blob/main/lit_nlp/components/curves.py
10261021
[dataset-py]: https://github.com/PAIR-code/lit/blob/main/lit_nlp/api/dataset.py
10271022
[grad-maps]: https://github.com/PAIR-code/lit/blob/main/lit_nlp/components/gradient_maps.py
10281023
[json]: https://www.json.org
10291024
[mnli-dataset]: https://cims.nyu.edu/~sbowman/multinli/
1025+
10301026
[mnli-demo]: https://pair-code.github.io/lit/demos/glue.html
1031-
[model-py]: https://github.com/PAIR-code/lit/blob/main/lit_nlp/api/dataset.py
1027+
1028+
[model-py]: https://github.com/PAIR-code/lit/blob/main/lit_nlp/api/model.py
10321029
[should_display_module]: https://github.com/PAIR-code/lit/blob/main/lit_nlp/client/core/lit_module.ts
10331030
[types_py]: https://github.com/PAIR-code/lit/blob/main/lit_nlp/api/types.py
10341031
[types_ts]: https://github.com/PAIR-code/lit/blob/main/lit_nlp/client/lib/lit_types.ts
10351032
[utils-lib]: https://github.com/PAIR-code/lit/blob/main/lit_nlp/client/lib/utils.ts
1033+
[utils-lib-py]: https://github.com/PAIR-code/lit/blob/main/lit_nlp/lib/utils.py
10361034
[word-replacer]: https://github.com/PAIR-code/lit/blob/main/lit_nlp/components/word_replacer.py

0 commit comments

Comments
 (0)