@@ -9,9 +9,10 @@ interface VisualizerProps {
99 temperature : number ;
1010 topK : number ;
1111 topP : number ;
12+ context ?: string ;
1213}
1314
14- export const Visualizer : React . FC < VisualizerProps > = ( { candidates, temperature, topK, topP } ) => {
15+ export const Visualizer : React . FC < VisualizerProps > = ( { candidates, temperature, topK, topP, context = "The input text is" } ) => {
1516
1617 // --- VISUAL CONSTANTS ---
1718 const CHART_HEIGHT = 100 ; // Use 100% of the allocated svg space
@@ -104,23 +105,51 @@ export const Visualizer: React.FC<VisualizerProps> = ({ candidates, temperature,
104105 return acc + Math . exp ( item . baseLogit / temperature ) ;
105106 } , 0 ) ;
106107
108+ const topCandidate = data [ 0 ] ;
109+
107110 return (
108111 < div className = "w-full space-y-6" >
109112
110113 { /* Main Card */ }
111114 < div className = "bg-gray-900/80 backdrop-blur-md rounded-2xl p-6 shadow-2xl relative" >
112115
113116 { /* Header */ }
114- < div className = "mb-4 border-b border-gray-800 pb-2 " >
117+ < div className = "mb-2 border-b border-gray-800 pb-3 flex justify-between items-end " >
115118 < div >
116119 < p className = "text-sm font-bold uppercase tracking-widest text-gray-400" >
117- Visualizing probability distribution and sampling filters
120+ Next Token Prediction
118121 </ p >
119122 </ div >
120123 </ div >
121124
125+ { /* CONTEXT SENTENCE DISPLAY */ }
126+ < div className = "mb-6 p-4 bg-black/40 rounded-xl border border-gray-800 flex flex-wrap items-baseline justify-center gap-x-3 gap-y-2 shadow-inner" >
127+ < span className = "text-gray-400 font-mono text-lg tracking-tight" > { context } </ span >
128+ < div className = "relative group" >
129+ < div className = "relative inline-block" >
130+ < span
131+ className = "font-bold text-lg font-mono border-b-2 border-dashed px-2 pb-0.5 transition-all duration-300"
132+ style = { {
133+ color : topCandidate . color ,
134+ borderColor : topCandidate . color ,
135+ textShadow : `0 0 20px ${ topCandidate . color } 40`
136+ } }
137+ >
138+ { topCandidate . word }
139+ </ span >
140+ { /* Blinking Cursor */ }
141+ < span className = "absolute -right-3 top-1 w-2 h-6 bg-indigo-500 animate-pulse rounded-sm" > </ span >
142+ </ div >
143+
144+ { /* Hover Label */ }
145+ < div className = "absolute left-1/2 -translate-x-1/2 -top-10 opacity-0 group-hover:opacity-100 transition-opacity bg-gray-800 text-[10px] text-white px-2 py-1 rounded whitespace-nowrap border border-gray-700 pointer-events-none" >
146+ Highest Probability Candidate
147+ </ div >
148+ </ div >
149+ </ div >
150+
122151 { /* CHART AREA */ }
123- < div className = "h-72 relative mt-4 mx-2 select-none group/chart" >
152+ < div className = "h-64 relative mt-2 mx-2 select-none group/chart" >
124153
125154 { /* LAYER 1: Bars Container (Bottom Z-Index, but allow hover popup) */ }
126155 < div
@@ -383,4 +412,4 @@ const generateMonotoneCubicPath = (points: {x: number, y: number}[]) => {
383412 }
384413
385414 return d ;
386- } ;
415+ } ;
0 commit comments