ایجاد یک درخواست برای یک مدل هوش مصنوعی (AI) مانند Gemini یا Gemma که کاملاً هدف شما را به تصویر میکشد، میتواند یک کار غیر ضروری باشد. اغلب، شما باید یک درخواست را با دست بنویسید و سپس آن را در موارد مختلف آزمایش کنید تا مطمئن شوید که مطابق با نیازهای شما است. بر اساس نتایج، ممکن است بهروزرسانیهای هدفمندی را برای درخواست ایجاد کنید: تغییر برخی کلمات در یک مکان، افزودن یک جمله جدید در مکان دیگر. این فرآیند خیلی اصولی نیست و ممکن است به بهترین نتیجه منجر نشود.
Google روشی را توسعه داده است که از LLM برای بهروزرسانی خودکار یک الگوی درخواستی بر اساس بازخوردی که در مورد خروجی مدل به زبان ساده ارائه میکنید، استفاده میکند. بازخورد شما، همراه با اعلان و خروجی مدل، به یک LLM ارسال میشود که درخواست را بهروزرسانی میکند تا با رفتار مورد نظر شما هماهنگ شود.
این روش به دو صورت در دسترس است:
کتابخانه Python model-alignment منبع باز به شما امکان میدهد این رویکرد را به طور انعطافپذیر در نرمافزار و گردش کار خود بگنجانید.
نسخه ای از این رویکرد در Vertex AI Studio ادغام شده است و به شما امکان می دهد از این گردش کار تنها با چند کلیک استفاده کنید.
این کتابخانه از دو گردش کار برای به روز رسانی خودکار الگوهای درخواست پشتیبانی می کند:
به روز رسانی های تکراری از اصول . این گردش کار از یک LLM برای تقطیر دستورالعملها از نقدهای غیرمستقیم خروجی مدل یا از ویرایشهای مستقیم خروجی مدل استفاده میکند. میتوانید به طور مکرر یک یا چند دستورالعمل را قبل از ارسال به LLM ایجاد کنید، که الگوی درخواستی را برای رعایت آن دستورالعملها بهروزرسانی میکند. شما همچنین می توانید دستورالعمل ها را به صورت دستی تنظیم کنید و آنها را در کنار دستورالعمل های تقطیر شده با LLM قرار دهید.
نقد مستقیم خروجی های مدل . این گردش کار بازخورد شما را در مورد کل خروجی مدل میگیرد و آن را به همراه خروجی اعلان و مدل، مستقیماً به LLM میدهد تا یک الگوی درخواستی بهروز شده تولید کند.
این دو گردش کار ممکن است هر دو برای برنامه شما مفید باشند. معاوضه قابل توجه وجود دستورالعملهایی است که میتواند یک مصنوع فرآیندی مفید و ملموس باشد که میتواند به اطلاعرسانی، برای مثال، رویکرد شما به شفافیت کمک کند.
شکل 1. این فلوچارت نشان می دهد که کجا و چگونه دو جریان کار کتابخانه Model Alignment برای فعال کردن به روز رسانی های دستورالعمل محور یا مستقیم به الگوهای درخواستی شما از هم جدا می شوند. توجه داشته باشید که این فرآیند تکراری است و این گردشهای کاری متقابلاً انحصاری نیستند، میتوانید در هر زمان بین آنها جابجا شوید.
نوت بوک Colab را بررسی کنید که از Gemini برای تراز کردن دستورات Gemma 2 با استفاده از هر دو گردش کار استفاده می کند.
تراز در Vertex AI Studio
استودیوی Vertex AI Google یک ویژگی «تصحیح سریع» را بر اساس گردش کار مستقیم از کتابخانه منبع باز Model Alignment اضافه کرده است تا ابزارهای تألیف، اجرا، ارزیابی و مقایسه آن را تحسین کند.
پس از اجرای یک درخواست، میتوانید بازخوردی در مورد روشهایی ارائه دهید که مدل باید متفاوت رفتار کند، و Vertex AI Studio از Gemini برای پیشنویس بازنویسی استفاده میکند. می توانید تغییرات پیشنهادی را بپذیرید و با کلیک یک دکمه دستور به روز شده را مجدداً اجرا کنید یا بازخورد خود را به روز کنید و از Gemini یک نامزد دیگر بخواهید.
شکل 2. ویژگی "تصفیه اعلان" Vertex AI Studio که برای به روز رسانی یک درخواست بر اساس بازخورد کاربر استفاده می شود.
پیوندها
تراز مدل را برای خودتان کاوش کنید:
این نوت بوک Colab را اجرا کنید که از Gemini برای تراز کردن اعلان های مختلف برای مدل Gemma 2 وزن باز ما با استفاده از هر دو روش تراز استفاده می کند.
ویژگی همترازی مدل «Refine Prompt» را در Vertex AI Studio امتحان کنید.
تاریخ آخرین بهروزرسانی 2024-11-12 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2024-11-12 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Model Alignment\n\n\u003cbr /\u003e\n\nCreating a prompt for an artificial intelligence (AI) model, such as Gemini or\nGemma, that perfectly captures a your intent can be a non-trivial task. Often,\nyou must write a prompt by hand and then test it in a variety of use cases to\nensure it fits your needs. Based on the results, you might make targeted updates\nto the prompt: changing some words in one place, adding a new sentence in\nanother. This process is not very principled and may not lead to the best\nresults.\n\nGoogle has [developed a method](https://arxiv.org/abs/2310.15428) that uses LLMs to\nautomatically update a [prompt template](/responsible/docs/alignment#prompt-templates) based on\nfeedback you provide about the model's output in plain language. Your feedback,\nalong with the prompt and the model's output, are sent to an LLM that updates\nthe prompt to better align with your intended behavior.\n\nThis method available in two ways:\n\n- The open source [`model-alignment` Python library](https://pypi.org/project/model-alignment/) lets you flexibly incorporate this approach into your software and workflows.\n- A [version of this approach](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/prompts/ai-powered-prompt-writing#refine_prompts) is integrated into Vertex AI Studio, letting you use this workflow with just a few clicks.\n\nOpen-Source Library\n-------------------\n\nModel Alignment is an [open-source Python library](https://github.com/pair-code/model-alignment), released as a\n[package on PyPI](https://pypi.org/project/model-alignment/) that enables alignment of prompts from human\nfeedback through an API. The library is based on our research into\n[prompt updating through human feedback](https://arxiv.org/abs/2310.15428) and\n[automatic classifier creation from labeled-data](https://arxiv.org/abs/2403.04894).\n\n**Curate prompt templates for Gemma using the Model Alignment library**\n\n|---|----------------------------------------------------------------------------------------------------------------------------------------------|\n| | [Start Google Colab](https://colab.research.google.com/github/pair-code/model-alignment/blob/main/notebooks/Gemma_for_Model_Alignment.ipynb) |\n\n\u003cbr /\u003e\n\nThis library supports two workflows for automatically updating prompt templates:\n\n1. **Iterative updates from principles** . This workflow uses an LLM to distill [guidelines](https://arxiv.org/abs/2212.08073) either from indirect critiques of the model's output, or from direct edits of the model output. You can iteratively create one or more guidelines before sending them to the LLM, which updates the prompt template to adhere to those guidelines. You can also hand-curate guidelines and include them alongside LLM-distilled ones.\n2. **Direct critique of model outputs**. This workflow takes your feedback about the entire model output and feeds it, along with the prompt and model output, directly to the LLM to generate an updated prompt template.\n\nThese two workflows may both be useful for you application. The notable\ntrade-off is the presence of guidelines, which can be a useful, concrete process\nartifact that can help inform, for example, your approach to\n[transparency](/responsible/docs/design#transparency-artifacts).\n\n**Figure 1.** This flowchart illustrates where and how the two Model Alignment\nlibrary workflows diverge to enable guideline-driven or direct updates to your\nprompt templates. Note that the process is iterative, and these workflows are\nnot mutually exclusive, you can switch between them at any time.\n\nCheck out the [Colab notebook](https://colab.research.google.com/github/pair-code/model-alignment/blob/main/notebooks/Gemma_for_Model_Alignment.ipynb) that uses [Gemini](https://ai.google.dev/gemini-api) to\nalign prompts for [Gemma 2](https://ai.google.dev/gemma) using both workflows.\n\nAlignment in Vertex AI Studio\n-----------------------------\n\nGoogle's [Vertex AI Studio](https://console.cloud.google.com/vertex-ai/studio/freeform) has added a\n[\"refine prompt\"](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/prompts/ai-powered-prompt-writing#refine_prompts) feature based on the *direct* workflow\nfrom the Model Alignment open source library to compliment its authoring,\nrunning, evaluation, and comparison tools.\n\nAfter running a prompt, you can provide feedback on ways in which the model\nshould behave differently, and Vertex AI Studio uses [Gemini](https://ai.google.dev/gemini-api) to draft\na rewrite. You can accept the proposed changes and re-run the updated prompt\nwith a click of a button, or update your feedback and have Gemini draft another\ncandidate.\n\n**Figure 2.** The \"refine prompt\" feature of Vertex AI Studio being used to\nupdate a prompt based on user feedback.\n\nLinks\n-----\n\nExplore model alignment for yourself:\n\n- Run this [Colab notebook](https://colab.research.google.com/github/pair-code/model-alignment/blob/main/notebooks/Gemma_for_Model_Alignment.ipynb) that uses Gemini to align various prompts for our open-weights Gemma 2 model using both alignment approaches.\n- Try the \"refine prompt\" model alignment feature in [Vertex AI Studio](https://console.cloud.google.com/vertex-ai/studio/freeform)."]]