Skip to main content
Ecco Logo

Ecco is a python library for explaining Natural Language Processing models using interactive visualizations.

It provides multiple interfaces to aid the explanation and intuition of Transformer-based language models. Read: Interfaces for Explaining Transformer Language Models.

Ecco runs inside Jupyter notebooks. It is built on top of pytorch and transformers.

The library is currently an alpha release of a research project. Not production ready. You’re welcome to contribute to make it better!

Installation

# Assuming you had PyTorch previously installed
pip install ecco

Documentation

To use the project:

import ecco

# Load pre-trained language model. Setting 'activations' to True tells Ecco to capture neuron activations.
lm = ecco.from_pretrained('distilgpt2', activations=True)

# Input text
text = "The countries of the European Union are:\n1. Austria\n2. Belgium\n3. Bulgaria\n4."

# Generate 20 tokens to complete the input text.
output = lm.generate(text, generate=20, do_sample=True)

# Ecco will output each token as it is generated.

# 'output' now contains the data captured from this run, including the input and output tokens
# as well as neuron activations and input saliency values.

# To view the input saliency
output.saliency()

This does the following:

  1. It loads a pretrained Huggingface DistilGPT2 model. It wraps it an ecco LM object that does useful things (e.g. it calculates input saliency, can collect neuron activations).

  2. We tell the model to generate 20 tokens.

  3. The model returns an ecco OutputSeq object. This object holds the output sequence, but also a lot of data generated by the generation run, including the input sequence and input saliency values. If we set activations=True in from_pretrained(), then this would also contain neuron activation values.

  4. output can now produce various interactive explorables. Examples include:

# To view the input saliency explorable
output.saliency()

# to view input saliency with more details (a bar and % value for each token)
output.saliency(style="detailed")

# output.activations contains the neuron activation values. it has the shape: (layer, neuron, token position)

# We can run non-negative matrix factorization using run_nmf. We pass the number of factors/components to break down into
nmf_1 = output.run_nmf(n_components=10)

# nmf_1 now contains the necessary data to create the interactive nmf explorable:
nmf_1.explore()

Changelog

0.0.8 (2020-11-20)

  • Allowing the project some fresh air.

Release files for ecco 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ecco 0.1.2
File Size Uploaded
ecco-0.1.2.tar.gz 65.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ecco 0.1.2
File Interpreter ABI Platform
ecco-0.1.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 136.3 kB

Release files / ecco-0.1.2.tar.gz

Download URL ecco-0.1.2.tar.gz
Size 65.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b0b280b3214f19fca28a74aec0e0c332693ccd3f621b79102dac69f902e1ffb2
BLAKE2b-256 checksum
How to use checksums
4fcf1b46e334f671d8e0c978526c990d225d8afef4d635ba2dfc33bfc7fcc8d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / ecco-0.1.2-py2.py3-none-any.whl

Download URL ecco-0.1.2-py2.py3-none-any.whl
Size 70.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
34f2a2ba7b93c30318edab31bdb878ba43177b4b373cff0af1cefcdda0d5bc57
BLAKE2b-256 checksum
How to use checksums
27817e3283e1f42435588cd6e1adfa56646b47c8512583ad7d4d82c147b8d5c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.14

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page