Skip to content

Commit

Permalink
Merge pull request #82 from PAIR-code/import
Browse files Browse the repository at this point in the history
Update main branch
  • Loading branch information
jameswex authored Oct 21, 2020
2 parents c998735 + 03767e1 commit e984253
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
lit_nlp/node_modules/**
lit_nlp/yarn-error.log
lit_nlp/client/build/**
**/build/**
**/__pycache__/**
**/*.pyc
20 changes: 13 additions & 7 deletions docs/python_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ familarity with the basic [system design](development.md#design-overview) and
the [type system](development.md#type-system).

The following is intended to give a conceptual overview; for the most precise
documentation, see the code in [lit_nlp/api](../lit_nlp/api) and examples
in [lit_nlp/examples](../lit_nlp/examples).
documentation, see the code in [api](../lit_nlp/api)
and [examples](../lit_nlp/examples).

## Adding Models and Data

Expand Down Expand Up @@ -44,7 +44,8 @@ and [`Model`](#models) classes implement this, and provide metadata (see the
[type system](development.md#type-system)) to describe themselves to other
components.

For full examples, see [lit_nlp/examples](../lit_nlp/examples). In particular:
For full examples, see
[examples](../lit_nlp/examples). In particular:

* [`simple_tf2_demo.py`](../lit_nlp/examples/simple_tf2_demo.py)
for a self-contained Keras/TF2 model for sentiment analysis.
Expand Down Expand Up @@ -195,8 +196,8 @@ Note: there are a few additional methods in the model API - see
The above example defined a black-box model, with predictions but no access to
internals. If we want a richer view into the model's behavior, we can add
additional return fields corresponding to hidden-state activations, gradients,
or attention. For example, a BERT-based model with several such features might
have the following `output_spec()`:
word embeddings, or attention. For example, a BERT-based model with several such
features might have the following `output_spec()`:

```py
def output_spec(self):
Expand Down Expand Up @@ -249,9 +250,14 @@ Most such components implement the
[`Interpreter`](../lit_nlp/api/components.py) API.
Conceptually, this is any function that takes a set of datapoints and a model,
and produces some output.[^identity-component] For example,
[local gradient-based salience](../lit_nlp/components/gradient_maps.py)
[local gradient-based salience (GradientNorm)](../lit_nlp/components/gradient_maps.py)
processes the `TokenGradients` and `Tokens` returned by a model and produces a
list of scores for each token.
list of scores for each token. The Integrated Gradients saliency method
additionally requires a `TokenEmbeddings` input and corresponding output, as
well as a label field `Target` to pin the gradient target to the same class as
an input and corresponding output. See the
[GLUE models class](../lit_nlp/examples/models/glue_models.py)
for an example of these spec requirements.

The core API involves implementing the `run()` method:

Expand Down
3 changes: 2 additions & 1 deletion docs/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ Salience maps show the influence of different parts of inputs features on a
model's prediction on the primary selection. This module can contain multiple
methodologies for calculating this salience, depending on the capabilities of
the model being analyzed (e.x. if the model provides gradients, then
gradient-based token-wise salience can be calculated and displayed). The
gradient-based token-wise salience can be calculated and displayed -- see
[adding models and data](python_api.md#adding-models-and-data) for more). The
background of each text piece is colored by the salience of that piece on the
prediction, and hovering on any piece will display the exact value calculated
for that piece.
Expand Down

0 comments on commit e984253

Please sign in to comment.