Skip to content
A flat, minimalistic 8-bit computer screen shows a horizontal row of colored blocks, each representing a language model token with colors shifting from blue to red to indicate high to low probability. Next to each main block are a few smaller differently colored blocks showing alternate tokens with top log probability. The design uses only five distinct colors and is simple, geometric, and corporate in style, with sharp edges and no background or extra effects. There are no people, text, shadows, gradients, or 3D elements.

LogProbs

logprobs is a mode where LLMs return the probability of each token. topLogProbs also returns list list of alternate tokens and their log probabilities. This can be useful for debugging and understanding the model’s behavior.

You can enable logprobs in the following ways:

  • Use the logprobs flag on the run command
Terminal window
npx genaiscript run ... --logprobs
  • add the logprobs flag to the script metadata
script({ logprobs: true, ...})

When logprobs is enabled, the cli will color the output based on the probability of each token. Blue color indicates high probability and red color indicates low probability.

Here is an example of logprobs in action when running a poem prompt with gpt-4o.


In  the  whisper  of  trees ,  the  night  softly  speaks ,   
Where  the  moon light  we aves  through  the  shadows  it  seeks .   
Stars  tw inkle  above ,  like  dreams  far  away ,   
Painting  the  night  with  the  dawn ’s  gentle  sway .

You can enable top-logprobs in the following ways:

  • Use the top-logprobs flag on the run command. It enables logprobs as well.
Terminal window
npx genaiscript run ... --top-logprobs 4
  • add the topLogprobs flag to the script metadata
script({ topLogProbs: 4, ...})

When top-logprobs are enabled, the console window is colored with the entropy of the alternate tokens.


In  the  whisper  of  trees ,  the  night  softly  speaks ,   
Where  the  moon light  we aves  through  the  shadows  it  seeks .   
Stars  tw inkle  above ,  like  dreams  far  away ,   
Painting  the  night  with  the  dawn ’s  gentle  sway .

The trace contains a rendering of the alternate tokens with colored output based on the logprobs.


In
B
Am
the
whispers
twilight
whisper
hush
quiet
of
ing
’s
the
dawn
leaves
,
at
where
the
a
where
wind
secrets
breeze
unfolds
softly
does
sigh
sings
hum
,
,\
,

Stars
A
Moon
moon
the
stars
moon
stars
silver
light
’s
paints
dances
gently
we
aves
eps
avers
through
dreams
silver
the
shadow
shadows
gentle
sky
shadows
it
and
seeks
keeps
streak
.
,
;

Stars
A
Dream
tw
like
dance
inkle
ink
irl
like
above
gently
in
,
like
like
in
a
dreams
eyes
secrets
in
taking
set
away
and
yet
,
;

Guid
In
Painting
the
silence
night’s
sky
night
darkness
with
in
sky
a
the
their
glow
light
colors
of
’s
’s
gentle
first
early
sway
gray
ray
.
.
.
<|end|>