이 페이지에서는 모델 요청에 설정할 수 있는 선택적 샘플링 매개변수를 보여줍니다. 모델별로 사용 가능한 매개변수가 다를 수 있습니다. 자세한 내용은 참고 문서를 확인하세요.
토큰 샘플링 매개변수
Top-P
Top-P는 모델이 출력용 토큰을 선택하는 방식을 변경합니다. 토큰은 확률의 합이 Top-P 값과 같아질 때까지 확률이 가장 높은 것부터(Top-K 참조) 가장 낮은 것까지 선택됩니다. 예를 들어 토큰 A, B, C의 확률이 0.3, 0.2, 0.1이고 Top-P 값이 0.5이면 모델이 온도를 사용해서 다음 토큰으로 A 또는 B를 선택하고 C는 후보에서 제외합니다.
Top-K는 모델이 출력용 토큰을 선택하는 방식을 변경합니다. Top-K가 1이면 선택된 토큰이 모델의 어휘에 포함된 모든 토큰 중에서 가장 확률이 높다는 의미입니다(그리디 디코딩이라고도 함). 반면에 Top-K가 3이면 강도를 사용하여 가장 확률이 높은 3개 토큰 중에서 다음 토큰이 선택된다는 의미입니다.
각 토큰 선택 단계에서 확률이 가장 높은 Top-K 토큰이 샘플링됩니다. 그런 다음 Top-P를 기준으로 토큰을 추가로 필터링하고 온도 샘플링을 사용하여 최종 토큰을 선택합니다.
온도는 응답 생성 중 샘플링에 사용되며 topP 및 topK가 적용될 때 발생합니다. 온도는 토큰 선택의 무작위성 수준을 제어합니다.
낮은 온도는 덜 개방적인 또는 덜 창의적인 대답이 필요한 프롬프트에 적합한 반면, 높은 온도는 더 창의적인 대답으로 이어질 수 있습니다. 온도가 0이면 확률이 가장 높은 토큰이 항상 선택됩니다. 이 경우 특정 프롬프트에 대한 응답은 대부분 확정적이지만 여전히 약간의 변형이 가능합니다.
모델이 너무 일반적이거나, 너무 짧은 응답을 반환하거나 모델이 대체 응답을 제공할 경우에는 온도(temperature)를 높여보세요.
온도가 낮을수록 예측 가능한(그러나 완전히 결정론적은 아님) 결과를 얻을 수 있습니다. 자세한 내용은 temperature를 참조하세요.
중지 매개변수
최대 출력 토큰
maxOutputTokens를 설정하여 응답에서 생성되는 토큰 수를 제한합니다. 토큰은 약 4자(영문 기준)이므로 100개의 토큰은 대략 60~80단어에 해당합니다. 응답 길이를 제한하려면 낮은 값을 설정합니다.
중지 시퀀스
응답에서 문자열 중 하나가 발견되면 모델에 텍스트 생성을 중지하도록 stopSequences에 문자열을 정의합니다. 문자열이 응답에 여러 번 표시되면 문자열이 처음 발견된 위치에서 응답이 잘립니다. 문자열은 대소문자를 구분합니다.
토큰 패널라이징 매개변수
빈도 페널티
양수 값은 생성된 텍스트에 반복적으로 표시되는 토큰에 페널티를 적용하여 콘텐츠가 반복될 가능성을 줄입니다. 최솟값은 -2.0입니다. 최댓값은 2.0 미만입니다.
자세한 내용은 frequencyPenalty를 참조하세요.
상태 페널티
양수 값은 생성된 텍스트에 이미 표시된 토큰에 페널티를 적용하여 다양한 콘텐츠가 생성될 가능성을 높입니다. 최솟값은 -2.0입니다. 최댓값은 2.0 미만입니다.
자세한 내용은 presencePenalty를 참조하세요.
고급 매개변수
이러한 매개변수를 사용하여 응답에서 토큰에 관한 추가 정보를 반환하거나 응답의 가변성을 제어합니다.
출력 토큰의 로그 확률
각 생성 단계에서 상위 후보 토큰의 로그 확률을 반환합니다. 모델에서 선택한 토큰은 각 단계의 상위 후보 토큰과 다를 수 있습니다. 1~5 범위의 정수 값을 사용하여 반환할 후보 수를 지정합니다. 자세한 내용은 logprobs를 참고하세요. 이 기능을 사용하려면 responseLogprobs 매개변수를 true로 설정해야 합니다.
시드가 특정 값으로 고정되면 모델은 반복된 요청에 같은 응답을 제공하기 위해 최선을 다합니다. 결정론적 출력은 보장되지 않습니다.
또한 온도와 같은 모델 또는 매개변수 설정을 변경하면 같은 시드 값을 사용하더라도 응답이 달라질 수 있습니다. 기본적으로 무작위 시드 값이 사용됩니다.
자세한 내용은 seed를 참조하세요.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-03(UTC)"],[],[],null,["# Content generation parameters\n\nThis page shows the optional sampling parameters you can set in a request to a\nmodel. The parameters available for each model may differ. For more information,\nsee the [reference documentation](/vertex-ai/generative-ai/docs/model-reference/inference#generationconfig).\n\nToken sampling parameters\n-------------------------\n\n### Top-P\n\n\nTop-P changes how the model selects tokens for output. Tokens are selected\nfrom the most probable to least probable until the sum of their probabilities\nequals the top-P value. For example, if tokens A, B, and C have a probability of\n0.3, 0.2, and 0.1 and the top-P value is `0.5`, then the model will\nselect either A or B as the next token by using temperature and excludes C as a\ncandidate.\n\nSpecify a lower value for less random responses and a higher value for more\nrandom responses.\nFor more information, see [`topP`](/vertex-ai/generative-ai/docs/model-reference/inference#topP).\n\n\u003cbr /\u003e\n\n### Temperature\n\n\nThe temperature is used for sampling during response generation, which occurs when `topP`\nand `topK` are applied. Temperature controls the degree of randomness in token selection.\nLower temperatures are good for prompts that require a less open-ended or creative response, while\nhigher temperatures can lead to more diverse or creative results. A temperature of `0`\nmeans that the highest probability tokens are always selected. In this case, responses for a given\nprompt are mostly deterministic, but a small amount of variation is still possible.\n\nIf the model returns a response that's too generic, too short, or the model gives a fallback\nresponse, try increasing the temperature.\n\n\u003cbr /\u003e\n\nLower temperatures lead to predictable (but not completely [deterministic](https://medium.com/google-cloud/is-a-zero-temperature-deterministic-c4a7faef4d20))\nresults. For more information, see [`temperature`](/vertex-ai/generative-ai/docs/model-reference/inference#temperature).\n\nStopping parameters\n-------------------\n\n### Maximum output tokens\n\nSet [`maxOutputTokens`](/vertex-ai/generative-ai/docs/model-reference/inference#maxOutputTokens) to limit the number of tokens\ngenerated in the response. A token is approximately four characters, so 100\ntokens correspond to roughly 60-80 words. Set a low value to limit the length\nof the response.\n\n### Stop sequences\n\nDefine strings in [`stopSequences`](/vertex-ai/generative-ai/docs/model-reference/inference#stopSequences) to tell the model to stop\ngenerating text if one of the strings is encountered in the response. If a\nstring appears multiple times in the response, then the response is truncated\nwhere the string is first encountered. The strings are case-sensitive.\n\nToken penalization parameters\n-----------------------------\n\n### Frequency penalty\n\n\nPositive values penalize tokens that repeatedly appear in the generated text, decreasing the\nprobability of repeating content. The minimum value is `-2.0`. The maximum value is up\nto, but not including, `2.0`.\nFor more information, see [`frequencyPenalty`](/vertex-ai/generative-ai/docs/model-reference/inference#frequencyPenalty).\n\n### Presence penalty\n\n\nPositive values penalize tokens that already appear in the generated text, increasing the\nprobability of generating more diverse content. The minimum value is `-2.0`. The maximum\nvalue is up to, but not including, `2.0`.\nFor more information, see [`presencePenalty`](/vertex-ai/generative-ai/docs/model-reference/inference#presencePenalty).\n\nAdvanced parameters\n-------------------\n\nUse these parameters to return more information about the tokens in the response\nor to control the variability of the response.\n|\n| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\n### Log probabilities of output tokens\n\n\nReturns the log probabilities of the top candidate tokens at each generation step. The model's\nchosen token might not be the same as the top candidate token at each step. Specify the number of\ncandidates to return by using an integer value in the range of `1`-`20`.\nFor more information, see [`logprobs`](/vertex-ai/generative-ai/docs/model-reference/inference#logprobs). You also need to\nset the [`responseLogprobs`](/vertex-ai/generative-ai/docs/model-reference/inference#responseLogprobs) parameter to `true` to use this\nfeature.\n\nThe [`responseLogprobs`](/vertex-ai/generative-ai/docs/model-reference/inference#responseLogprobs) parameter returns the log\nprobabilities of the tokens that were chosen by the model at each step.\n\nFor more information, see the [Intro to Logprobs](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/logprobs/intro_logprobs.ipynb) notebook.\n\n### Seed\n\n\nWhen seed is fixed to a specific value, the model makes a best effort to provide\nthe same response for repeated requests. Deterministic output isn't guaranteed.\nAlso, changing the model or parameter settings, such as the temperature, can\ncause variations in the response even when you use the same seed value. By\ndefault, a random seed value is used.\nFor more information, see [`seed`](/vertex-ai/generative-ai/docs/model-reference/inference#seed).\n\n### Example\n\nHere is an example that uses parameters to tune a model's response. \n\n### Python\n\n#### Install\n\n```\npip install --upgrade google-genai\n```\n\n\nTo learn more, see the\n[SDK reference documentation](https://googleapis.github.io/python-genai/).\n\n\nSet environment variables to use the Gen AI SDK with Vertex AI:\n\n```bash\n# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values\n# with appropriate values for your project.\nexport GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT\nexport GOOGLE_CLOUD_LOCATION=global\nexport GOOGLE_GENAI_USE_VERTEXAI=True\n```\n\n\u003cbr /\u003e\n\n from google import genai\n from google.genai.types import GenerateContentConfig, HttpOptions\n\n client = genai.Client(http_options=HttpOptions(api_version=\"v1\"))\n response = client.models.generate_content(\n model=\"gemini-2.5-flash\",\n contents=\"Why is the sky blue?\",\n # See the SDK documentation at\n # https://googleapis.github.io/python-genai/genai.html#genai.types.GenerateContentConfig\n config=GenerateContentConfig(\n temperature=0,\n candidate_count=1,\n response_mime_type=\"application/json\",\n top_p=0.95,\n top_k=20,\n seed=5,\n max_output_tokens=500,\n stop_sequences=[\"STOP!\"],\n presence_penalty=0.0,\n frequency_penalty=0.0,\n ),\n )\n print(response.text)\n # Example response:\n # {\n # \"explanation\": \"The sky appears blue due to a phenomenon called Rayleigh scattering. When ...\n # }\n\n### Go\n\nLearn how to install or update the [Go](/vertex-ai/generative-ai/docs/sdks/overview).\n\n\nTo learn more, see the\n[SDK reference documentation](https://pkg.go.dev/google.golang.org/genai).\n\n\nSet environment variables to use the Gen AI SDK with Vertex AI:\n\n```bash\n# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values\n# with appropriate values for your project.\nexport GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT\nexport GOOGLE_CLOUD_LOCATION=global\nexport GOOGLE_GENAI_USE_VERTEXAI=True\n```\n\n\u003cbr /\u003e\n\n import (\n \t\"context\"\n \t\"fmt\"\n \t\"io\"\n\n \tgenai \"google.golang.org/genai\"\n )\n\n // generateWithConfig shows how to generate text using a text prompt and custom configuration.\n func generateWithConfig(w io.Writer) error {\n \tctx := context.Background()\n\n \tclient, err := genai.NewClient(ctx, &genai.ClientConfig{\n \t\tHTTPOptions: genai.HTTPOptions{APIVersion: \"v1\"},\n \t})\n \tif err != nil {\n \t\treturn fmt.Errorf(\"failed to create genai client: %w\", err)\n \t}\n\n \tmodelName := \"gemini-2.5-flash\"\n \tcontents := genai.Text(\"Why is the sky blue?\")\n \t// See the documentation: https://googleapis.github.io/python-genai/genai.html#genai.types.GenerateContentConfig\n \tconfig := &genai.GenerateContentConfig{\n \t\tTemperature: genai.Ptr(float32(0.0)),\n \t\tCandidateCount: int32(1),\n \t\tResponseMIMEType: \"application/json\",\n \t}\n\n \tresp, err := client.Models.GenerateContent(ctx, modelName, contents, config)\n \tif err != nil {\n \t\treturn fmt.Errorf(\"failed to generate content: %w\", err)\n \t}\n\n \trespText := resp.Text()\n\n \tfmt.Fprintln(w, respText)\n \t// Example response:\n \t// {\n \t// \"explanation\": \"The sky is blue due to a phenomenon called Rayleigh scattering ...\n \t// }\n\n \treturn nil\n }\n\n\u003cbr /\u003e\n\nWhat's next\n-----------\n\n- Learn about [responsible AI best practices and Vertex AI's safety filters](/vertex-ai/generative-ai/docs/learn/responsible-ai).\n- Learn about [system instructions for safety](/vertex-ai/generative-ai/docs/multimodal/safety-system-instructions).\n- Learn about [abuse monitoring](/vertex-ai/generative-ai/docs/learn/abuse-monitoring).\n- Learn about [responsible AI](/vertex-ai/generative-ai/docs/learn/responsible-ai)."]]