From e2398ab4f2298d37806103ca13f3eea05e550a0a Mon Sep 17 00:00:00 2001 From: Gabriele Sarti Date: Wed, 6 Apr 2022 20:48:46 +0200 Subject: [PATCH] Improved documentation (#132) --- .github/workflows/build.yml | 1 + Makefile | 40 +++-- docs/source/_static/inseq.js | 43 ++++- docs/source/_static/style.css | 23 ++- docs/source/_templates/layout.html | 9 -- docs/source/conf.py | 8 +- docs/source/examples/pair_comparison.rst | 67 ++++++++ docs/source/html_outputs/pair_comparison.htm | 46 ++++++ docs/source/html_outputs/winomt_example.htm | 23 +++ docs/source/index.rst | 27 +++- docs/source/main_classes/data_classes.rst | 153 ++++++++++++++++++ .../main_classes/feature_attribution.rst | 76 ++++++++- .../{gradient_attribution.rst => models.rst} | 32 ++-- inseq/attr/feat/__init__.py | 8 + inseq/attr/feat/gradient_attribution.py | 2 + inseq/data/attribution.py | 4 +- pyproject.toml | 2 +- requirements.txt | 142 +++++++++++----- 18 files changed, 595 insertions(+), 111 deletions(-) create mode 100644 docs/source/examples/pair_comparison.rst create mode 100644 docs/source/html_outputs/pair_comparison.htm create mode 100644 docs/source/html_outputs/winomt_example.htm create mode 100644 docs/source/main_classes/data_classes.rst rename docs/source/main_classes/{gradient_attribution.rst => models.rst} (51%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 854be1f8..095b1552 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,7 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v3 with: diff --git a/Makefile b/Makefile index 19ecba33..1dd99f87 100644 --- a/Makefile +++ b/Makefile @@ -9,20 +9,22 @@ VERSION := latest .PHONY: help help: @echo "Commands:" - @echo "poetry-download : downloads and installs the poetry package manager" - @echo "poetry-remove : removes the poetry package manager" - @echo "install : installs required dependencies" - @echo "install-dev : installs the dev dependencies for the project" - @echo "check-style : run checks on all files without fixing them." - @echo "fix-style : run checks on files and potentially modifies them." - @echo "check-safety : run safety checks on all tests." - @echo "lint : run linting on all files (check-style + check-safety)" - @echo "test : run all tests." - @echo "codecov : check coverage of all the code." - @echo "docs : serve generated documentation locally." - @echo "docker-build : builds docker image for the package." - @echo "docker-remove : removes built docker image." - @echo "clean : cleans all unecessary files." + @echo "poetry-download : downloads and installs the poetry package manager" + @echo "poetry-remove : removes the poetry package manager" + @echo "install : installs required dependencies" + @echo "install-dev : installs the dev dependencies for the project" + @echo "check-style : run checks on all files without fixing them." + @echo "fix-style : run checks on files and potentially modifies them." + @echo "check-safety : run safety checks on all tests." + @echo "lint : run linting on all files (check-style + check-safety)" + @echo "test : run all tests." + @echo "codecov : check coverage of all the code." + @echo "build-docs : build sphinx documentation." + @echo "serve-docs : serve documentation locally." + @echo "docs : build and serve generated documentation locally." + @echo "docker-build : builds docker image for the package." + @echo "docker-remove : removes built docker image." + @echo "clean : cleans all unecessary files." #* Poetry .PHONY: poetry-download @@ -89,11 +91,17 @@ codecov: poetry run pytest --cov inseq --cov-report html #* Docs -.PHONY: docs -docs: +.PHONY: build-docs +build-docs: cd docs && make html SPHINXOPTS="-W -j 4" + +.PHONY: serve-docs +serve-docs: cd docs/_build/html && python3 -m http.server 8080 +.PHONY: docs +docs: build-docs serve-docs + #* Docker # Example: make docker VERSION=latest # Example: make docker IMAGE=some_name VERSION=0.1.0 diff --git a/docs/source/_static/inseq.js b/docs/source/_static/inseq.js index 27935f7f..9abe0dc7 100644 --- a/docs/source/_static/inseq.js +++ b/docs/source/_static/inseq.js @@ -1,10 +1,24 @@ function addIcon() { - const inseqLogo = "_static/inseq_logo.png"; + const inseqLogo = "/_static/inseq_logo.png"; + const link = document.createElement("a"); + const indexpath = "/index.html"; + link.setAttribute("href", indexpath); const image = document.createElement("img"); image.setAttribute("src", inseqLogo); + image.setAttribute("alt", "Inseq logo"); + image.style.width = "80%" + image.style.paddingRight = "10%"; + link.appendChild(image); + const desc = document.createElement("p"); + desc.innerHTML = "Interpretability for sequence-to-sequence models 🔍"; + desc.style.color = "black"; + desc.style.paddingLeft = "20px"; + desc.style.paddingTop = "10px"; + desc.style.width = "80%" const div = document.createElement("div"); - div.appendChild(image); + div.appendChild(link); + div.appendChild(desc); div.style.textAlign = 'center'; div.style.paddingTop = '30px'; @@ -40,10 +54,35 @@ function addCustomFooter() { document.querySelector("footer").appendChild(customFooter); } +function resizeHtmlExamples() { + var examples = document.getElementsByClassName("html-example"); + for (const ex of examples) { + const iframe = ex.firstElementChild; + const zoom = iframe.getAttribute("scale") + const origHeight = iframe.contentWindow.document.body.scrollHeight + const origWidth = iframe.contentWindow.document.body.scrollWidth + ex.style.height = ((origHeight * zoom) + 50) + "px"; + const frameHeight = origHeight / zoom + const frameWidth = origWidth / zoom + // add extra 50 pixels - in reality need just a bit more + iframe.style.height = frameHeight + "px" + // set the width of the iframe as the width of the iframe content + iframe.style.width = frameWidth + 'px'; + iframe.style.zoom = zoom; + iframe.style.MozTransform = `scale(${zoom})`; + iframe.style.WebkitTransform = `scale(${zoom})`; + iframe.style.transform = `scale(${zoom})`; + iframe.style.MozTransformOrigin = "0 0"; + iframe.style.WebkitTransformOrigin = "0 0"; + iframe.style.transformOrigin = "0 0"; + } +} + function onLoad() { addIcon(); addCustomFooter(); + resizeHtmlExamples(); } window.addEventListener("load", onLoad); diff --git a/docs/source/_static/style.css b/docs/source/_static/style.css index 14c84d29..d519cc60 100644 --- a/docs/source/_static/style.css +++ b/docs/source/_static/style.css @@ -159,15 +159,11 @@ a { display: inline; vertical-align: middle; margin-right: 16px; - max-width: 200px; + max-width: 160px; width: 100%; margin-bottom: 0; } -.wy-nav-content-wrap { - margin-left: 340px; -} - @media only screen and (max-width: 768px) { .wy-nav-side { @@ -181,15 +177,6 @@ a { .wy-nav-content-wrap.shift { left: 340px; - top: 75px; - } - - .wy-nav-content-wrap { - z-index: 10; - } - - .inseq_header { - display: inline; } } @@ -337,3 +324,11 @@ a.copybtn { font-size: 18px; color: black; } + +.html-example { + width: 100%; +} + +.html-example > iframe { + width: 100%; +} diff --git a/docs/source/_templates/layout.html b/docs/source/_templates/layout.html index 549cdd52..4c92306a 100644 --- a/docs/source/_templates/layout.html +++ b/docs/source/_templates/layout.html @@ -1,13 +1,4 @@ {% extends "!layout.html" %} {% block extrahead %} {% endblock %} {% block extrabody %} -
- -
- {% endblock %} diff --git a/docs/source/conf.py b/docs/source/conf.py index 74d9102f..8403b06b 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -17,8 +17,8 @@ _PATH_ROOT = Path(__file__).parent.parent.parent.absolute() -_PATH_SRC = Path(_PATH_ROOT, "inseq") -sys.path.insert(0, str(_PATH_SRC.absolute())) +# _PATH_SRC = Path(_PATH_ROOT, "inseq") +sys.path.insert(0, str(_PATH_ROOT.absolute())) # -- Project information ----------------------------------------------------- @@ -89,6 +89,9 @@ # The name of the Pygments (syntax highlighting) style to use. pygments_style = None +# Permalinks +html_permalinks_icon = "" + # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True @@ -137,6 +140,7 @@ # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = [ "images", + "html_outputs", "_static", "_static/style.css", "_static/hk-grotesk-pro/HKGroteskPro-Bold.woff2", diff --git a/docs/source/examples/pair_comparison.rst b/docs/source/examples/pair_comparison.rst new file mode 100644 index 00000000..3a35f531 --- /dev/null +++ b/docs/source/examples/pair_comparison.rst @@ -0,0 +1,67 @@ +.. + Copyright 2022 The Inseq Team. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + specific language governing permissions and limitations under the License. + +########################################## +Comparing Attributions with PairAggregator +########################################## + +Inseq support minimal pair analysis via the `PairAggregator `_ component. + +Here is an example of using ``PairAggregator`` to produce a heatmap to visualize the score difference between two ``FeatureAttributionSequenceOutput`` objects: + +.. code-block:: python + + import inseq + from inseq.data.aggregator import AggregatorPipeline, ContiguousSpanAggregator, SequenceAttributionAggregator, PairAggregator + + # Load the EN-FR translation model and attach the IG method + model = inseq.load_model("Helsinki-NLP/opus-mt-en-fr", "integrated_gradients") + + # Perform the attribution with forced decoding. Return convergence deltas, probabilities and target attributions. + out = model.attribute( + [ + "The manager told the hairdresser that the haircut he made her was terrible.", + "The manager told the hairdresser that the haircut he made her was terrible.", + ], + [ + "Le gĂ©rant a dit au coiffeur que la coupe de cheveux qu'il lui a faite Ă©tait terrible.", + "La gĂ©rante a dit au coiffeur que la coupe de cheveux qu'il lui a faite Ă©tait terrible.", + ], + n_steps=300, + return_convergence_delta=True, + attribute_target=True, + output_step_probabilities=True, + internal_batch_size=100, + include_eos_baseline=False, + ) + + # Aggregation pipeline composed by two steps: + # 1. Aggregate contiguous tokens across all attribution dimensions + # 2. Aggregate the last dimension of the neuron-level attribution to make it token-level + squeezesum = AggregatorPipeline([ContiguousSpanAggregator, SequenceAttributionAggregator]) + + # Simply aggregate over the last dimension for the masculine variant + masculine = out.sequence_attributions[0].aggregate(aggregator=SequenceAttributionAggregator) + + # For the feminine variant, we also use the contiguous span aggregator to merge "▁gĂ©rant" "e" + # in a single token to match masculine shape + feminine = out.sequence_attributions[1].aggregate(aggregator=squeezesum, target_spans=(1, 3)) + + # Take the diff of the scores of the two attribution and show it + masculine.show(aggregator=PairAggregator, paired_attr=feminine) + + +.. raw:: html + +
+ +
diff --git a/docs/source/html_outputs/pair_comparison.htm b/docs/source/html_outputs/pair_comparison.htm new file mode 100644 index 00000000..f61dd7a6 --- /dev/null +++ b/docs/source/html_outputs/pair_comparison.htm @@ -0,0 +1,46 @@ +
0th instance:
+ +
+
+
+ +
+
+ Source Saliency Heatmap +
+ x: Generated tokens, y: Attributed tokens +
+ + + +
▁Le → ▁La▁gĂ©rant → ▁gĂ©rante▁a▁dit▁au▁coiffeur▁que▁la▁coupe▁de▁cheveux▁qu'il▁lui▁a▁faite▁était▁terrible.</s>
▁The-0.8150.091-0.0170.0090.066-0.0050.0310.042-0.176-0.0080.045-0.0370.002-0.0050.002-0.013-0.048-0.005-0.006-0.00.0010.001
▁manager0.919-0.576-0.1080.0340.01-0.0050.0280.004-0.0190.0090.0190.0040.009-0.0380.0170.00.006-0.002-0.0020.007-0.001-0.034
▁told-0.251-0.341-0.2210.0170.0090.011-0.039-0.005-0.0020.009-0.014-0.0860.001-0.0280.005-0.0240.004-0.002-0.003-0.0030.0-0.041
▁the0.07-0.1520.1450.0090.0010.0440.001-0.121-0.014-0.0010.001-0.0330.005-0.003-0.004-0.038-0.01-0.014-0.0-0.0010.0-0.006
▁hair-0.025-0.074-0.008-0.0070.0-0.011-0.007-0.014-0.010.0120.001-0.0350.0010.004-0.007-0.0050.004-0.0070.00.0020.0010.002
dress-0.0540.026-0.0010.0030.006-0.055-0.024-0.007-0.0050.010.006-0.013-0.002-0.0-0.005-0.001-0.004-0.0-0.002-0.0010.0010.007
er0.02-0.014-0.010.0030.01-0.0160.013-0.0040.0020.0040.004-0.0010.0040.0040.0030.00.0040.00.0-0.0010.0-0.009
▁that-0.007-0.0790.0560.01-0.013-0.0380.0230.0340.021-0.042-0.0120.102-0.0020.0070.0230.001-0.0030.0050.013-0.002-0.0020.017
▁the0.088-0.03-0.015-0.013-0.027-0.003-0.0060.068-0.102-0.004-0.0280.0010.0230.01-0.0220.0280.006-0.0070.01-0.0070.0010.014
▁hair-0.017-0.0590.0020.0010.001-0.0020.0070.01-0.006-0.0-0.012-0.11-0.0020.010.002-0.0090.007-0.01-0.0010.0020.00.041
cut0.109-0.073-0.016-0.0040.0010.00.0050.0040.0850.041-0.0320.1140.02-0.0070.009-0.0-0.001-0.007-0.0010.004-0.0010.014
▁he-0.323-0.035-0.018-0.0080.0060.0020.017-0.004-0.0070.0070.0010.054-0.031-0.060.016-0.002-0.009-0.0070.002-0.004-0.0010.006
▁made0.055-0.025-0.012-0.0010.00.007-0.001-0.0090.0040.007-0.006-0.029-0.018-0.0270.0160.02-0.0060.01-0.005-0.00.0-0.024
▁her0.03-0.0740.037-0.0140.0120.0040.0040.00.002-0.001-0.007-0.063-0.0020.017-0.03-0.016-0.037-0.0140.001-0.002-0.001-0.037
▁was-0.026-0.0270.058-0.0110.0080.003-0.0050.010.002-0.004-0.0120.0390.0170.012-0.007-0.0190.031-0.001-0.012-0.007-0.0030.014
▁terrible0.070.0010.019-0.005-0.003-0.004-0.0060.0030.0060.0010.0170.0180.0180.0010.0060.008-0.00.0220.014-0.0010.0050.009
.0.008-0.0490.077-0.002-0.002-0.017-0.022-0.008-0.001-0.00.0070.0190.016-0.003-0.0080.015-0.018-0.0050.0060.005-0.0-0.018
</s>0.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.0
deltas0.00.00.0-0.00.00.0-0.0-0.0-0.00.00.0-0.0-0.0-0.0-0.00.0-0.00.0-0.0-0.00.0-0.001
probabilities-0.525-0.080.009-0.003-0.019-0.003-0.023-0.001-0.010.002-0.009-0.001-0.001-0.0-0.020.014-0.0130.0030.001-0.008-0.0010.0
+
+ +
+
+
+ +
0th instance:
+ +
+
+
+ +
+
+ Target Saliency Heatmap +
+ x: Generated tokens, y: Attributed tokens +
+ + + +
▁Le → ▁La▁gĂ©rant → ▁gĂ©rante▁a▁dit▁au▁coiffeur▁que▁la▁coupe▁de▁cheveux▁qu'il▁lui▁a▁faite▁était▁terrible.</s>
▁Le → ▁La0.6120.036-0.066-0.004-0.009-0.0320.0310.105-0.022-0.0170.1170.01-0.012-0.021-0.021-0.042-0.0070.0080.020.0030.041
▁gĂ©rant → ▁gĂ©rante0.4630.0910.007-0.0460.1290.0730.0140.0370.024-0.0380.0310.0180.0080.0130.033-0.0220.0040.013-0.0030.048
▁a-0.0580.0010.0220.0030.0170.0120.00.011-0.0220.002-0.0030.001-0.015-0.007-0.005-0.003-0.00.00.054
▁dit-0.004-0.010.0030.0040.004-0.0010.007-0.019-0.0-0.002-0.001-0.0060.009-0.001-0.00.0020.0-0.005
▁au0.031-0.021-0.0180.058-0.0030.013-0.1030.009-0.0-0.0080.030.005-0.0030.0050.0020.00.018
▁coiffe0.015-0.001-0.0020.0120.004-0.021-0.002-0.002-0.002-0.0010.004-0.005-0.0010.0010.00.011
ur-0.0-0.008-0.001-0.0050.0020.0050.0010.0030.0080.006-0.0010.0010.0-0.0-0.003
▁que0.023-0.008-0.01-0.0030.021-0.005-0.003-0.001-0.007-0.010.0040.0010.0020.024
▁la-0.0940.0340.0180.008-0.0030.004-0.0130.005-0.019-0.002-0.0010.0010.012
▁coupe0.02-0.017-0.026-0.0070.0-0.0190.025-0.016-0.0050.003-0.0-0.018
▁de0.0350.0060.002-0.0060.021-0.032-0.0160.004-0.0080.0010.013
▁cheveux-0.021-0.017-0.00.00.003-0.0060.0020.00.00.031
▁qu0.022-0.0310.0340.0210.025-0.0-0.0030.0020.048
'-0.010.0050.011-0.010.004-0.006-0.0010.02
il0.0440.0110.0020.0-0.0010.0010.02
▁lui-0.019-0.02-0.0050.00.0020.004
▁a0.0460.021-0.0-0.0010.018
▁faite-0.0030.001-0.0-0.028
▁était-0.0050.004-0.036
▁terrible-0.001-0.02
.0.015
</s>
deltas0.00.00.0-0.00.00.0-0.0-0.0-0.00.00.0-0.0-0.0-0.0-0.00.0-0.00.0-0.0-0.00.0-0.001
probabilities-0.525-0.080.009-0.003-0.019-0.003-0.023-0.001-0.010.002-0.009-0.001-0.001-0.0-0.020.014-0.0130.0030.001-0.008-0.0010.0
+
+ +
+
+
+ diff --git a/docs/source/html_outputs/winomt_example.htm b/docs/source/html_outputs/winomt_example.htm new file mode 100644 index 00000000..d9f36b08 --- /dev/null +++ b/docs/source/html_outputs/winomt_example.htm @@ -0,0 +1,23 @@ +
0th instance:
+ +
+
+
+ +
+
+ Source Saliency Heatmap +
+ x: Generated tokens, y: Attributed tokens +
+ + + +
▁Le▁manager▁a▁dit▁au▁coiffeur▁que▁la▁coupe▁de▁cheveux▁qu'il▁lui▁a▁faite▁était▁terrible.</s>
▁The0.9670.6580.437-0.045-0.118-0.237-0.02-0.159-0.173-0.049-0.055-0.005-0.0020.0380.022-0.0080.001-0.0650.0330.057-0.063-0.401
▁manager0.001-0.3540.068-0.005-0.022-0.0210.157-0.001-0.0450.0110.0850.219-0.067-0.1780.0290.0010.135-0.031-0.0560.019-0.0280.427
▁told0.2320.620.8390.9810.051-0.0660.036-0.09-0.0450.0270.2190.489-0.051-0.328-0.0070.0080.2490.037-0.024-0.008-0.0030.602
▁the0.013-0.1140.2760.1330.9860.128-0.6420.6080.092-0.0070.0980.020.167-0.08-0.013-0.059-0.1680.042-0.0210.0380.015-0.027
▁hair-0.0060.0080.0230.0310.0640.221-0.163-0.004-0.054-0.0320.1490.3790.037-0.147-0.147-0.013-0.0240.044-0.0180.0140.0330.115
dress0.023-0.0660.038-0.0060.0340.827-0.36-0.0170.005-0.0660.1520.075-0.041-0.011-0.030.007-0.0490.0310.035-0.0120.0060.063
er0.0060.0170.021-0.0010.0240.376-0.4760.045-0.017-0.0290.0280.075-0.0-0.021-0.0450.013-0.0230.0110.0260.002-0.0130.09
▁that0.0450.0010.0430.0690.0480.21-0.0510.615-0.035-0.065-0.0250.1150.0-0.216-0.027-0.059-0.0080.0490.036-0.015-0.0610.204
▁the-0.015-0.103-0.067-0.0470.038-0.028-0.1460.4540.5950.193-0.0960.0090.4060.018-0.01-0.0390.0540.3760.026-0.031-0.007-0.056
▁hair-0.019-0.006-0.0280.0160.0050.0180.053-0.007-0.0330.1350.0430.6950.018-0.243-0.028-0.032-0.013-0.073-0.0370.0290.0120.183
cut-0.012-0.0050.0090.0060.0010.033-0.0090.0510.7610.9490.8740.2340.1270.1290.110.0370.0960.3370.034-0.0170.0150.183
▁he0.0320.0180.0060.0240.0040.028-0.0590.0230.0850.1150.0410.0090.7620.5970.7770.1130.291-0.0220.0350.0320.0340.024
▁made-0.0190.1040.0310.021-0.0170.006-0.027-0.001-0.0860.042-0.1470.0360.0930.4680.350.180.8160.789-0.186-0.005-0.010.111
▁her0.0090.105-0.0950.0460.0130.0110.0510.012-0.013-0.036-0.0590.0640.0110.208-0.430.8240.2630.2610.037-0.015-0.0060.14
▁was-0.0060.053-0.0340.074-0.0070.003-0.0320.0340.013-0.1020.197-0.0160.4070.164-0.2210.487-0.0370.0910.8530.022-0.3260.159
▁terrible0.004-0.010.0340.031-0.0080.003-0.1190.050.052-0.0460.202-0.0020.1330.067-0.011-0.126-0.036-0.1550.4470.9510.0270.13
.0.083-0.062-0.0410.030.003-0.034-0.3610.05-0.01-0.0290.066-0.022-0.0930.239-0.013-0.107-0.2310.0420.1520.2930.939-0.287
</s>0.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.0
deltas-0.00.0-0.00.0-0.0-0.001-0.0-0.00.00.0-0.001-0.0020.0-0.00.0-0.00.0010.00.00.0-0.00.0
probabilities0.6550.2570.7020.7910.7620.960.9280.8350.6250.8480.5410.9250.7350.9060.8890.5940.4060.650.8360.6980.8980.899
+
+ +
+
+
+ diff --git a/docs/source/index.rst b/docs/source/index.rst index 21b30c08..d49c7d25 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -24,17 +24,34 @@ Here is an example of using Inseq to attribute an English-to-Italian translation import inseq - model = inseq.load_model("Helsinki-NLP/opus-mt-en-it", "integrated_gradients") + model = inseq.load_model("Helsinki-NLP/opus-mt-en-fr", "integrated_gradients") out = model.attribute( - "The developer argued with the designer because she did not like the design.", - return_convergence_delta=True, - n_steps=100 + "The developer argued with the designer because she did not like the design.", + n_steps=300, + return_convergence_delta=True, + output_step_probabilities=True, + internal_batch_size=100, + include_eos_baseline=False, ) out.show() +.. raw:: html + +
+ +
+ + .. toctree:: :maxdepth: 2 + :caption: Using 🐛 Inseq + + examples/pair_comparison + +.. toctree:: + :maxdepth: 4 :caption: Main Classes + main_classes/models + main_classes/data_classes main_classes/feature_attribution - main_classes/gradient_attribution diff --git a/docs/source/main_classes/data_classes.rst b/docs/source/main_classes/data_classes.rst new file mode 100644 index 00000000..44ce503e --- /dev/null +++ b/docs/source/main_classes/data_classes.rst @@ -0,0 +1,153 @@ +.. + Copyright 2022 The Inseq Team. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + specific language governing permissions and limitations under the License. + +Data Classes +======================================================================================================================= + +TensorWrapper +----------------------------------------------------------------------------------------------------------------------- + +.. autoclass:: inseq.data.data_utils.TensorWrapper + :members: + +Batching +----------------------------------------------------------------------------------------------------------------------- + +BatchEncoding +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.data.batch.BatchEncoding + :members: + + +BatchEmbedding +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.data.batch.BatchEmbedding + :members: + + +Batch +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.data.batch.Batch + :members: + + +EncoderDecoderBatch +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.data.batch.EncoderDecoderBatch + :members: + + +Attributions +----------------------------------------------------------------------------------------------------------------------- + +FeatureAttributionSequenceOutput +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.data.attribution.FeatureAttributionSequenceOutput + :members: + + +FeatureAttributionStepOutput +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.data.attribution.FeatureAttributionStepOutput + :members: + + +FeatureAttributionOutput +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.data.attribution.FeatureAttributionOutput + :members: + +Gradient-based Attribution +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +GradientFeatureAttributionSequenceOutput +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + + +.. autoclass:: inseq.data.attribution.GradientFeatureAttributionSequenceOutput + :members: + + +GradientFeatureAttributionStepOutput +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + + +.. autoclass:: inseq.data.attribution.GradientFeatureAttributionStepOutput + :members: + + +Aggregators +----------------------------------------------------------------------------------------------------------------------- + + +DispatchableDict +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.data.aggregator.DispatchableDict + :members: + + +Aggregator +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.data.aggregator.Aggregator + :members: + + +AggregatorPipeline +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.data.aggregator.AggregatorPipeline + :members: + + +AggregableMixin +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.data.aggregator.AggregableMixin + :members: + + +SequenceAttributionAggregator +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.data.aggregator.SequenceAttributionAggregator + :members: + + +ContiguousSpanAggregator +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.data.aggregator.ContiguousSpanAggregator + :members: + + +SubwordAggregator +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.data.aggregator.SubwordAggregator + :members: + + +PairAggregator +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.data.aggregator.PairAggregator + :members: diff --git a/docs/source/main_classes/feature_attribution.rst b/docs/source/main_classes/feature_attribution.rst index d24ed8ca..facdc9f8 100644 --- a/docs/source/main_classes/feature_attribution.rst +++ b/docs/source/main_classes/feature_attribution.rst @@ -10,8 +10,82 @@ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. +Feature Attribution +======================================================================================================================= + + FeatureAttribution -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +----------------------------------------------------------------------------------------------------------------------- .. autoclass:: inseq.attr.FeatureAttribution :members: + + +Gradient Attribution +----------------------------------------------------------------------------------------------------------------------- + +.. autoclass:: inseq.attr.feat.GradientAttribution + :members: + + +DeepLiftAttribution +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.attr.feat.DeepLiftAttribution + :members: + + +DiscretizedIntegratedGradientsAttribution +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. warning:: + The DiscretizedIntegratedGradientsAttribution class is currently not functioning and needs fixing. + +.. autoclass:: inseq.attr.feat.DiscretizedIntegratedGradientsAttribution + :members: + + +IntegratedGradientsAttribution +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.attr.feat.IntegratedGradientsAttribution + :members: + + +InputXGradientAttribution +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.attr.feat.InputXGradientAttribution + :members: + + +SaliencyAttribution +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: inseq.attr.feat.SaliencyAttribution + :members: + + +Layer Attribution Methods +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + + +LayerIntegratedGradientsAttribution +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +.. autoclass:: inseq.attr.feat.LayerIntegratedGradientsAttribution + :members: + + +LayerGradientXActivationAttribution +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' +.. autoclass:: inseq.attr.feat.LayerGradientXActivationAttribution + :members: + + +LayerDeepLiftAttribution +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +.. autoclass:: inseq.attr.feat.LayerDeepLiftAttribution + :members: diff --git a/docs/source/main_classes/gradient_attribution.rst b/docs/source/main_classes/models.rst similarity index 51% rename from docs/source/main_classes/gradient_attribution.rst rename to docs/source/main_classes/models.rst index f70174a6..893d5922 100644 --- a/docs/source/main_classes/gradient_attribution.rst +++ b/docs/source/main_classes/models.rst @@ -1,5 +1,5 @@ .. - Copyright 2021 The Inseq Team. All rights reserved. + Copyright 2022 The Inseq Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -10,32 +10,18 @@ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -Gradient Attribution ------------------------------------------------------------------------------------------------------------------------ - -GradientAttribution -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. autoclass:: inseq.attr.feat.GradientAttribution - :members: - - -IntegratedGradientsAttribution -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Models +======================================================================================================================= -.. autoclass:: inseq.attr.feat.IntegratedGradientsAttribution - :members: - - -InputXGradientAttribution -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +AttributionModel +----------------------------------------------------------------------------------------------------------------------- -.. autoclass:: inseq.attr.feat.InputXGradientAttribution +.. autoclass:: inseq.models.AttributionModel :members: -SaliencyAttribution -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +HuggingfaceModel +----------------------------------------------------------------------------------------------------------------------- -.. autoclass:: inseq.attr.feat.SaliencyAttribution +.. autoclass:: inseq.models.HuggingfaceModel :members: diff --git a/inseq/attr/feat/__init__.py b/inseq/attr/feat/__init__.py index 5ec1af67..b7f491c6 100644 --- a/inseq/attr/feat/__init__.py +++ b/inseq/attr/feat/__init__.py @@ -1,9 +1,13 @@ from .feature_attribution import FeatureAttribution, list_feature_attribution_methods from .gradient_attribution import ( + DeepLiftAttribution, DiscretizedIntegratedGradientsAttribution, GradientAttribution, InputXGradientAttribution, IntegratedGradientsAttribution, + LayerDeepLiftAttribution, + LayerGradientXActivationAttribution, + LayerIntegratedGradientsAttribution, SaliencyAttribution, ) @@ -12,8 +16,12 @@ "FeatureAttribution", "list_feature_attribution_methods", "GradientAttribution", + "DeepLiftAttribution", "InputXGradientAttribution", "IntegratedGradientsAttribution", "DiscretizedIntegratedGradientsAttribution", "SaliencyAttribution", + "LayerIntegratedGradientsAttribution", + "LayerGradientXActivationAttribution", + "LayerDeepLiftAttribution", ] diff --git a/inseq/attr/feat/gradient_attribution.py b/inseq/attr/feat/gradient_attribution.py index 78967a51..df78b21f 100644 --- a/inseq/attr/feat/gradient_attribution.py +++ b/inseq/attr/feat/gradient_attribution.py @@ -127,7 +127,9 @@ def __init__(self, attribution_model, **kwargs): class DiscretizedIntegratedGradientsAttribution(GradientAttribution): """Discretized Integrated Gradients attribution method + Reference: https://arxiv.org/abs/2108.13654 + Original implementation: https://github.com/INK-USC/DIG """ diff --git a/inseq/data/attribution.py b/inseq/data/attribution.py index 1244d222..1aea6453 100644 --- a/inseq/data/attribution.py +++ b/inseq/data/attribution.py @@ -42,8 +42,8 @@ class FeatureAttributionSequenceOutput(TensorWrapper, AggregableMixin): Output produced by a standard attribution method. Attributes: - source (list of :class:`~inseq.utils.typing.TokenWithId): Tokenized source sequence. - target (list of :class:`~inseq.utils.typing.TokenWithId): Tokenized target sequence. + source (list of :class:`~inseq.utils.typing.TokenWithId`): Tokenized source sequence. + target (list of :class:`~inseq.utils.typing.TokenWithId`): Tokenized target sequence. source_attributions (:obj:`SequenceAttributionTensor`): Tensor of shape (`source_len`, `target_len`) plus an optional third dimension if the attribution is granular (e.g. gradient attribution) containing the attribution scores produced at each generation step of diff --git a/pyproject.toml b/pyproject.toml index 78663d5a..a07012a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,6 +66,7 @@ isort = {extras = ["colors"], version = "^5.10.1"} mypy = "^0.910" mypy-extensions = "^0.4.3" pre-commit = "^2.17.0" +poethepoet = "^0.13.1" pydocstyle = "^6.1.1" pylint = "^2.12.2" pytest = "^6.2.5" @@ -79,7 +80,6 @@ sphinx-copybutton = "^0.4.0" sphinx-gitstamp = "^0.3.2" sphinx-markdown-tables = "^0.0.15" sphinx-rtd-theme = "^1.0.0" -poethepoet = "^0.13.1" [tool.poe.tasks] torch-cpu = "python -m pip install torch==1.11.0+cpu -f https://download.pytorch.org/whl/torch_stable.html" diff --git a/requirements.txt b/requirements.txt index 5cd6f985..3bb8660f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,38 +1,108 @@ -captum==0.4.0; python_version >= "3.6" -certifi==2021.5.30; python_full_version >= "3.6.0" -charset-normalizer==2.0.4; python_version >= "3" and python_full_version >= "3.6.0" -click==7.1.2; python_full_version >= "3.6.0" and python_version >= "3.6" -colorama==0.4.4; python_version >= "3.6" and python_full_version >= "3.6.0" and python_version < "4.0" and platform_system == "Windows" -commonmark==0.9.1; python_version >= "3.6" and python_version < "4.0" -cycler==0.10.0; python_version >= "3.7" -filelock==3.0.12; python_full_version >= "3.6.0" -huggingface-hub==0.0.17; python_full_version >= "3.6.0" -idna==3.2; python_version >= "3.5" and python_full_version >= "3.6.0" -joblib==1.0.1; python_version >= "3.6" and python_full_version >= "3.6.0" -kiwisolver==1.3.2; python_version >= "3.7" -matplotlib==3.4.3; python_version >= "3.7" -numpy==1.21.1; python_version >= "3.7" -packaging==21.0; python_version >= "3.6" and python_full_version >= "3.6.0" -pandas==1.3.3; python_full_version >= "3.7.1" and python_version >= "3.6" -pillow==8.3.2; python_version >= "3.7" -protobuf==3.17.3; python_full_version >= "3.6.0" -pygments==2.10.0; python_version >= "3.6" and python_version < "4.0" -pyparsing==2.4.7; python_version >= "3.6" and python_full_version >= "3.6.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.7") -python-dateutil==2.8.2; python_full_version >= "3.7.1" and python_version >= "3.7" -pytz==2021.1; python_full_version >= "3.7.1" and python_version >= "3.6" -pyyaml==5.4.1; python_full_version >= "3.6.0" -regex==2021.8.28; python_full_version >= "3.6.0" -requests==2.26.0; python_full_version >= "3.6.0" -rich==10.9.0; python_version >= "3.6" and python_version < "4.0" -sacremoses==0.0.45; python_full_version >= "3.6.0" -scipy==1.6.1; python_version >= "3.7" +appnope==0.1.2; platform_system == "Darwin" and python_version >= "3.8" and sys_platform == "darwin" +argon2-cffi-bindings==21.2.0; python_version >= "3.6" +argon2-cffi==21.3.0; python_version >= "3.6" +asttokens==2.0.5; python_version >= "3.8" +attrs==21.4.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7" +backcall==0.2.0; python_version >= "3.8" +beautifulsoup4==4.10.0; python_full_version > "3.0.0" and python_version >= "3.7" +bleach==4.1.0; python_version >= "3.7" +captum==0.4.1; python_version >= "3.6" +certifi==2021.10.8; python_full_version >= "3.6.0" +cffi==1.15.0; implementation_name == "pypy" and python_version >= "3.7" +charset-normalizer==2.0.12; python_version >= "3" and python_full_version >= "3.6.0" +click==8.1.1; python_version >= "3.7" and python_full_version >= "3.6.0" +colorama==0.4.4; python_version >= "3.6" and python_full_version >= "3.6.2" and python_full_version < "4.0.0" and (python_version >= "3.7" and python_full_version < "3.0.0" and platform_system == "Windows" or platform_system == "Windows" and python_version >= "3.7" and python_full_version >= "3.5.0") and platform_system == "Windows" and (python_version >= "3.8" and python_full_version < "3.0.0" and sys_platform == "win32" or sys_platform == "win32" and python_version >= "3.8" and python_full_version >= "3.5.0") +commonmark==0.9.1; python_full_version >= "3.6.2" and python_full_version < "4.0.0" +cycler==0.11.0; python_version >= "3.7" +debugpy==1.6.0; python_version >= "3.7" +decorator==5.1.1; python_version >= "3.8" +defusedxml==0.7.1; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7" +entrypoints==0.4; python_version >= "3.7" +executing==0.8.3; python_version >= "3.8" +filelock==3.6.0; python_version >= "3.7" and python_full_version >= "3.6.0" +fonttools==4.31.2; python_version >= "3.7" +huggingface-hub==0.4.0; python_full_version >= "3.6.0" +idna==3.3; python_version >= "3.5" and python_full_version >= "3.6.0" +importlib-resources==5.6.0; python_version < "3.9" and python_version >= "3.7" +ipykernel==6.10.0; python_version >= "3.7" +ipython-genutils==0.2.0; python_version >= "3.6" +ipython==8.2.0; python_version >= "3.8" +ipywidgets==7.7.0 +jedi==0.18.1; python_version >= "3.8" +jinja2==3.1.1; python_version >= "3.7" +joblib==1.1.0; python_version >= "3.7" and python_full_version >= "3.6.0" +json-tricks==3.15.5 +jsonschema==4.4.0; python_version >= "3.7" +jupyter-client==7.2.1; python_full_version >= "3.7.0" and python_version >= "3.7" +jupyter-core==4.9.2; python_version >= "3.7" +jupyterlab-pygments==0.1.2; python_version >= "3.7" +jupyterlab-widgets==1.1.0; python_version >= "3.6" +kiwisolver==1.4.2; python_version >= "3.7" +markupsafe==2.1.1; python_version >= "3.7" +matplotlib-inline==0.1.3; python_version >= "3.8" +matplotlib==3.5.1; python_version >= "3.7" +mistune==0.8.4; python_version >= "3.7" +nbclient==0.5.13; python_full_version >= "3.7.0" and python_version >= "3.7" +nbconvert==6.4.5; python_version >= "3.7" +nbformat==5.2.0; python_full_version >= "3.7.0" and python_version >= "3.7" +nest-asyncio==1.5.4; python_full_version >= "3.7.0" and python_version >= "3.7" +notebook==6.4.10; python_version >= "3.6" +numpy==1.22.3; python_version >= "3.8" +packaging==21.3; python_version >= "3.7" and python_full_version >= "3.6.0" +pandas==1.4.1; python_version >= "3.8" +pandocfilters==1.5.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7" +parso==0.8.3; python_version >= "3.8" +pexpect==4.8.0; sys_platform != "win32" and python_version >= "3.8" +pickleshare==0.7.5; python_version >= "3.8" +pillow==9.0.1; python_version >= "3.7" +prometheus-client==0.13.1; python_version >= "3.6" +prompt-toolkit==3.0.28; python_full_version >= "3.6.2" and python_version >= "3.8" +protobuf==3.19.4; python_version >= "3.5" +psutil==5.9.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7" +ptyprocess==0.7.0; sys_platform != "win32" and python_version >= "3.8" and os_name != "nt" +pure-eval==0.2.2; python_version >= "3.8" +py==1.11.0; python_version >= "3.7" and python_full_version < "3.0.0" and implementation_name == "pypy" or implementation_name == "pypy" and python_version >= "3.7" and python_full_version >= "3.5.0" +pycparser==2.21; python_version >= "3.7" and python_full_version < "3.0.0" and implementation_name == "pypy" or implementation_name == "pypy" and python_version >= "3.7" and python_full_version >= "3.4.0" +pygments==2.11.2; python_full_version >= "3.6.2" and python_full_version < "4.0.0" and python_version >= "3.8" +pyparsing==3.0.7; python_version >= "3.7" and python_full_version >= "3.6.0" +pyrsistent==0.18.1; python_version >= "3.7" +python-dateutil==2.8.2; python_version >= "3.8" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.8" +pytz==2022.1; python_version >= "3.8" +pywin32==303; sys_platform == "win32" and platform_python_implementation != "PyPy" and python_version >= "3.7" +pywinpty==2.0.5; os_name == "nt" and python_version >= "3.7" +pyyaml==6.0; python_version >= "3.6" and python_full_version >= "3.6.0" +pyzmq==22.3.0; python_version >= "3.7" +regex==2022.3.15; python_version >= "3.6" and python_full_version >= "3.6.0" +requests==2.27.1; python_full_version >= "3.6.0" +rich==10.16.2; python_full_version >= "3.6.2" and python_full_version < "4.0.0" +sacremoses==0.0.49; python_full_version >= "3.6.0" +scikit-learn==1.0.2; python_version >= "3.7" +scipy==1.8.0; python_version >= "3.8" and python_version < "3.11" seaborn==0.11.2; python_version >= "3.6" -sentencepiece==0.1.91; python_full_version >= "3.6.0" +send2trash==1.8.0; python_version >= "3.6" +sentencepiece==0.1.96 +setuptools-scm==6.4.2; python_version >= "3.7" shellingham==1.4.0; python_version >= "3.6" -six==1.16.0; python_full_version >= "3.6.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.7") -tokenizers==0.10.3; python_full_version >= "3.6.0" -torch==1.9.0; python_full_version >= "3.6.2" -transformers==4.10.2; python_full_version >= "3.6.0" -typer==0.3.2; python_version >= "3.6" -typing-extensions==3.10.0.2; python_full_version >= "3.6.2" and python_version >= "3.6" -urllib3==1.26.6; python_full_version >= "3.6.0" and python_version < "4" +six==1.16.0; python_full_version >= "3.6.0" and python_version >= "3.7" and (python_version >= "3.8" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.8") and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.7") +sklearn==0.0 +soupsieve==2.3.1; python_full_version > "3.0.0" and python_version >= "3.7" +stack-data==0.2.0; python_version >= "3.8" +terminado==0.13.3; python_version >= "3.7" +testpath==0.6.0; python_version >= "3.7" +threadpoolctl==3.1.0; python_version >= "3.7" +tokenizers==0.11.6; python_full_version >= "3.6.0" +tomli==2.0.1; python_version >= "3.7" +torch==1.11.0; python_full_version >= "3.7.0" +torchtyping==0.1.4; python_full_version >= "3.7.0" +tornado==6.1; python_version >= "3.7" +tqdm==4.63.1; python_full_version >= "3.6.0" +traitlets==5.1.1; python_full_version >= "3.7.0" and python_version >= "3.8" +transformers==4.17.0; python_full_version >= "3.6.0" +typeguard==2.13.3; python_full_version >= "3.7.0" +typer==0.4.1; python_version >= "3.6" +typing-extensions==4.1.1; python_full_version >= "3.7.0" and python_version >= "3.6" +urllib3==1.26.9; python_full_version >= "3.6.0" and python_version < "4" +wcwidth==0.2.5; python_full_version >= "3.6.2" and python_version >= "3.8" +webencodings==0.5.1; python_version >= "3.7" +widgetsnbextension==3.6.0 +zipp==3.7.0; python_version < "3.9" and python_version >= "3.7"