machine-learningdeep-learningartificial-intelligencegoogle-gemini

What are Tokens, Top K and Top P?


I'm learning to use Google AI Studio and when generating the snippet I came across these terms:

const generationConfig = {
  temperature: 1,
  topP: 0.95,
  topK: 64,
  maxOutputTokens: 8192,
  responseMimeType: "text/plain",
};

I'm struggling to understand what those terms mean. What are topP, topK, and maxOutputTokens. I want to understand these in order to use them properly.


Solution

  • You can find those details at the model parameters documentation.

    But in a short:

    Gemini is a generative model which means that, in a high level explanation, it "composes" (or generates) an answer given its semantic knowledge in a given language (being a spoken language, a programming language, etc). So basically you can imagine a bag of possible "next tokens" when writing a sentence and top-k and top-p will customize the possible vocabulary to be considered.

    hope that helps.