跳转到主要内容

标签(标签)

资源精选(342) Go开发(108) Go语言(103) Go(99) angular(82) LLM(75) 大语言模型(63) 人工智能(53) 前端开发(50) LangChain(43) golang(43) 机器学习(39) Go工程师(38) Go程序员(38) Go开发者(36) React(33) Go基础(29) Python(24) Vue(22) Web开发(20) Web技术(19) 精选资源(19) 深度学习(19) Java(18) ChatGTP(17) Cookie(16) android(16) 前端框架(13) JavaScript(13) Next.js(12) 安卓(11) typescript(10) 资料精选(10) NLP(10) 第三方Cookie(9) Redwoodjs(9) LLMOps(9) Go语言中级开发(9) 自然语言处理(9) 聊天机器人(9) PostgreSQL(9) 区块链(9) mlops(9) 安全(9) 全栈开发(8) ChatGPT(8) OpenAI(8) Linux(8) AI(8) GraphQL(8) iOS(8) 软件架构(7) Go语言高级开发(7) AWS(7) C++(7) 数据科学(7) whisper(6) Prisma(6) 隐私保护(6) RAG(6) JSON(6) DevOps(6) 数据可视化(6) wasm(6) 计算机视觉(6) 算法(6) Rust(6) 微服务(6) 隐私沙盒(5) FedCM(5) 语音识别(5) Angular开发(5) 快速应用开发(5) 提示工程(5) Agent(5) LLaMA(5) 低代码开发(5) Go测试(5) gorm(5) REST API(5) 推荐系统(5) WebAssembly(5) GameDev(5) CMS(5) CSS(5) machine-learning(5) 机器人(5) 游戏开发(5) Blockchain(5) Web安全(5) Kotlin(5) 低代码平台(5) 机器学习资源(5) Go资源(5) Nodejs(5) PHP(5) Swift(5) 智能体(4) devin(4) Blitz(4) javascript框架(4) Redwood(4) GDPR(4) 生成式人工智能(4) Angular16(4) Alpaca(4) SAML(4) JWT(4) JSON处理(4) Go并发(4) kafka(4) 移动开发(4) 移动应用(4) security(4) 隐私(4) spring-boot(4) 物联网(4) nextjs(4) 网络安全(4) API(4) Ruby(4) 信息安全(4) flutter(4) 专家智能体(3) Chrome(3) CHIPS(3) 3PC(3) SSE(3) 人工智能软件工程师(3) LLM Agent(3) Remix(3) Ubuntu(3) GPT4All(3) 软件开发(3) 问答系统(3) 开发工具(3) 最佳实践(3) RxJS(3) SSR(3) Node.js(3) Dolly(3) 移动应用开发(3) 编程语言(3) 低代码(3) IAM(3) Web框架(3) CORS(3) 基准测试(3) Go语言数据库开发(3) Oauth2(3) 并发(3) 主题(3) Theme(3) earth(3) nginx(3) 软件工程(3) azure(3) keycloak(3) 生产力工具(3) gpt3(3) 工作流(3) C(3) jupyter(3) 认证(3) prometheus(3) GAN(3) Spring(3) 逆向工程(3) 应用安全(3) Docker(3) Django(3) R(3) .NET(3) 大数据(3) Hacking(3) 渗透测试(3) C++资源(3) Mac(3) 微信小程序(3) Python资源(3) JHipster(3) 大型语言模型(2) 语言模型(2) 可穿戴设备(2) JDK(2) SQL(2) Apache(2) Hashicorp Vault(2) Spring Cloud Vault(2) Go语言Web开发(2) Go测试工程师(2) WebSocket(2) 容器化(2) AES(2) 加密(2) 输入验证(2) ORM(2) Fiber(2) Postgres(2) Gorilla Mux(2) Go数据库开发(2) 模块(2) 泛型(2) 指针(2) HTTP(2) PostgreSQL开发(2) Vault(2) K8s(2) Spring boot(2) R语言(2) 深度学习资源(2) 半监督学习(2) semi-supervised-learning(2) architecture(2) 普罗米修斯(2) 嵌入模型(2) productivity(2) 编码(2) Qt(2) 前端(2) Rust语言(2) NeRF(2) 神经辐射场(2) 元宇宙(2) CPP(2) 数据分析(2) spark(2) 流处理(2) Ionic(2) 人体姿势估计(2) human-pose-estimation(2) 视频处理(2) deep-learning(2) kotlin语言(2) kotlin开发(2) burp(2) Chatbot(2) npm(2) quantum(2) OCR(2) 游戏(2) game(2) 内容管理系统(2) MySQL(2) python-books(2) pentest(2) opengl(2) IDE(2) 漏洞赏金(2) Web(2) 知识图谱(2) PyTorch(2) 数据库(2) reverse-engineering(2) 数据工程(2) swift开发(2) rest(2) robotics(2) ios-animation(2) 知识蒸馏(2) 安卓开发(2) nestjs(2) solidity(2) 爬虫(2) 面试(2) 容器(2) C++精选(2) 人工智能资源(2) Machine Learning(2) 备忘单(2) 编程书籍(2) angular资源(2) 速查表(2) cheatsheets(2) SecOps(2) mlops资源(2) R资源(2) DDD(2) 架构设计模式(2) 量化(2) Hacking资源(2) 强化学习(2) flask(2) 设计(2) 性能(2) Sysadmin(2) 系统管理员(2) Java资源(2) 机器学习精选(2) android资源(2) android-UI(2) Mac资源(2) iOS资源(2) Vue资源(2) flutter资源(2) JavaScript精选(2) JavaScript资源(2) Rust开发(2) deeplearning(2) RAD(2)

