Cheat Sheet: Mastering Temperature and Top_p in ChatGPT API

I think you just need to play around with top_p vs. temperature to see the difference. Honesty, I mainly use temperature, but I can see the value of top_p in certain situations.

Here is an example where I have the AI to try to be “creative” and write a rap song. Basically, the temperature version is better than the top_p version, since the rhymes in the temperature version seem to make more sense and feel less forced. The top_p version limits the vocabulary, sounds way more clinical???. But this could be good in situations where you want it to write code, or maybe Q/A from your documents (I would need to test this to be sure). Or act like a lawyer/doctor (or whatever).

System: “You are MC Hammer!”
User: “Throw me some rhymes, yo!”

Limit it by top_p :-1:

Not sure I like this one over the next one, too clinical using top_p

temp = 1, top_p = 0.09, max_tokens = 320, model = gpt-4

(Verse 1)
Yo, it’s Hammer time, I’m back on the scene,
I’m the lyrical genius, the rhyme machine,
I got the moves, the style, the groove, no doubt,
When I step on the stage, everybody shout.

(Chorus)
Can’t touch this, I’m the one and only,
MC Hammer, never lonely,
I got the rhythm, the beat, the flow,
When I grab the mic, it’s time to go.

(Verse 2)
I’m the king of the dance floor, the master of the beat,
When I’m rockin’ the mic, you can’t stay in your seat,
I got the power, the energy, the vibe,
When I’m on the stage, you know it’s live.

(Bridge)
I’m untouchable, unstoppable, the legend in the game,
MC Hammer, remember the name,
I’m the pioneer, the trailblazer, the icon,
When I’m on the mic, you know it’s on.

(Chorus)
Can’t touch this, I’m the one and only,
MC Hammer, never lonely,
I got the rhythm, the beat, the flow,
When I grab the mic, it’s time to go.

(Outro)
So, there you have it, the rhymes I threw,
MC Hammer, still fresh and new,
I’ll keep on dancin’, keep on groovin’,
As long as the beat keeps on movin’.

Limit it by temperature :+1:

This one sounds better, and notice it keeps going and is cutoff by the token limit. I vote temperature > top_p for this task (see below).

temp = 0.09, top_p = 1, max_tokens = 320, model = gpt-4

(Verse 1)
Yo, it’s MC Hammer, back on the scene,
With the funky fresh rhymes, you know what I mean,
I’m the lyrical master, the king of the groove,
When I step on the mic, I make the whole room move.

(Chorus)
Can’t touch this, no, you can’t compete,
I’m the one and only, with the golden beat,
I’m the king of the dance floor, the lord of the rhyme,
When I’m on the mic, it’s Hammer Time!

(Verse 2)
I’m the man with the plan, the original don,
I’ve been rockin’ the mic since the break of dawn,
I’m the one who made it cool to wear parachute pants,
When I hit the stage, everybody starts to dance.

(Bridge)
I’m the master of the flow, the ruler of the game,
When I’m on the mic, you’ll remember my name,
MC Hammer, the legend, the icon, the star,
I’ve been breakin’ it down, near and far.

(Chorus)
Can’t touch this, no, you can’t compete,
I’m the one and only, with the golden beat,
I’m the king of the dance floor, the lord of the rhyme,
When I’m on the mic, it’s Hammer Time!

(Outro)
So, remember my name, and don’t you forget,
I’m the one and only, the best you’ll ever get,
I’m MC Hammer, the legend, the king,
When I >|cuttoff due to token limit|<

1 Like