Skip to content

Mattbusel/Every-Other-Token

Repository files navigation

Every Other Token (Rust)

A real-time LLM stream mutator and token-visualization engine built in Rust.

Rust MIT License OpenAI API

Every Other Token Output

“Every token tells a story. Every other token tells a different one.”


What is it?

Every Other Token intercepts OpenAI’s streaming API token-by-token and mutates every other one in real time. Instead of treating prompts like static text, it invites you to see, touch, and reshape the token stream as it flows.

Built in Rust for speed, reliability, and next-gen research.


What Can It Do?

  • Transform every other token: reverse, uppercase, mock, noise
  • Visualize token roles with color-coded Visual Mode
  • Highlight token-level salience with Heatmap Mode
  • Real-time mutation of OpenAI responses
  • Designed for LLM interpretability, creativity, and stream manipulation

Quick Start — GUI .exe Version (No Rust Required!)

Instructions:

  1. Download the ZIP and extract the EveryOtherToken folder.

  2. Double-click EveryOtherToken.bat.

  3. When prompted:

    • Enter your OpenAI API Key (e.g., sk-...)
    • Type your prompt (e.g., "Tell me a story")
    • Choose a transformation (1–4)
    • Choose a model (e.g., GPT-3.5 or 4)
    • Enable visual mode (Y/n)
    • Enable heatmap mode (Y/n)

What you’ll see:

 Every Other Token - GUI Version
==================================

 Enter your OpenAI API Key: 
 Enter your prompt: Tell me a story
 Choose a transformation: [1] Reverse, [2] Uppercase, [3] Mock, [4] Noise
 Choose a model: [1] GPT-3.5 Turbo, [2] GPT-4 Turbo, [3] GPT-4
 Enable visual mode? (y/n): y
 Enable heatmap mode? (y/n): y

[Beautiful, real-time color-coded output appears]

You are now seeing the language model think, one token at a time.


Researcher Edition — CLI (for Rust users)

Prerequisites

  • Rust 1.70 or higher
  • OpenAI API key (get one from OpenAI)

Install & Build

git clone https://github.com/Mattbusel/Every-Other-Token
cd every-other-token-rust
cargo build --release

CLI Usage

cargo run -- "Prompt here" [transform] [model] [--visual] [--heatmap]

Examples:

cargo run -- "Tell me a story about a robot"
cargo run -- "Explain quantum physics" uppercase
cargo run -- "Write a haiku" mock gpt-4
cargo run -- "What is consciousness?" reverse --visual --heatmap

Visual Mode

  • Color-codes even vs odd tokens
  • Even tokens: unchanged (normal)
  • Odd tokens: transformed (bright cyan + bold)

Heatmap Mode

Shows importance of each token based on:

  • Token position
  • Length
  • Word type
  • Syntactic/semantic clues
Color Meaning
🔴 Bright Red Most important (0.8–1.0)
🟠 Red High importance (0.6–0.8)
🟡 Yellow Medium (0.4–0.6)
🔵 Blue Low (0.2–0.4)
⚪ White Minimal (0.0–0.2)

Available Transformations

Transform Effect Example (input: hello world)
reverse Reverses odd tokens hello dlrow
uppercase Uppercases odd tokens hello WORLD
mock Alternating case hello WoRlD
noise Adds junk characters hello w0rld$

Why This Matters

Every Other Token is a playground for:

  • LLM interpretability & token dependency research
  • Creative mutation of AI output
  • Robustness & semantic degradation testing
  • Real-time token flow control

It’s not just a toy — it’s a research microscope.


Performance

Rust implementation offers extreme efficiency:

  • 60% lower latency than Python
  • ~10k tokens/sec throughput
  • 90% lower memory usage Great for long prompts or batch testing

Suggested Use Cases

Semantic Fragility

cargo run -- "What is the capital of France?" noise --visual

LLM Error Behavior

cargo run -- "Solve: 87 * 45 =" reverse

Co-Creative Mutation

cargo run -- "Write a love poem to the moon" mock

Attention Visualization

cargo run -- "Explain how transformers work" --heatmap

Contributing

Pull requests welcome!

  1. Fork the repo
  2. Create a new branch
  3. Code or tweak a transformation
  4. Test it
  5. Submit a PR


Credits & Thanks

  • Inspired by token-level control research
  • Built in Rust with ❤️
  • Thanks to OpenAI and the Rust async ecosystem

Releases

No releases published

Packages

No packages published

Languages