category

目前在LLM上开发的方法正在迅速发展,即时工程在某种程度上被链接和代理的概念所吸收。

在最近的一篇文章中,我写到了即时工程的演变,以及即时工程是如何被吸收到更大的开发结构中的。

这些更大的开发结构允许:

  1. 更长、更复杂的用户交互
  2. 进程可以串行或并行运行
  3. 提示可以编程、共享、存储和模板化
  4. 链接是创建提示流或提示序列的概念。

对于现有流退出并且可以创建预先确定的会话或工作流的情况,Chaining工作得很好。

另一方面,在流量未知或高度不可预测的情况下,链接并不能很好地服务于场景。在这些情况下,预定的流程将不能很好地工作,并且需要一定程度的自主权。

 

什么是代理?

代理可以通过使用其可支配的一组工具或资源来接收查询。这些工具可以包括访问维基百科、网络搜索、数学库、LLM等。

  • 链可以包含代理。
  • 代理还包含一个链。

但是,在代理的情况下,它是一系列步骤,这些步骤是在代理循环使用其可支配的工具来为请求提供服务时动态编译的。

LangChain有一个广泛的工具列表,可以将这些工具合并到代理创建的自组织链中。

下图显示了LangChain代理所遵循的事件序列:

在下面的笔记本摘录中,可以看到一个模棱两可的问题和事件的顺序。从进入链条、动作输入、观察、思考等。

另一个实际例子;考虑到下面的图片,这个笔记本是一个LangChain代理的,它可以访问网络搜索和GPT4来回答这个问题。

注意经纪人是如何进入一个链的,回答我提出的问题:SpaceX和特斯拉的创始人是什么年出生的,他创立的第一家公司叫什么名字?并将问题转化为行动。

特工进入搜索动作,搜索输入为:SpaceX和特斯拉的创始人出生年份和第一家公司。

这是基于代理接收到的初始输入的观察结果。特工有一个想法,最终的答案已经达成。链已经完成,并给出了回应:太空探索技术公司和特斯拉的创始人埃隆·马斯克出生于1971年。他创办的第一家公司是Zip2。

LangChain Agent example

以下是Langchain代理的完整工作代码,它可以执行:

  • 网络搜索
  • 数学
  • 并且可以访问GPT4

考虑到下面的代码,向代理提交了一个模棱两可的问题:

太空探索技术公司和特斯拉的创始人是哪一年出生的,他创立的第一家公司叫什么名字?

pip install langchain
pip install google-search-results
pip install openai

