СледваСледващо ръководство
Бързо създаване на версии и регресионно тестване
технически
Техническо РЪКОВОДСТВО
Автоматичното оптимизиране на подканите използва алгоритъм за търсене на по-добри инструкции или примери с малко данни.
Чуйте това ръководствоAI-разказан · ~3 min
Той оценява кандидат подканите спрямо метрика на набор от примери, вместо да разчита на ръчно подправени формулировки. Известни подходи включват APE, Google DeepMind's OPRO и DSPy, отворен източник рамка от Стандфорд. Заедно те превръщат инженерството на подканите от догадки в измерим, повторим процес.
Hand-tuned prompts have a known weakness. Wording that works for one model, dataset or version can quietly stop working on another, and changes are usually judged on only a handful of examples. Automatic prompt optimization replaces that loop with a search. You provide three things: - A task. - A set of inputs, ideally with expected outputs. - A metric, such as exact match or a rubric scored by another model. The optimizer generates candidate prompts, runs them, scores them and keeps the winners. Early examples made the idea concrete. APE (Automatic Prompt Engineer, Zhou et al., 2022) had a model propose many instructions from input-output examples, then kept the highest-scoring ones. OPRO (Optimization by PROmpting, Yang et al., Google DeepMind, 2023) used an LLM as the optimizer. Its meta-prompt listed earlier instructions with their scores, and the model proposed new ones. OPRO found instructions such as "Take a deep breath and work on this problem step-by-step," which scored well for one particular model on grade-school math. Optimized wording can be unintuitive and specific to a model. DSPy goes further by changing how programs are written. It was developed at Stanford NLP by Omar Khattab and collaborators and introduced in 2023. You declare what each step does with a signature, such as "question, context -> answer," and combine modules like Predict or ChainOfThought. An optimizer (earlier called a teleprompter), such as BootstrapFewShot or MIPROv2, then "compiles" the program by choosing demonstrations and instructions for each module to maximize your metric. Three misconceptions are worth correcting: - These tools remove human judgment. They do not, because the metric and examples define "better." - Optimized prompts are safe to trust. They can overfit a small dataset. - Optimization is free. It costs real API calls, sometimes many.
Екип, който изгражда класификатор за тикети за поддръжка, пише DSPy подпис "ticket -> category" и предоставя 200 етикетирани тикета и метрика за точност. Оптимизаторът след това избира примерите с малко данни, които получават най-добри резултати.
Когато компания преминава от един доставчик на LLM към друг, тя преизпълнява своя DSPy оптимизатор за новата модел. Тя не пренаписва ръчно подканите, които са били настроени за стария модел.
Изследовател изпълнява OPRO-стилен цикъл. Един модел предлага нови формулировки за инструкция, всяка формулировка се оценява по математическа оценка, а най-добре оценената история се връща в следващия кръг предложения.
Поток за отговор на въпроси, усилен с извличане, се оптимизира от край до край, с метрика, която проверява крайни отговори спрямо референтни отговори. И стъпката за писане на заявка, и стъпката за отговор се подобряват заедно.
Prompt optimization is becoming a normal part of LLM engineering, alongside evaluation suites, rather than a research curiosity. Open questions remain. How well do optimized prompts transfer between models? How do you write metrics for subjective qualities like tone or helpfulness? How do you avoid overfitting small datasets? Some research combines prompt optimization with lightweight fine-tuning, and DSPy supports both. Models change often, so the ability to re-optimize automatically against a stable test set is likely to matter more than any single clever prompt. Defining good metrics and examples remains a human job.
Безплатен бюлетин
Три проверени AI истории всяка делнична сутрин, написани на достъпен език. Безплатно завинаги, без реклами.
Един имейл всеки делничен ден. Отписване с едно кликване. Никога не продаваме и не споделяме вашия имейл адрес.
Тествайте себе си
Незабавна обратна връзка за всеки отговор и сертификат за споделяне с подлежащ на проверка идентификационен номер, след като преминете курс.
Подкрепете безплатното AI образование. AI Understanding е 501(c)(3) с нестопанска цел — без реклами, без платен достъп, никога. Направете дарение
Automatic prompt optimization uses an algorithm to search for better instructions or few-shot examples. It scores candidate prompts against a metric on a set of examples instead of relying on hand-tweaked wording. Well-known approaches include APE, Google DeepMind's OPRO and DSPy, an open-source framework from Stanford. Together they turn prompt engineering from guesswork into a measurable, repeatable process.
The optimizer needs a task, examples and a metric so it can score candidate prompts and keep the best ones.
OPRO uses a language model as the optimizer. It sees past instructions with their scores and proposes new ones.
The instruction scored well for one particular model on grade-school math. Wording found by search can be surprising and may not carry over to other models.
Signatures declare what a module should do in terms of its input and output fields. DSPy then works out the prompt.
Successful traces become few-shot examples, including for internal steps you never labeled yourself.
Продължавай да учиш
Още ръководства, избрани за тази тема
СледваСледващо ръководство
Бързо създаване на версии и регресионно тестване
технически