Welcome to the LLM Heatmap Visualizer! This repository contains a collection of scripts designed to generate full attention-head heatmaps for transformer-based Large Language Models (LLMs). Heatmaps provide a visual representation of how attention is distributed across different heads in a transformer model, allowing for better understanding and evaluation of LLMs.
- Generate attention-head heatmaps for various transformer-based LLMs.
- Easy-to-use scripts that require minimal setup.
- Support for multiple LLM frameworks.
- Visualize attention distributions to gain insights into model behavior.
- Export heatmaps in various formats for reports and presentations.
To get started, clone this repository to your local machine:
git clone https://github.com/harshtiwari01/llm-heatmap-visualizer.git
cd llm-heatmap-visualizer
Next, install the required dependencies. You can do this using pip
:
pip install -r requirements.txt
Make sure you have Python 3.7 or higher installed. If you don't have it yet, you can download it from python.org.
To generate heatmaps, you need to download the necessary scripts from the Releases section. Once you have the scripts, you can execute them as follows:
python generate_heatmap.py --model <model_name> --input <input_text>
Replace <model_name>
with the name of the LLM you want to analyze and <input_text>
with the text input for which you want to visualize the attention.
--model
: The name of the transformer-based LLM (e.g.,gpt-3
,bert
).--input
: The text input to analyze.
Here's a simple example of how to generate a heatmap:
python generate_heatmap.py --model gpt-3 --input "What is the capital of France?"
This command will generate a heatmap showing how the model attends to different parts of the input text. The output will be saved in the output/
directory.
We welcome contributions! If you have ideas for improvements or new features, feel free to fork the repository and submit a pull request. Please make sure to follow the guidelines in CONTRIBUTING.md
.
- Fork the repository.
- Create a new branch (
git checkout -b feature/YourFeature
). - Make your changes.
- Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature/YourFeature
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE
file for details.
For questions or feedback, feel free to reach out:
- Author: Harsh Tiwari
- Email: harsh@example.com
- GitHub: harshtiwari01
Thank you for checking out the LLM Heatmap Visualizer! For the latest updates and releases, visit the Releases section. Your contributions and feedback are valuable to us!