LangChain的原理
系列文章主要目的快速厘清不同方法的原理差异和应用场景,
对于理论的细节请参考文末的Reference,
Reference中会筛选较为正确,细节的说明
你知道ChatGPT Plugin,AutoGPT和AgentGPT的工作原理吗?其实主要都是基于对于LLMs的Prompt工程,这篇文章主要就是透过目前最活跃的开源框架LangChain进行原理剖析,一览这类型框架背后的工作原理
Langchaing是一个语言模型的开发框架,主要是利用大型LLMs的强大得few-shot以及zero-shot泛化能力作为基础,以Prompt控制为核心基础,让开发者可以根据需求,往上快速堆叠应用,简单来说:
LangChain 是基于提示词工程(Prompt Engineering),提供一个桥接大型语言模型(LLMs)以及实际应用App的胶水层框架。
具体LangChain的原理是什么呢?我们基于LangChain的源码快速剖析:
LangChain最底层的核心其实都放在了langchain/agents/structured_chat/prompt.py中
# flake8: noqa
PREFIX = """Respond to the human as helpfully and accurately as possible. You have access to the following tools:"""
FORMAT_INSTRUCTIONS = """Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).
Valid "actio