[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2024-11-23。"],[],[],null,["*Model tuning* is a crucial process in adapting Gemini to perform specific tasks\nwith greater precision and accuracy. Model tuning works by providing a model\nwith a training dataset that contains a set of examples of specific downstream\ntasks.\n\nThis page provides an overview of model tuning for Gemini, describes\nthe tuning options available for Gemini, and helps you determine when\neach tuning option should be used.\n\nBenefits of model tuning\n\nModel tuning is an effective way to customize large models to your tasks. It's a\nkey step to improve the model's quality and efficiency. Model tuning provides the\nfollowing benefits:\n\n- Higher quality for your specific tasks\n- Increased model robustness\n- Lower inference latency and cost due to shorter prompts\n\nTuning compared to prompt design\n\n- **Prompting with pre-trained Gemini models** : Prompting is the art of crafting effective instructions to guide AI models like Gemini in generating the outputs you want. It involves designing prompts that clearly convey the task, format you want, and any relevant context. You can use Gemini's capabilities with minimal setup. It's best suited for:\n - Limited labeled data: If you have a small amount of labeled data or can't afford a lengthy fine-tuning process.\n - Rapid prototyping: When you need to quickly test a concept or get a baseline performance without heavy investment in fine-tuning.\n- **Customized fine-tuning of Gemini models** : For more tailored results, Gemini lets you fine-tune its models on your specific datasets. To create an AI model that excels in your specific domain, consider fine-tuning. This involves retraining the base model on your own labeled dataset, adapting its weights to your task and data. You can adapt Gemini to your use cases. Fine-tuning is most effective when:\n - You have labeled data: A sizable dataset to train on (think 100 examples or more), which allows the model to deeply learn your task's specifics.\n - Complex or unique tasks: For scenarios where advanced prompting strategies are not sufficient, and a model tailored to your data is essential.\n\nWe recommend starting with prompting to find the optimal prompt. Then, move on to\nfine-tuning (if required) to further boost performances or fix recurrent errors.\nWhile adding more examples might be beneficial, it is important to evaluate where\nthe model makes mistakes before adding more data. High-quality, well-labeled data\nis crucial for good performance and better than quantity. Also, the data you use\nfor fine-tuning should reflect the prompt distribution, format and context the\nmodel will encounter in production.\n\nTuning provides the following benefits over prompt design:\n\n- Allows deep customization on the model and results in better performance on specific tasks.\n- Align the model with custom syntax, instructions, domain specific semantic rules.\n- Offers more consistent and reliable results.\n- Capable of handling more examples at once.\n- Save cost at inference by removing few-shot examples, long instructions in the prompts\n\nTuning approaches\n\nParameter-efficient tuning and full fine-tuning are two approaches to\ncustomizing large models. Both methods have their advantages and implications in\nterms of model quality and resource efficiency.\n\nParameter efficient tuning\n\nParameter-efficient tuning, also called adapter tuning, enables efficient\nadaptation of large models to your specific tasks or domain. Parameter-efficient tuning\nupdates a relatively small subset of the model's parameters during the tuning\nprocess.\n\nTo understand how Vertex AI supports adapter tuning and serving, you\ncan find more details in the following whitepaper, [Adaptation of Large Foundation Models](https://services.google.com/fh/files/misc/adaptation_of_foundation_models_whitepaper_google_cloud.pdf).\n\nFull fine-tuning\n\nFull fine-tuning updates all parameters of the model, making it suitable for\nadapting the model to highly complex tasks, with the potential of achieving higher\nquality. However full fine tuning demands higher computational resources for both\ntuning and serving, leading to higher overall costs.\n\nParameter efficient tuning compared to full fine tuning\n\nParameter-efficient tuning is more resource efficient and cost effective compared\nto full fine-tuning. It uses significantly lower computational resources to train.\nIt's able to adapt the model faster with a smaller dataset. The flexibility of\nparameter-efficient tuning offers a solution for multi-task learning without the need\nfor extensive retraining.\n\nSupported tuning methods\n\nVertex AI supports supervised fine-tuning to customize foundational models.\n\nSupervised fine-tuning\n\nSupervised fine-tuning improves the performance of the model by teaching it a new\nskill. Data that contains hundreds of labeled examples is used to teach the\nmodel to mimic a desired behavior or task. Each labeled example demonstrates\nwhat you want the model to output during inference.\n\nWhen you run a supervised fine-tuning job, the model learns additional parameters\nthat help it encode the necessary information to perform the desired task or\nlearn the desired behavior. These parameters are used during inference. The\noutput of the tuning job is a new model that combines the newly learned\nparameters with the original model.\n\nSupervised fine-tuning of a text model is a good option when the output of your model\nisn't complex and is relatively easy to define. Supervised fine-tuning is recommended\nfor classification, sentiment analysis, entity extraction, summarization of\ncontent that's not complex, and writing domain-specific queries. For code\nmodels, supervised tuning is the only option.\n\nModels that support supervised fine-tuning\n\nThe following Gemini models support supervised tuning:\n\n- [Gemini 2.5 Flash-Lite](/vertex-ai/generative-ai/docs/models/gemini/2-5-flash-lite)\n- [Gemini 2.5 Pro](/vertex-ai/generative-ai/docs/models/gemini/2-5-pro)\n- [Gemini 2.5 Flash](/vertex-ai/generative-ai/docs/models/gemini/2-5-flash)\n- [Gemini 2.0 Flash](/vertex-ai/generative-ai/docs/models/gemini/2-0-flash)\n- [Gemini 2.0 Flash-Lite](/vertex-ai/generative-ai/docs/models/gemini/2-0-flash-lite)\n\nFor more information on using supervised fine-tuning with each respective model,\nsee the following pages: Tune [text](/vertex-ai/generative-ai/docs/models/tune_gemini/text_tune), [image](/vertex-ai/generative-ai/docs/models/tune_gemini/image_tune), [audio](/vertex-ai/generative-ai/docs/models/tune_gemini/audio_tune), and [document](/vertex-ai/generative-ai/docs/models/tune_gemini/doc_tune) data types.\n\nLimitations\n\nSupervised fine-tuning has the following limitations:\n\n- Tuning is not a Covered Service and is excluded from the SLO of any Service Level Agreement.\n\nWhat's next\n\n- To learn more about the document understanding capability of Gemini models, see the [Document understanding](/vertex-ai/generative-ai/docs/multimodal/document-understanding) overview.\n- To start tuning, see [Tune Gemini models by using supervised fine-tuning](/vertex-ai/generative-ai/docs/models/gemini-use-supervised-tuning)\n- To learn how supervised fine-tuning can be used in a solution that builds a generative AI knowledge base, see [Jump Start Solution: Generative AI\n knowledge base](/architecture/ai-ml/generative-ai-knowledge-base)."]]