# 🔬 GPT-2 Token Similarity Visualizer!

**URL:** <https://discuss.streamlit.io/t/gpt-2-token-similarity-visualizer/119766>\
**Category:** Show the Community!\
**Tags:** gpt2, transformers, nlp, interpretability, streamlit-cloud\
**Created:** [October 11, 2025, 5:34pm UTC](https://discuss.streamlit.io/t/gpt-2-token-similarity-visualizer/119766 "2025-10-11T17:34:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SiddhantSadangi](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/siddhantsadangi/32/68895_2.png) [@SiddhantSadangi](https://discuss.streamlit.io/u/SiddhantSadangi)\
**Post date:** [October 11, 2025, 5:34pm UTC](https://discuss.streamlit.io/t/gpt-2-token-similarity-visualizer/119766/1 "2025-10-11T17:34:47Z")

</div>

# GPT-2 Token Similarity Visualizer

[![Open in Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg) ](https://gpt2-token-similarity.streamlit.app/)

A Streamlit application for visualizing token similarity relationships across GPT-2 layers. This is a Python fork of the original React-based visualizer from [@KhoomeiK/gpt2-explorer](https://github.com/KhoomeiK/gpt2-explorer/tree/main/visualizer) that provides an interactive “microscope” into how language models process and understand text.

## What This App Does

This tool helps you understand how GPT-2 processes text by visualizing the relationships between tokens across different layers. It’s particularly valuable for:

- **🧠 Understanding Language Model Internals** : See how semantic relationships between tokens evolve as they’re processed through different GPT-2 layers
- **🔬 Research & Interpretability** : Debug model behavior, analyze attention patterns, and study how different prompts affect internal representations
- **🎓 Educational Use** : Demonstrate how transformers work visually and teach AI concepts through interactive exploration
- **🛠 Practical Applications** : Optimize prompts, debug model behavior, and identify unexpected token associations

## Features

- **Interactive Graphs** : Pan, zoom, and hover for activation details
- **Layer Exploration** : See how token relationships evolve across layers
- **Adjustable Parameters** : Threshold, neighbor limits, node size, and edge width
- **Multiple Metrics** : Cosine similarity and dot product
- **Color Schemes** : Position-based or activation-based
- **Real-time Statistics** : Graph density and similarity stats
- **Token Search** : Find and highlight specific tokens in the graph
- **Auto-play** : Animate through layers automatically

**GitHub repo:** [SiddhantSadangi/gpt2-token-similarity: Streamlit app for exploring how language models process text through interactive graphs, layer-by-layer analysis, and real-time token relationship mapping. Perfect for AI research, education, and model interpretability.](https://github.com/SiddhantSadangi/gpt2-token-similarity)

**I’d love your feedback!**

⭐ Star the repo if you find this useful

💬 Drop a comment with feature requests or improvements

🔧 Submit PRs for any enhancements you’d like to contribute

---

<div class="post-metadata">

**Author:** ![KATE\_INA](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/kate_ina/32/55311_2.png) [@KATE\_INA](https://discuss.streamlit.io/u/KATE_INA)\
**Post date:** [October 19, 2025, 5:24pm UTC](https://discuss.streamlit.io/t/gpt-2-token-similarity-visualizer/119766/2 "2025-10-19T17:24:49Z")

</div>

I like your app, its nice and educative.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [April 17, 2026, 5:25pm UTC](https://discuss.streamlit.io/t/gpt-2-token-similarity-visualizer/119766/3 "2026-04-17T17:25:46Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