from langchain.agents import load_tools
from langchain.agents import initialize_agent
from langchain.agents import AgentType
from langchain.llms import OpenAI

import os
os.environ['OPENAI_API_KEY'] = str("xxxxxxxxxxxxxxxxxxx")
os.environ["SERPAPI_API_KEY"] = str("xxxxxxxxxxxxxxxxxxx")
llm = OpenAI(temperature=0,model_name='gpt-4-0314')

tools = load_tools(["serpapi", "llm-math"], llm=llm)

agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)

agent.run("What year was the founder of SpaceX and Tesla born and what is the name of the first company he founded?")

以及代理响应:

> Entering new AgentExecutor chain...
I need to search for the birth year of the founder of SpaceX and Tesla and the name of his first company.
Action: Search
Action Input: founder of SpaceX and Tesla birth year and first company
Observation: Elon Musk ; Born: June 28, 1971 (age 51) Pretoria South Africa ; Founder: PayPal SpaceX Zip2 ; Early life. Musk was born to a South African father and a Canadian ...
Thought:I now know the final answer
Final Answer: Elon Musk, the founder of SpaceX and Tesla, was born in 1971. The first company he founded was Zip2.

> Finished chain.
'Elon Musk, the founder of SpaceX and Tesla, was born in 1971. The first company he founded was Zip2.

此示例显示了代理有权访问的实例:

  • 维基百科
  • GPT4
pip install langchain
pip install wikipedia
pip install openai

from langchain.agents import load_tools
from langchain.agents import initialize_agent
from langchain.agents import AgentType
from langchain.llms import OpenAI

import os
os.environ['OPENAI_API_KEY'] = str("xxxxxxxxxxxxxxxxxxxxxxxxxxx")
llm = OpenAI(temperature=0,model_name='gpt-4-0314')

tools = load_tools(["wikipedia"], llm=llm)
agent = initialize_agent(tools, llm, agent="zero-shot-react-description", verbose=True)

agent.run("What year was the founder of SpaceX and Tesla born and what is the name of the first company he founded?")

注意响应中的差异:


> Entering new AgentExecutor chain...
I need to find information about the founder of SpaceX and Tesla, including his birth year and the first company he founded.
Action: Wikipedia
Action Input: Elon Musk
Observation: Page: Elon Musk
Summary: Elon Reeve Musk  ( EE-lon; born June 28, 1971) is a business magnate and investor. He is the founder, CEO and chief engineer of SpaceX; angel investor, CEO and product architect of Tesla, Inc.; owner and CEO of Twitter; founder of the Boring Company; co-founder of Neuralink and OpenAI; and president of the philanthropic Musk Foundation. With an estimated net worth of around $192 billion as of March 27, 2023, primarily from his ownership stakes in Tesla and SpaceX, Musk is the second-wealthiest person in the world, according to both the Bloomberg Billionaires Index and Forbes's real-time billionaires list.Musk was born in Pretoria, South Africa, and briefly attended at the University of Pretoria before moving to Canada at age 18, acquiring citizenship through his Canadian-born mother. Two years later, he matriculated at Queen's University and transferred to the University of Pennsylvania, where he received bachelor's degrees in economics and physics. He moved to California in 1995 to attend Stanford University. After two days, he dropped out and, with his brother Kimbal, co-founded the online city guide software company Zip2. In 1999, Zip2 was acquired by Compaq for $307 million and Musk co-founded X.com, a direct bank. X.com merged with Confinity in 2000 to form PayPal, which eBay acquired for $1.5 billion in 2002. Musk received an EB-5 investor green card in 1997, which led to his U.S. citizenship in 2002.With $175.8 million, Musk founded SpaceX in 2002, a spaceflight services company. In 2004, he was an early investor in the electric vehicle manufacturer Tesla Motors, Inc. (Tesla, Inc.). He became its chairman and product architect, assuming the position of CEO in 2008. In 2006, he helped create SolarCity, a solar energy company that was later acquired by Tesla and became Tesla Energy. In 2015, he co-founded OpenAI, a nonprofit artificial intelligence research company. The following year, he co-founded Neuralink—a neurotechnology company developing brain–computer interfaces—and the Boring Company, a tunnel construction company. Musk has also proposed a hyperloop high-speed vactrain transportation system. In 2022, his acquisition of Twitter for $44 billion was completed. 
Musk has made controversial statements on politics and technology, particularly on Twitter, and is a polarizing figure. He has been criticized for making unscientific and misleading statements, including spreading COVID-19 misinformation. In 2018, the U.S. Securities and Exchange Commission (SEC) sued Musk for falsely tweeting that he had secured funding for a private takeover of Tesla. Musk stepped down as chairman of Tesla and paid a $20 million fine as part of a settlement agreement with the SEC.

