1+ #!/usr/bin/env python3
2+ """Generate final demo showing all bumplot improvements."""
3+
4+ import sys
5+ sys .path .insert (0 , '/Users/jmanning/quantum-conversations/code' )
6+
7+ from quantum_conversations import ParticleFilter , TokenSequenceVisualizer , ModelManager
8+ import matplotlib .pyplot as plt
9+ from pathlib import Path
10+
11+ # Create output directory
12+ output_dir = Path ("bumplot_final" )
13+ output_dir .mkdir (exist_ok = True )
14+
15+ print ("Generating final demo visualizations with all improvements..." )
16+ print ("=" * 60 )
17+
18+ model_manager = ModelManager ()
19+
20+ # Test Case 1: Small example to see all improvements clearly
21+ print ("\n 1. Small example (20 particles)" )
22+ pf = ParticleFilter (
23+ model_name = "EleutherAI/pythia-70m" ,
24+ n_particles = 20 ,
25+ temperature = 0.7 ,
26+ device = "cpu" ,
27+ model_manager = model_manager ,
28+ seed = 42
29+ )
30+
31+ particles = pf .generate ("The future is" , max_new_tokens = 10 )
32+ viz = TokenSequenceVisualizer (tokenizer = pf .tokenizer )
33+
34+ fig = viz .visualize_bumplot (
35+ particles ,
36+ output_path = str (output_dir / "final_demo_small.png" ),
37+ max_vocab_display = 8 ,
38+ show_tokens = True ,
39+ colormap = 'RdYlGn' ,
40+ figsize = (16 , 10 )
41+ )
42+ plt .close (fig )
43+ print (f"✓ Saved: { output_dir } /final_demo_small.png" )
44+
45+ # Test Case 2: Medium complexity to show transparency
46+ print ("\n 2. Medium complexity (50 particles)" )
47+ pf = ParticleFilter (
48+ model_name = "EleutherAI/pythia-70m" ,
49+ n_particles = 50 ,
50+ temperature = 0.8 ,
51+ device = "cpu" ,
52+ model_manager = model_manager ,
53+ seed = 42
54+ )
55+
56+ particles = pf .generate ("Hello world" , max_new_tokens = 12 )
57+ viz = TokenSequenceVisualizer (tokenizer = pf .tokenizer )
58+
59+ fig = viz .visualize_bumplot (
60+ particles ,
61+ output_path = str (output_dir / "final_demo_medium.png" ),
62+ max_vocab_display = 10 ,
63+ show_tokens = True ,
64+ colormap = 'RdYlGn' ,
65+ figsize = (16 , 10 )
66+ )
67+ plt .close (fig )
68+ print (f"✓ Saved: { output_dir } /final_demo_medium.png" )
69+
70+ # Test Case 3: High divergence
71+ print ("\n 3. High divergence (100 particles)" )
72+ pf = ParticleFilter (
73+ model_name = "EleutherAI/pythia-70m" ,
74+ n_particles = 100 ,
75+ temperature = 1.2 ,
76+ device = "cpu" ,
77+ model_manager = model_manager ,
78+ seed = 42
79+ )
80+
81+ particles = pf .generate ("Once upon a" , max_new_tokens = 12 )
82+ viz = TokenSequenceVisualizer (tokenizer = pf .tokenizer )
83+
84+ fig = viz .visualize_bumplot (
85+ particles ,
86+ output_path = str (output_dir / "final_demo_divergent.png" ),
87+ max_vocab_display = 12 ,
88+ show_tokens = True ,
89+ colormap = 'RdYlGn' ,
90+ figsize = (18 , 10 )
91+ )
92+ plt .close (fig )
93+ print (f"✓ Saved: { output_dir } /final_demo_divergent.png" )
94+
95+ print ("\n " + "=" * 60 )
96+ print ("ALL IMPROVEMENTS IMPLEMENTED:" )
97+ print ("=" * 60 )
98+ print ("✓ No overshooting (sigmoid transitions)" )
99+ print ("✓ No gaps (overlapping segments)" )
100+ print ("✓ No out-of-range curves (clamped to max_vocab_display)" )
101+ print ("✓ Clear transparency (alpha=0.1)" )
102+ print ("✓ Uniform font size (12pt, 10pt for long tokens)" )
103+ print ("✓ Opaque token backgrounds" )
104+ print ("✓ Smart text colors (white/black based on background)" )
105+ print ("✓ Large axis labels (18pt)" )
106+ print ("✓ Large tick labels (14pt)" )
107+ print ("✓ Colorbar at x=0.88 with 0%/100% labels" )
108+ print ("✓ Proper y-axis padding (0.3 to max+0.8)" )
109+ print ("✓ Max token length 15 chars" )
110+ print ("\n Final visualizations saved to: bumplot_final/" )
0 commit comments