Skip to content

harshtiwari01/llm-heatmap-visualizer

Repository files navigation

LLM Heatmap Visualizer 🌡️

GitHub Repo Stars GitHub Forks GitHub Issues GitHub License

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.

Table of Contents

Features ✨

  • 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.

Installation 🛠️

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.

Usage 🚀

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.

Parameters

  • --model: The name of the transformer-based LLM (e.g., gpt-3, bert).
  • --input: The text input to analyze.

Example 📊

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.

Heatmap Example

Contributing 🤝

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.

Steps to Contribute

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/YourFeature).
  3. Make your changes.
  4. Commit your changes (git commit -m 'Add new feature').
  5. Push to the branch (git push origin feature/YourFeature).
  6. Open a pull request.

License 📜

This project is licensed under the MIT License. See the LICENSE file for details.

Contact 📫

For questions or feedback, feel free to reach out:

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!