註冊並分享邀請連結,可獲得影片播放與邀請獎勵。

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture 投稿は個人の意見です。
加入 May 2026
286 正在關注    469 粉絲
# Useful but Little-Known Features of ADK 2.0 🌍 What if your agent's prompts could improve themselves automatically, instead of requiring manual tuning? ADK 2.0's optimization feature combines samplers and agent optimizers to automatically refine your agent's instructions based on evaluation results. 📌 Title: Optimization 🔗 URL: 🧩 Overview The optimization feature consists of two components: Samplers (which evaluate candidates) and Agent Optimizers (which improve instructions). `LocalEvalSampler` runs candidate agents against evaluation datasets and computes scores. Two optimizers are available: `GEPARootAgentPromptOptimizer`, which uses the GEPA algorithm to optimize the root agent's prompt, and `SimplePromptOptimizer`, which iterates through an execute-evaluate-critique-rewrite cycle. Results are returned as an `OptimizerResult` containing optimized agents with their scores. 🛠 How to use it Run optimization from the CLI with `adk optimize`. ```python import asyncio from google.adk.evaluation.eval_config import EvalConfig from google.adk.evaluation.local_eval_sets_manager import LocalEvalSetsManager from google.adk.optimization.local_eval_sampler import LocalEvalSampler from google.adk.optimization.local_eval_sampler import LocalEvalSamplerConfig from google.adk.optimization.simple_prompt_optimizer import SimplePromptOptimizer from google.adk.optimization.simple_prompt_optimizer import ( SimplePromptOptimizerConfig, ) # Set up the sampler sampler_config = LocalEvalSamplerConfig( eval_config=EvalConfig(criteria={"response_match_score": 0.75}), app_name="my_agent", train_eval_set="train_eval_set", ) sampler = LocalEvalSampler(sampler_config, LocalEvalSetsManager(agents_dir=".")) # Run optimization optimizer = SimplePromptOptimizer(config=SimplePromptOptimizerConfig()) result = sampler)) # Get the optimized agent and score best = result.optimized_agents[0] best_agent = best.optimized_agent print(f"Score: {best.overall_score}") ``` 🏗 Building it into production ・Run optimization periodically as evaluation datasets evolve, keeping prompts continuously refined ・Use `SimplePromptOptimizer` for quick iterations and `GEPARootAgentPromptOptimizer` for thorough exploration ・Compare pre- and post-optimization scores and only update prompts when improvement is confirmed ・Build evaluation datasets from real user interactions for practical optimization 💡 Use cases 📈 Automatically improve agent prompts based on evaluation scores 🔬 Systematically compare multiple prompt candidates and select the best one 🔄 Re-optimize prompts after model changes or API specification updates 🎯 Fine-tune prompts for specific tasks like code generation, summarization, or classification ⚠️ Watch out `GEPARootAgentPromptOptimizer` only optimizes the root agent's prompt. It does not cover sub-agent prompts, so optimize those separately if needed. Also, optimization requires multiple evaluation runs, so keep an eye on LLM API call costs. ✨ With optimization, you can move from trial-and-error prompt tuning to data-driven automation. Set up regular optimization cycles to continuously raise your agent's quality bar. #ADK# #AIAgent#
顯示更多