A tool for understanding and exploring the internal mechanisms of Large Language Models (LLMs) through multiple explanation methods.
X-LLM provides comprehensive explanations of how different language models (GPT-2, OPT, Pythia) process and understand information. By analyzing both transformer attention patterns and feed-forward network activations, this tool enables researchers and enthusiasts to gain insights into these complex systems.
- Multiple Model Support: Currently supports GPT-2, OPT, and Pythia models
- Dual Explanation Methods:
- Transformer-based Explanations: Analyze how attention heads focus on word relationships
- FFN-based Explanations: Understand feed-forward network activations and word importance
- Interactive UI: Built with Streamlit for easy exploration
- Retrieval-Augmented Generation (RAG): Uses semantic search to find relevant explanations based on user queries
- Conversational Interface: Chat-based interaction with the system
- Database: PostgreSQL for storing model explanations
- Embedding Model: SentenceTransformer for semantic similarity search
- LLM Agent: GPT-4o-mini for generating human-friendly responses
- Web Framework: Streamlit for the user interface
- Python 3.11+
- PostgreSQL server
- OpenAI API key
-
Clone the repository:
git clone https://github.com/Secrisx/XLLM_app.git cd XLLM_app -
Install dependencies:
pip install -r requirements.txt
-
Create a
.envfile with your OpenAI API key:OPENAI_API_KEY=your_api_key_here
Start the Streamlit app:
streamlit run app.py