Page: Acquisition of Twitter by Elon Musk
Summary: Business magnate Elon Musk initiated an acquisition of American social media company Twitter, Inc. on April 14, 2022, and concluded it on October 27, 2022. Musk had begun buying shares of the company in January 2022, becoming its largest shareholder by April with a 9.1 percent ownership stake. Twitter invited Musk to join its board of directors, an offer he initially accepted before declining. On April 14, Musk made an unsolicited offer to purchase the company, to which Twitter's board initially responded with a "poison pill" strategy to resist a hostile takeover, before unanimously accepting Musk's buyout offer of $44 billion on April 25. Musk stated that he planned to introduce new features to the platform, make its algorithms open-source, combat spambot accounts, and promote free speech.
In July, Musk announced his intention to terminate the agreement, asserting that Twitter had breached their agreement by refusing to crack down on spambot accounts. The company filed a lawsuit against Musk in the Delaware Court of Chancery shortly thereafter, with a trial scheduled for the week of October 17. Weeks before the trial was set to begin, Musk reversed course, announcing that he would move forward with the acquisition. The deal was closed on October 27, with Musk immediately becoming Twitter's new owner and CEO. Twitter was taken private and merged into a new parent company named X Corp. Upon acquiring Twitter, Musk promptly fired several top executives, including previous CEO Parag Agrawal. Musk has since proposed several reforms to Twitter and laid off half of the company's workforce. Hundreds of employees then resigned from the company after Musk issued an ultimatum demanding they commit to "extremely hardcore" work.
Reactions to the buyout have been mixed, with praise for Musk's planned reforms and vision for the company, particularly his calls for greater free speech, but criticism over fears of a potential rise in misinformation, disinformation, harassment, and hate speech on the platform. Within the United States, conservatives have largely supported the acquisition, while many liberals and former Twitter employees have voiced concerns about Musk's intentions. Since becoming owner, Musk has faced backlash for his handling of the company and account suspensions.

Page: Views of Elon Musk
Summary: Elon Musk, one of the richest men in the world and the CEO of Tesla, has expressed many views on a wide variety of subjects, ranging from politics to science.
Within the context of American politics, Musk has described himself as being politically moderate. Musk supported George W. Bush in 2004, Barack Obama in 2008 and 2012, Hillary Clinton in 2016, and Joe Biden in 2020. In 2022, Musk said he would start voting for Republican Party candidates. He has stated support for universal basic income, gun rights, freedom of speech, a tax on carbon emissions and opposes government subsidies.Musk is also a prominent critic of short-selling. Musk has expressed concern about issues such as artificial intelligence, climate change and population decline. He has also criticized COVID-19 lockdowns, public transportation, and labor unions.
Thought:I now know the final answer.
Final Answer: Elon Musk, the founder of SpaceX and Tesla, was born on June 28, 1971. The first company he founded was Zip2, which he co-founded with his brother Kimbal in 1995.

> Finished chain.
'Elon Musk, the founder of SpaceX and Tesla, was born on June 28, 1971. The first company he founded was Zip2, which he co-founded with his brother Kimbal in 1995.

最后

链和代理可以互换使用。代理人最有价值的组成部分是:

  1. 默认情况下,执行思维链推理和提示的能力。
  2. 选择和排序适当工具的自主性水平。
  3. 由代理保持的逻辑水平以及达到答案的清晰度。
  4. 代理的上下文窗口非常重要,这可以从代码中使用的问题中看出。这些问题都是隐晦的、模棱两可的、需求链推理和多跳方法。

 

文章链接