Name | savis JSON |
Version |
0.4.3
JSON |
| download |
home_page | None |
Summary | A sentence-level visualization tool for attention in large language models |
upload_time | 2024-12-16 11:12:47 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | Copyright (c) 2012-2024 Scott Chacon and others Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
attention
large language models
nlp
visualization
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# SAVIS: Sentence-Level Attention Visualization for Large Language Models
SAVIS (Sentence-level Attention VISualization) is a Python library for visualizing inter-sentence attention in large language models (LLMs). This tool enhances the interpretability of LLMs by providing an intuitive visualization of how attention is distributed across sentences in generated text.
<center>
<img src="https://raw.githubusercontent.com/Seongbuming/savis/master/images/savis.png" width="500" alt="SAVIS analyzing reviews">
</center>
## Features
- Inter-sentence attention calculation
- Interactive visualization of attention patterns
- Support for various LLMs through [Hugging Face](https://huggingface.co)'s `transformers` library
## Installation
```bash
pip install savis
```
## Quick Start
```python
from savis import TextGenerator, ISA, ISAVisualization
# Initialize the text generator with your chosen model
generator = TextGenerator("Model name")
# Generate text and get attention data
input_text = "Your input prompt here"
generated_text, attentions, tokenizer, input_ids, outputs = generator.generate_text(input_text)
# Calculate inter-sentence attention
isa = ISA(outputs.sequences[0], attentions, tokenizer)
# Visualize the attention patterns
vis = ISAVisualization(isa.sentence_attention, isa.sentences)
vis.visualize_sentence_attention()
```
## Key Components
1. `TextGenerator`: Interfaces with the LLM to generate text and extract attention information.
2. `Attention`: Manages the underlying LLM and provides methods for obtaining attention data from the model.
3. `ISA` (Inter-Sentence Attention): Processes raw attention data to compute attention between sentences.
4. `ISAVisualization`: Creates interactive visualizations of the computed inter-sentence attention.
These components work together to provide a comprehensive pipeline from text generation to attention visualization:
- `TextGenerator` uses the LLM to generate text based on input prompts.
- `Attention` handles the interaction with the LLM, extracting detailed attention information.
- `ISA` takes the raw attention data and computes meaningful inter-sentence attention scores.
- `ISAVisualization` takes these scores and creates interactive visualizations.
## License
SAVIS is released under the MIT License. See the [LICENSE](https://github.com/Seongbuming/savis/blob/master/LICENSE) file for more details.
Raw data
{
"_id": null,
"home_page": null,
"name": "savis",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "attention, large language models, nlp, visualization",
"author": null,
"author_email": "Seongbum Seo <seo@seongbum.com>",
"download_url": "https://files.pythonhosted.org/packages/79/38/df1fce6641e4e7826cb3ed09d555d2bef7cf5f24e01065eb3d7e862b697d/savis-0.4.3.tar.gz",
"platform": null,
"description": "# SAVIS: Sentence-Level Attention Visualization for Large Language Models\n\nSAVIS (Sentence-level Attention VISualization) is a Python library for visualizing inter-sentence attention in large language models (LLMs). This tool enhances the interpretability of LLMs by providing an intuitive visualization of how attention is distributed across sentences in generated text.\n\n<center>\n<img src=\"https://raw.githubusercontent.com/Seongbuming/savis/master/images/savis.png\" width=\"500\" alt=\"SAVIS analyzing reviews\">\n</center>\n\n## Features\n\n- Inter-sentence attention calculation\n- Interactive visualization of attention patterns\n- Support for various LLMs through [Hugging Face](https://huggingface.co)'s `transformers` library\n\n## Installation\n\n```bash\npip install savis\n```\n\n## Quick Start\n\n```python\nfrom savis import TextGenerator, ISA, ISAVisualization\n\n# Initialize the text generator with your chosen model\ngenerator = TextGenerator(\"Model name\")\n\n# Generate text and get attention data\ninput_text = \"Your input prompt here\"\ngenerated_text, attentions, tokenizer, input_ids, outputs = generator.generate_text(input_text)\n\n# Calculate inter-sentence attention\nisa = ISA(outputs.sequences[0], attentions, tokenizer)\n\n# Visualize the attention patterns\nvis = ISAVisualization(isa.sentence_attention, isa.sentences)\nvis.visualize_sentence_attention()\n```\n\n## Key Components\n\n1. `TextGenerator`: Interfaces with the LLM to generate text and extract attention information.\n2. `Attention`: Manages the underlying LLM and provides methods for obtaining attention data from the model.\n3. `ISA` (Inter-Sentence Attention): Processes raw attention data to compute attention between sentences.\n4. `ISAVisualization`: Creates interactive visualizations of the computed inter-sentence attention.\n\nThese components work together to provide a comprehensive pipeline from text generation to attention visualization:\n\n- `TextGenerator` uses the LLM to generate text based on input prompts.\n- `Attention` handles the interaction with the LLM, extracting detailed attention information.\n- `ISA` takes the raw attention data and computes meaningful inter-sentence attention scores.\n- `ISAVisualization` takes these scores and creates interactive visualizations.\n\n## License\n\nSAVIS is released under the MIT License. See the [LICENSE](https://github.com/Seongbuming/savis/blob/master/LICENSE) file for more details.\n",
"bugtrack_url": null,
"license": "Copyright (c) 2012-2024 Scott Chacon and others Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "A sentence-level visualization tool for attention in large language models",
"version": "0.4.3",
"project_urls": {
"Bug Tracker": "https://github.com/Seongbuming/savis/issues",
"Documentation": "https://github.com/Seongbuming/savis#readme",
"Homepage": "https://github.com/Seongbuming/savis",
"Repository": "https://github.com/Seongbuming/savis"
},
"split_keywords": [
"attention",
" large language models",
" nlp",
" visualization"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cb2ec9b1af7e7dfdfa5a393f81440b02f86efa05918556df405e8192e397208b",
"md5": "f9435b04e5cd37fb18c088c4171ac29d",
"sha256": "f19e432aa2b9972d93a50d1fae9bc14c6f3e55aad813142705eb0aae4c55cd02"
},
"downloads": -1,
"filename": "savis-0.4.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f9435b04e5cd37fb18c088c4171ac29d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 12201,
"upload_time": "2024-12-16T11:12:42",
"upload_time_iso_8601": "2024-12-16T11:12:42.069221Z",
"url": "https://files.pythonhosted.org/packages/cb/2e/c9b1af7e7dfdfa5a393f81440b02f86efa05918556df405e8192e397208b/savis-0.4.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7938df1fce6641e4e7826cb3ed09d555d2bef7cf5f24e01065eb3d7e862b697d",
"md5": "b5b694fbc9a5691c17d210cfceea790c",
"sha256": "4a0f8ef6fd59db83d781f11524e0726f4ead38ba901c49b699a1ce19efd27bb6"
},
"downloads": -1,
"filename": "savis-0.4.3.tar.gz",
"has_sig": false,
"md5_digest": "b5b694fbc9a5691c17d210cfceea790c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 4870430,
"upload_time": "2024-12-16T11:12:47",
"upload_time_iso_8601": "2024-12-16T11:12:47.238640Z",
"url": "https://files.pythonhosted.org/packages/79/38/df1fce6641e4e7826cb3ed09d555d2bef7cf5f24e01065eb3d7e862b697d/savis-0.4.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-16 11:12:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Seongbuming",
"github_project": "savis",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "savis"
}