Overview
This toolkit provides in-context explanations for LLMs - explanations of the output of an LLM in terms of parts of the input context given to the LLM. It will be useful for both researchers and practitioners who want to understand the reason for a particular generation with respect to the context.
The toolkit features explanation methods, quick start and elaborate example notebooks, tests, and documentation. The quick start notebooks can also be run in Google Colab.
Methods
-
Multi-Level Explanations for Generative Language Models: Explains generated text by attributing to parts of the input context and quantifying the importance of these parts to the generation.
-
CELL your Model: Contrastive Explanations for Large Language Models: Explains text generation by generating contrastive prompts (i.e., edited version of the input prompt) that elicit responses that differ from the original response according to a pre-defined score.
-
Token Highlighter: Inspecting and Mitigating Jailbreak Prompts for Large Language Models: Explains potential jailbreak threats by highlighting important prompt tokens based on model gradients.
Download package from pypi
To make use of ICX360, simply install ICX360 from your package manager, e.g. pip or uv:
uv pip install icx360
Download the spacy models for use in the project
uv run python -m spacy download en_core_web_trf
uv run python -m spacy download en_core_web_trf
Download from repo
Prerequisites
The toolkit can be installed locally using the instructions below. Please ensure sufficient resources (such as GPUs) are available for running the methods.
The toolkit uses uv as the package manager (Python 3.11). Make sure that uv is installed via either:
curl -Ls https://astral.sh/uv/install.sh | sh
or using Homebrew:
brew install astral-sh/uv/uv
or using pip (use this if in Windows):
pip install uv
Installation
Once uv is installed, in Linux or Mac, clone the repo:
git clone git@github.com:IBM/ICX360.git icx360
cd icx360
Ensure that you are inside the icx360 directory (where README.md is located) and run:
uv venv --python 3.12
source .venv/bin/activate
uv pip install .
uv run python -m spacy download en_core_web_trf
uv run python -m spacy download en_core_web_trf
Or in Windows, run:
uv venv --python 3.12
.venv/bin/activate
uv pip install .
uv run python -m spacy download en_core_web_trf
uv run python -m spacy download en_core_web_trf
The package has been tested on Red Hat Enterprise Linux 9.
Quickstart Examples
Find many more examples here.
Tests
We have included a collection of tests that can be used for checking if the installation worked properly. This can be achieved by running the "non-slow" tests:
pytest -m "not slow"
Note that these only test the plumbing and not any realistic functionality.
Those interested in testing the realistic functionality can run the notebooks in the ./examples/ folder or run the "slow and not vllm" tests. These use Hugging Face models that are large enough to meaningfully perform their tasks. Please ensure you have sufficient infrastructure (e.g. GPUs) before running these. Run the "slow and not vllm" tests using:
pytest -m "slow and not vllm"
Finally, if you also have a VLLM model that you would like to test, first enter its parameters in model_catalog in tests/conftest.py and then run:
pytest -m "vllm"
License
ICX360 is provided under Apache 2.0 license.
Contributing
- Get started by checking our contribution guidelines.
- If you have any questions, just ask!
Get involved
Lets form a community around this toolkit! Ask a question, raise an issue, or express interest to contribute in the discussions page.
IBM ❤️ Open Source AI
The first release of ICX360 has been brought to you by IBM in the hope of building a larger community around this topic.
Metadata
Release files for icx360 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| icx360-0.1.0.tar.gz | 62.8 kB | Without provenance | Details for icx360-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| icx360-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for icx360-0.1.0-py3-none-any.whl |
Total release size: 154.0 kB
Release files / icx360-0.1.0.tar.gz
| Download URL | icx360-0.1.0.tar.gz |
|---|---|
| Size | 62.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
630951d345e3714c89a43367ff9a1f49d30a056d7f2f66b98b76ec59ea13cdf6
|
|
BLAKE2b-256 checksum How to use checksums |
4dc3047c5719d7f7b99bfb85d9293faab39909008bb6f7b2e4cae299e5cc6e6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.11
|
Release files / icx360-0.1.0-py3-none-any.whl
| Download URL | icx360-0.1.0-py3-none-any.whl |
|---|---|
| Size | 91.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4a8184f220d478b42e55516ea8829e140cc531f50a90aa5a6fbdbb4d39c8051
|
|
BLAKE2b-256 checksum How to use checksums |
c0047a47a997fc971cb8e7a17fd7d89836690c44e7e1df5b31b3ace210a1f0c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.11
|
Security for icx360 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.