대화형 애플리케이션을 빌드할 때 응답 시간(지연 시간이라고도 함)이 사용자 경험에서 중요한 역할을 합니다. 이 섹션에서는 Vertex AI LLM API의 맥락에서 지연 시간의 개념을 살펴보고 이를 최소화하고 AI 기반 애플리케이션의 응답 시간을 개선할 수 있는 실용적인 전략을 제공합니다.
LLM의 지연 시간 측정항목 이해
지연 시간은 모델에서 입력 프롬프트를 처리하고 해당 출력 응답을 생성하는 데 걸리는 시간을 나타냅니다.
모델을 사용하여 지연 시간을 검사할 때는 다음 사항을 고려하세요.
첫 번째 토큰까지의 시간(TTFT)은 모델에서 프롬프트를 수신한 후 응답의 첫 번째 토큰을 생성하는 데 걸리는 시간입니다. TTFT는 특히 즉각적인 피드백 제공이 중요한 스트리밍을 활용하는 애플리케이션과 관련이 있습니다.
마지막 토큰까지의 시간(TTLT)는 모델에서 프롬프트를 처리하고 응답을 생성하는 데 걸리는 전체 시간을 측정합니다.
지연 시간 감소 전략
Vertex AI를 통해 여러 가지 전략을 활용하여 지연 시간을 최소화하고 애플리케이션 응답성을 향상시킬 수 있습니다.
사용 사례에 적합한 모델 선택
Vertex AI는 다양한 기능과 성능 특성을 가진 여러 가지 모델을 제공합니다. 특정 니즈에 가장 적합한 모델을 선택합니다.
Gemini 1.5 Flash: 경제적인 대용량 애플리케이션을 위해 설계된 멀티모달 모델입니다. Gemini 1.5 Flash는 품질 저하 없이 빠르고 저렴한 애플리케이션을 빌드할 수 있도록 속도와 효율성을 제공합니다. 텍스트, 코드, 이미지 오디오, 오디오가 포함되거나 포함되지 않은 동영상, PDF 또는 이러한 요소의 조합과 같은 모달리티를 지원합니다.
Gemini 1.5 Pro: 더 큰 맥락을 지원하는 보다 강력한 멀티모달 모델입니다. 텍스트, 코드, 이미지 오디오, 오디오가 포함되거나 포함되지 않은 동영상, PDF 또는 이러한 요소의 조합과 같은 모달리티를 지원합니다.
Gemini 1.0 Pro: 속도가 가장 중요하고 프롬프트에 텍스트만 포함된 경우 이 모델을 사용하는 것이 좋습니다. 이 모델은 뛰어난 결과를 제공하면서 더 빠른 응답 시간을 제공합니다.
속도와 출력 품질과 관련된 요구사항을 신중하게 평가하여 사용 사례에 가장 적합한 모델을 선택합니다. 사용 가능한 모델 목록은 모든 모델 살펴보기를 참조하세요.
프롬프트 및 출력 길이 최적화
입력 프롬프트 및 예상 출력 모두의 토큰 수는 처리 시간에 직접적인 영향을 미칩니다. 지연 시간을 줄이려면 토큰 수를 최소화합니다.
불필요한 세부정보나 중복 없이 인텐트를 효과적으로 전달하는 명확하고 간결한 프롬프트를 작성합니다. 프롬프트가 짧을수록 첫 번째 토큰까지의 시간이 줄어듭니다.
시스템 안내를 사용하여 응답 길이를 제어합니다. 간결한 답변을 제공하거나 출력을 특정 문장 또는 단락 수로 제한하도록 모델에 지시합니다. 이 전략은 마지막 토큰까지의 시간을 줄일 수 있습니다.
temperature를 조정합니다. temperature 매개변수를 실험하여 출력의 무작위성을 제어합니다. temperature 값이 낮을수록 응답이 더 짧고 더욱 집중됩니다. 반면 값이 높을수록 출력은 더 다양하지만 잠재적으로 더 길어질 수 있습니다. 자세한 내용은 모델 매개변수 참조의 temperature를 참고하세요.
한도를 설정하여 출력을 제한합니다. 지나치게 긴 출력이 방지되도록 max_output_tokens 매개변수를 사용하여 생성된 응답 길이의 최대 길이 제한을 설정합니다. 하지만 문장 중간에서 응답이 끊어질 수 있으므로 주의해야 합니다.
응답 스트리밍
스트리밍을 사용하면 모델에서 전체 출력을 생성하기 전에 응답을 보내기 시작합니다. 이렇게 하면 출력을 실시간으로 처리할 수 있으며 개발자는 사용자 인터페이스를 즉시 업데이트하고 다른 동시 태스크를 수행할 수 있습니다.
[[["이해하기 쉬움","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-04(UTC)"],[],[],null,["# Best practices with large language models (LLMs)\n\nMultimodal prompts\n------------------\n\nFor information on best practices for multimodal prompts, see the following\npages based on the modality that you're working with:\n\n- [Image understanding](/vertex-ai/generative-ai/docs/multimodal/image-understanding)\n- [Video understanding](/vertex-ai/generative-ai/docs/multimodal/video-understanding)\n- [Audio understanding](/vertex-ai/generative-ai/docs/multimodal/audio-understanding)\n- [Document understanding](/vertex-ai/generative-ai/docs/multimodal/document-understanding)\n\nReduce latency\n--------------\n\nWhen you build interactive applications, response time, also known as latency,\nplays a crucial role in the user experience. This section explores the concept\nof latency in the context of Vertex AI LLM APIs and provides\nactionable strategies to minimize it and improve the response time of\nyour AI-powered applications.\n\n### Understanding latency metrics for LLMs\n\nLatency refers to the time it takes for a model to process your input\nprompt and generate a corresponding output response.\n\nWhen examining latency with a model, consider the following:\n\n*Time to first token (TTFT)* is the time that it takes for the model to produce\nthe first token of the response after receiving the prompt. TTFT is particularly\nrelevant for applications utilizing streaming, where providing immediate\nfeedback is crucial.\n\n*Time to last token (TTLT)* measures the overall time taken by the model to process\nthe prompt and generate the response.\n\n### Strategies to reduce latency\n\nYou can utilize several strategies with Vertex AI\nto minimize latency and enhance the responsiveness of your applications:\n\n#### Choose the right model for your use case\n\nVertex AI provides a diverse range of models with varying\ncapabilities and performance characteristics. Carefully evaluate your\nrequirements regarding speed and output quality to choose the model that best\naligns with your use case. For a list of available models, see\n[Explore all models](/vertex-ai/generative-ai/docs/model-garden/explore-models).\n\n#### Optimize prompt and output length\n\nThe number of tokens in both your input prompt and expected output directly\nimpacts processing time. Minimize your token count to reduce\nlatency.\n\n- Craft clear and concise prompts that effectively convey your intent without\n unnecessary details or redundancy. Shorter prompts reduce your time to first token.\n\n- Use *system instructions* to control the length of the response. Instruct the\n model to provide concise answers or limit the output to a specific number of\n sentences or paragraphs. This strategy can reduce your time to last token.\n\n- Adjust the `temperature`. Experiment with the `temperature` parameter to\n control the randomness of the output. Lower `temperature` values can lead to\n shorter, more focused responses, while higher values can result in more\n diverse, but potentially longer, outputs. For more information,\n see [`temperature` in the model parameters reference](/vertex-ai/generative-ai/docs/model-reference/gemini#parameters).\n\n- Restrict output by setting a limit. Use the `max_output_tokens` parameter to\n set a maximum limit on the length of the generated response length, preventing\n overly long output. However, be cautious as this might cut off responses\n mid-sentence.\n\n#### Stream responses\n\nWith streaming, the model starts sending its response before it generates the\ncomplete output. This enables real-time processing of the output, and you can\nimmediately update your user interface and perform other concurrent tasks.\n\nStreaming enhances perceived responsiveness and creates a more interactive user\nexperience.\n\nWhat's next\n-----------\n\n- Learn [general prompt design strategies](/vertex-ai/generative-ai/docs/learn/prompt-design-strategies).\n- See some [sample prompts](/vertex-ai/generative-ai/docs/prompt-gallery).\n- Learn how to [send chat prompts](/vertex-ai/generative-ai/docs/multimodal/send-chat-prompts-gemini).\n- Learn about [responsible AI best practices and Vertex AI's safety filters](/vertex-ai/generative-ai/docs/learn/responsible-ai).\n- Learn how to [tune a model](/vertex-ai/generative-ai/docs/models/tune-models).\n- Learn about [Provisioned Throughput](/vertex-ai/generative-ai/docs/provisioned-throughput) to assure production workloads."]]