A desktop-first (Java Swing) project that makes Transformer mechanics explicit and inspectable.
This project is intentionally not built with PyTorch, JAX, or Transformers libraries. It is meant to make the mechanics visible — not hidden behind abstractions.
This is not a production LLM implementation.
Tokenization, attention and logits are intentionally simulated and are not compatible with real trained models.
It is a visual simulator designed to help you understand the flow:
- text input
- tokenization
- (simulated) attention
- (simulated) logits
- decoding
- final response
Yes, Swing is old.
That’s fine.
Modern frameworks are great at hiding complexity. This project does the opposite: it tries to show what’s going on.
Swing keeps state changes visible. Nothing happens “by magic” behind the scenes.
That makes it a good fit for a step-by-step, inspectable simulator.
It’s also:
- deterministic,
- easy to ship as a single desktop tool,
- well suited for an “instrument panel” style UI (tokens, matrices, logits, decoding trace).
- Token view: shows tokens and ids.
- Attention view (simulated): displays an attention matrix (NxN) per step.
- Logits view (simulated): displays top-k “logits” and probabilities.
- Decode trace: shows decoding decisions step-by-step.
- Reproducible: seeded simulation so the same input yields the same “fake” internals.
src/main/java/.../ui— Swing UI panelssrc/main/java/.../core— tokenizer, simulator, decoding logicsrc/main/java/.../backend— pluggable backend interface (mock by default)
- Java 17+
- Gradle
Gradle is only required for building the project. End users do not need Gradle.
gradle run- Go to the Releases section of this repository.
- Download the file:
swing-transformer.jar. - Run it using one of the options below.
Option A — Any OS
java -jar swing-transformer.jarOption B — Shortcut
Windows: double-click run.bat
Linux / macOS: ./run.sh
Windows users,
run.batonly executes:java -jar swing-transformer.jar
No files are modified, no network access is performed, and no administrative privileges are required.
This project is intentionally not:
- a full LLM implementation
- a training framework
- a performance benchmark
- a replacement for real inference engines
Its goal is understanding, not optimization.
- Run the application.
- Enter a short prompt (one sentence is enough).
- Click Run.
- Inspect:
- how text is tokenized,
- how attention matrices change per step,
- how logits influence decoding,
- how the final response is formed token by token.
Many modern frameworks optimize for performance and abstraction. This project goes in the opposite direction.
It exists to make internal states visible, even if that means being slower, simpler, or less "realistic" than production systems.
This project was developed by an engineer and data scientist with a background in:
- Postgraduate degree in Data Science and Analytics (USP)
- Bachelor's degree in Computer Engineering (UERJ)
- Special interest in statistical models, interpretability, and applied AI