* Building effective agents https://www.anthropic.com/research/building-effective-agents (2024/12/20) * 非常好的說明和比較 workflows 和 agents * Agentic Workflow Patterns (2024/10/25) * https://medium.com/google-cloud/designing-cognitive-architectures-agentic-workflow-patterns-from-scratch-63baa74c54bc ## Flow Engineering > 2024 上半年,這還叫做 Flow Engineering,大約下半年之後社群逐漸改叫做 Agentic Workflow * 2024/5/10 個人想法整理: * 其實就是 prompt chaining 的進階版: 加上狀態機,不同狀態有不同 system prompt 或 工具、切換狀態可用 LLM 判斷 * 但是每個節點實際的 prompt 組成,會疊加之前的(部分)結果 * 例如在 reflection 情境中,會加到 chat history ? * 我猜有些情境是寫進 user prompt? 有些情境有是寫在 user/assistant messages ? * 這部分好像不同情境差異頗大啊? * langgraph 的處理方式似乎也是每個 node 又覆蓋寫個方法而已? * 心得: flow engineering 可以說是一種進階的 prompt chaining * 將一個萬能的 system prompt + function calling 拆開 不同狀態流程,不同狀態有各自的 system prompt 和 tools * 其實也可以說這就是 mulit-agents 麻,是不同的 agent 在處理 messages 流動啊 * 不過,開發難度的確有比較高,你需要想清楚 messages 會如何流程 * 相比用 function calling 全 auto 模式,寫這個 code 的確是比較難 - https://div.beehiiv.com/p/flow-engineering-need 一般性介紹 - Multiturn flows > few shot prompting - 案例有 - AlphaCodium - Claude-ception - [[Corrective RAG (CRAG)]] * https://twitter.com/LangChainAI/status/1781467213108740182 2024/4/20 * https://www.youtube.com/watch?v=eBjxz7qrNBs * https://twitter.com/hwchase17/status/1781704381173563896 * https://twitter.com/SullyOmarr/status/1788605573660803316 * prompt engineering should just be called flow engineering * [[Llamaindex]] 的 Query pipeline * https://www.latent.space/p/elicit * 像 AutoGPT 這樣的開放式代理程式存在問題,包括:1)很難一再複製相同的工作流程;2)沒有辦法硬編碼代理程式應該採取的特定步驟,而不是讓大多數人從產品中得到的。我們需要更好的監督流程: process ![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ba1a433-2e19-4b27-bb24-f8a768231167_1680x1498.png) * Agents aren’t all you need https://www.parcha.com/blog/agents-arent-all-you-need (2024/6/7) * 其實就是在介紹 flow engineering ## LangGraph - [[LangGraph]] - https://langchain-ai.github.io/langgraph/tutorials/introduction/ - https://langchain-ai.github.io/langgraph/concepts/ - 這篇解釋不錯 https://langchain-ai.github.io/langgraph/concepts/#background-agents-ai-workflows-as-graphs - Reflection Simple - https://github.com/langchain-ai/langgraph/blob/main/examples/reflection/reflection.ipynb - 自幹沒問題 - 實作 [[Reflexion 反思]] 搭配 search 效果較好 - 其實跟 [[Self-Ask prompting]] 蠻像的 - 這個跟 reflection 都是固定的迴圈次數 - 資料收集 https://github.com/langchain-ai/langgraph/blob/main/examples/chatbots/information-gather-prompting.ipynb - 跟單純只用 function calling 收集參數相比,這明確分成兩個狀態,有不同的 system prompt!!! - 這個是用 function call 來判斷狀態變化 - Self-Reflective RAG with LangGraph - CRAG https://github.com/langchain-ai/langgraph/blob/main/examples/rag/langgraph_crag.ipynb * Self-RAG https://github.com/langchain-ai/langgraph/blob/main/examples/rag/langgraph_self_rag.ipynb * Routing + [[Corrective RAG (CRAG)]] + [[Self-RAG]] * https://www.youtube.com/watch?v=-ROS6gfYIts (2024/4/19) * https://github.com/langchain-ai/langgraph/blob/main/examples/rag/langgraph_rag_agent_llama3_local.ipynb * https://blog.langchain.dev/agentic-rag-with-langgraph/ * Q: CRAG: 如果已經做了 re-ranking,基本已經檢查相關性了? 感覺不需要用 LLM 做 relevant 檢查,至少這關不用 * Q: 有辦法在 function calling 模擬實現嗎? 感覺可以加到 prompt 裡面,可能會有效果只是不穩定 - 客服 chatbot - https://twitter.com/LangChainAI/status/1787861023996912097 - https://langchain-ai.github.io/langgraph/tutorials/customer-support/customer-support/ - 非常完整的一個 chatbot agent without tool - 心得: 每一層的 tools 不能提供太多,而且不能依賴 LLM 能夠可以自動規劃這些 tools 的呼叫順序、平行又更難了 * [[STORM]] https://github.com/langchain-ai/langgraph/blob/main/examples/storm/storm.ipynb ## AlphaCodium * https://www.codium.ai/blog/alphacodium-state-of-the-art-code-generation-for-code-contests/ * 推薦用 YAML 比 JSON 更適合程式碼輸出 * 文字分析用 Bullet points 條列輸出 * code: https://github.com/Codium-ai/AlphaCodium * paper: https://arxiv.org/abs/2401.08500 * https://twitter.com/karpathy/status/1748043513156272416 1/19 最新話題 * https://twitter.com/itamar_mar/status/1747957348293824676 * https://twitter.com/swyx/status/1748089313433420115 * https://twitter.com/bindureddy/status/1749186440104456263 * https://twitter.com/omarsar0/status/1748353615427735623 * https://twitter.com/iarrp/status/1760032419519004978 * https://twitter.com/RLanceMartin/status/1763276758365999251