Mulai 29 April 2025, model Gemini 1.5 Pro dan Gemini 1.5 Flash tidak tersedia di project yang belum pernah menggunakan model ini, termasuk project baru. Untuk mengetahui detailnya, lihat Versi dan siklus proses model.
Saat Anda membuat aplikasi interaktif, waktu respons (latensi) adalah bagian penting dari pengalaman pengguna. Bagian ini menjelaskan latensi untuk Vertex AI LLM API dan memberikan strategi untuk menguranginya.
Memahami metrik latensi untuk LLM
Latensi adalah waktu yang dibutuhkan model untuk memproses perintah input Anda dan menghasilkan respons.
Saat mengevaluasi latensi, pertimbangkan metrik berikut:
Waktu hingga token pertama (TTFT): Waktu yang diperlukan model untuk menampilkan token pertama respons setelah menerima perintah. TTFT sangat penting untuk aplikasi streaming yang memerlukan respons cepat.
Waktu hingga token terakhir (TTLT): Waktu keseluruhan yang dibutuhkan model untuk memproses perintah dan menghasilkan respons lengkap.
Strategi untuk mengurangi latensi
Untuk mengurangi latensi dan meningkatkan daya tanggap aplikasi, Anda dapat menggunakan strategi berikut dengan Vertex AI:
Pilih model yang tepat untuk kasus penggunaan Anda. Vertex AI menawarkan berbagai model dengan kemampuan dan karakteristik performa yang berbeda. Untuk memilih model terbaik untuk kasus penggunaan Anda, evaluasi persyaratan Anda terkait kecepatan dan kualitas output. Untuk mengetahui daftar model yang tersedia, lihat Jelajahi semua model.
Mengoptimalkan panjang perintah dan output. Jumlah token dalam perintah input dan output yang diharapkan secara langsung memengaruhi waktu pemrosesan. Untuk mengurangi latensi, minimalkan jumlah token Anda.
Tulis perintah yang jelas dan ringkas yang menyampaikan maksud Anda tanpa detail yang tidak perlu. Perintah yang lebih pendek mengurangi waktu untuk token pertama.
Untuk mengontrol panjang respons, gunakan petunjuk sistem. Anda dapat menginstruksikan model untuk memberikan jawaban yang ringkas atau membatasi output ke sejumlah kalimat atau paragraf tertentu. Strategi ini dapat mengurangi waktu ke token terakhir.
Sesuaikan temperature. Untuk mengontrol keacakan output, bereksperimenlah dengan parameter temperature. Nilai temperature yang lebih rendah dapat menghasilkan respons yang lebih singkat dan lebih fokus. Nilai yang lebih tinggi dapat menghasilkan output yang lebih beragam, tetapi berpotensi lebih panjang. Untuk mengetahui informasi selengkapnya, lihat temperature di referensi parameter model.
Menetapkan batas output. Untuk mencegah output yang terlalu panjang, gunakan parameter max_output_tokens untuk menetapkan panjang maksimum respons yang dihasilkan. Perhatikan bahwa tindakan ini dapat memotong respons di tengah kalimat.
Aktifkan respons bertahap. Saat Anda menggunakan streaming, model akan mengirimkan responsnya saat sedang dibuat, bukan menunggu output selesai. Dengan demikian, Anda dapat memproses output secara real time, sehingga Anda dapat langsung memperbarui antarmuka pengguna dan melakukan tugas serentak lainnya. Streaming meningkatkan responsivitas yang dirasakan dan menciptakan pengalaman pengguna yang lebih interaktif.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-25 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."]]