Posted in

什么是 “认知架构”?_AI阅读总结 — 包阅AI

包阅导读总结

1. 关键词:认知架构、LLM 应用、自主性级别、系统思维、架构选择

2. 总结:本文介绍了“认知架构”的含义,将其与系统思维相关联,并对应不同自主性级别的 LLM 应用举例。还提到选择认知架构时应考虑任务需求,LangChain 和 LangGraph 变得更灵活可定制以适应不同架构选择。

3.

– 什么是“认知架构”

– 有丰富历史,指关于人脑结构的理论及计算实例化。

– 作者所指的是系统思考方式,即处理用户输入并执行动作或生成响应的代码/提示/LLM 调用流程。

– 自主性级别与认知架构的映射

– 列举不同自主性级别对应的认知架构示例,如纯代码、单次 LLM 调用、LLM 调用链、路由器、状态机、自主代理。

– 选择认知架构

– 各种架构无绝对优劣,取决于任务。

– LangChain 和 LangGraph 更灵活可定制,可通过低级部分控制应用的认知架构。

思维导图:

文章地址:https://blog.langchain.dev/what-is-a-cognitive-architecture/

文章来源:blog.langchain.dev

作者:Harrison Chase

发布时间:2024/7/22 2:05

语言:英文

总字数:743字

预计阅读时间:3分钟

评分:89分

标签:认知架构,LLM 应用,自主性级别,LangChain,代理系统


以下为原文内容

本内容来源于用户推荐转载,旨在分享知识与观点,如有侵权请联系删除 联系邮箱 media@ilingban.com

Update: Several readers have pointed out that the term “cognitive architecture” has a rich history in neuroscience and computational cognitive science. Per Wikipedia, “acognitive architecturerefers to both a theory about the structure of thehuman mindand to a computational instantiation of such a theory”. That definition (and corresponding research and articles on the topic) are more comprehensive than any definition I attempt to offer here, and this blog should instead be read as a mapping of my experience building and helping build LLM-powered applications over the past year to this area of research.

One phrase I’ve used a lot over the past six months (and will likely use more) is “cognitive architecture”. It’s a term I first heard from Flo Crivello – all credit for coming up with it goes to him, and I think it’s a fantastic term. So what exactly do I mean by this?

What I mean by cognitive architecture is how your system thinks —in other words, the flow of code/prompts/LLM calls that takes user input and performs actions or generates a response.

I like the word “cognitive” because agentic systems rely on using an LLM to reason about what to do.

I like the word “architecture” because these agentic systems still involve a good amount of engineering similar to traditional system architecture.

Mapping levels of autonomy to cognitive architectures

If we refer back to this slide (originally from my TED Talk) on the different levels of autonomy in LLM applications, we can see examples of different cognitive architectures.

First is just code – everything is hard coded. Not even really a cognitive architecture.

Next is just a single LLM call. Some data preprocessing before and/or after, but a single LLM call makes up the majority of the application. Simple chatbots likely fall into this category.

Next is a chain of LLM calls. This sequence can be either breaking the problem down into different steps, or just serve different purposes. More complex RAG pipelines fall into this category: use a first LLM call to generate a search query, then a second LLM call to generate an answer.

After that, a router. Prior to this, you knew all the steps the application would take ahead of time. Now, you no longer do. The LLM decides which actions to take. This adds in a bit more randomness and unpredictability.

The next level is what I call a state machine. This is combining an LLM doing some routing with a loop. This is even more unpredictable, as by combining the router with a loop, the system could (in theory) invoke an unlimited number of LLM calls.

The final level of autonomy is the level I call an agent, or really an “autonomous agent”. With state machines, there are still constraints on which actions can be taken and what flows are executed after that action is taken. With autonomous agents, those guardrails are removed. The system itself starts to decide which steps are available to take and what the instructions are: this can be done by updating the prompts, tools, or code used to power the system.

Choosing a cognitive architecture

When I talk about “choosing a cognitive architecture,” I mean choosing which of these architectures you want to adopt. None of these are strictly “better” than others – they all have their own purpose for different tasks.

When building LLM applications, you’ll probably want to experiment with different cognitive architectures just as frequently as you experiment with prompts. We’re building LangChain and LangGraph to enable that. Most of our development efforts over the past year have gone into building low-level, highly controllable orchestration frameworks (LCEL and LangGraph).

This is a bit of a departure from early LangChain which focused on easy-to-use, off-the-shelf chains. These were great for getting started but tough to customize and experiment with. This was fine early on, as everyone was just trying to get started, but as the space matured, the design pretty quickly hit its limits.

I’m extremely proud of the changes we’ve made over the past year to make LangChain and LangGraph more flexible and customizable. If you’ve only ever used LangChain through the high level wrappers, check out the low-level bits. They are much more customizable, and will really let you control the cognitive architecture of your application.

If you’re building straight-forward chains and retrieval flows, check out LangChain in Python and JavaScript. For more complex agentic workflows, try out LangGraph in Python and JavaScript.

Updates from the LangChain team and community