| Notebook | Link |
|---|---|
| Logprobs Generation | |
| Token Tree Analysis |
This repository explores the internal stochastic nature of Gemma
models. By extracting transition scores and logits from the Hugging Face
transformers generation loop, we can analyze the model’s
confidence levels and visualize “competing” tokens at each step of the
sequence.
This repository contains no confidential data/IP and is intended for demonstration and research use.
The dynamic thresholding logic in
Token_Tree_Analysis.ipynb adapts how “picky” the model is
about branching based on how busy the search queue currently is.
Where: * is the
calculated probability threshold for the current step. *
is the
min_branch_threshold (e.g., 0.1). * is the
max_branch_threshold (e.g., 0.5). * is the current length of
the queue (number of active paths). *
is the
soft_queue_limit (target number of active paths).
Note: The saturation ratio is capped at 1.0.
soft_queue_limit), the threshold rises toward Logprobs_in_Gemma.ipynb: The main Jupyter Notebook
containing the log probability analysis code, helper functions, and
experiments.Token_Tree_Analysis.ipynb: Notebook for generating and
analyzing token trees.token_tree_analysis/: Contains the visualizer and
sample outputs for the token tree analysis.pip install -U torch transformers pandas accelerate numpy huggingface-hubLogprobs_in_Gemma.ipynb in VS Code or Jupyter
Lab.google/gemma-2-2b-it).Token_Tree_Analysis.ipynb to generate and analyze
token decision trees.You can visualize the generated JSONL data using the Gemma Token Analysis Visualizer.
For analyzing token generation trees, use the Token Tree Visualizer.