jorgemarcc/graphcodebert-interpretability
0
1---2title: Code Similarity Visualization with GraphCodeBERT3emoji: ๐ง 4colorFrom: gray5colorTo: blue6sdk: gradio7sdk_version: 5.38.08app_file: app.py9pinned: false10license: mit11short_description: Augmenting the Interpretability of GraphCodeBERT12---13 14# Code Similarity Visualization with GraphCodeBERT15 16This interactive application visualizes token-level embeddings generated by [GraphCodeBERT](https://huggingface.co/microsoft/graphcodebert-base) for classical sorting algorithms. It supports pairwise comparison of algorithms based on their representation in the modelโs embedding space, using PCA for dimensionality reduction.17 18## โ๏ธ Reference19 20Martinez-Gil, J. (2025). 21**Augmenting the Interpretability of GraphCodeBERT for Code Similarity Tasks**. 22*International Journal of Software Engineering and Knowledge Engineering*, 35(05), 657โ678.23 24## ๐ Features25 26- Select two classical sorting algorithms.27- Automatic tokenization and embedding via GraphCodeBERT.28- PCA-based projection into 2D space for visualization.29- Clear matplotlib plots showing token-level distribution differences.30 31## ๐ง Technical Overview32 33- **Model**: [`microsoft/graphcodebert-base`](https://huggingface.co/microsoft/graphcodebert-base)34- **Embedding Layer**: Last hidden state35- **Reduction**: Principal Component Analysis (PCA)36- **Interface**: Gradio37- **Languages**: Python 3.10+38 39## ๐ Dependencies40 41All required libraries are listed in `requirements.txt`:42 43```44 45transformers46torch47scikit-learn48numpy49matplotlib50gradio51Pillow52 53```54 55## ๐ฅ๏ธ Intended Use56 57- Academic teaching and demonstration of code embeddings58- Qualitative evaluation of pretrained models for source code59- Supplementary visualization for software engineering publications60 61## ๐ฌ Contact62 63**Jorge Martinez-Gil** 64Senior Research Scientist in Computer Science