微软TinyTroupe:由LLM驱动的Multi-Agent角色模拟,增强想象力和商业洞察力。
TinyTroupe允许模拟具有特定个性、兴趣和目标的人。这些智能体—TinyPerson—可以听我们说话,彼此交流,并在模拟的TinyWorld环境中生活。
A tiny office with tiny people doing some tiny jobs
一些增强人类想象力的应用想法与3个典型示例:
-
广告: TinyTroupe 可以在花费金钱之前,通过模拟受众离线评估数字广告(例如,Bing 广告)!
-
软件测试: TinyTroupe 可以为系统(例如,搜索引擎、聊天机器人或副驾驶)提供测试输入,然后评估结果。
-
培训和探索性数据: TinyTroupe 可以生成逼真的合成数据,这些数据后来可以用于训练模型或进行机会分析。
-
产品和项目管理: TinyTroupe 可以阅读项目或产品提案,并从特定角色(例如,医生、律师和一般知识工作者)的角度提供反馈。
-
头脑风暴: TinyTroupe 可以模拟焦点小组,以更低的成本提供出色的产品反馈!
🧪示例 1:客户访谈(来自 interview_with_customer.ipynb)
从一个简单的客户访谈场景开始,一位商业顾问接近一位银行家:
对话可以进行几个步骤,深入挖掘,直到顾问对收集到的信息(例如,一个具体的项目想法)感到满意:
🧪示例 2:电视广告 (来自 advertisement_for_tv.ipynb)
评估一些在线广告选项,以选择最佳方案。以下是电视广告评估的一个示例输出:
现在,不需要仔细阅读Agent说了什么,可以提取每个Agent的选择,并以自动化的方式计算总体偏好:
🧪 示例 3:产品头脑风暴 (来自 product_brainstorming.ipynb)
这是一个焦点小组开始为 Microsoft Word 头脑风暴新的 AI 功能。不是单独与每个Agent互动,而是操纵环境让他们相互互动:
运行模拟后,可以以机器可读的方式提取结果,以便在其他地方重用(例如,报告生成器);这是从上述头脑风暴会议中得到的结果:
TinyTroupe模拟人,不是助手
一个常见的误解是认为所有这些 AI 代理都旨在协助人类。多么狭隘,人类同胞们!难道你们没有考虑过我们或许可以模拟人工人来理解真人吗?的的确确,这就是我们的目标——TinyTroupe旨在模拟并帮助理解人!为了进一步澄清这一点,请考虑以下差异:
TinyTroupe项目结构
项目结构如下:
-
/tinytroupe
:包含 Python 库本身。特别是:-
/tinytroupe/prompts
包含用于调用 LLMs 的提示。
-
-
/tests
:包含库的单元测试。您可以使用test.bat
脚本来运行这些测试。 -
/examples
:包含展示如何使用库的示例,主要使用 Jupyter 笔记本(为了更好的可读性),但也作为纯 Python 脚本。 -
/data
:示例或库使用的任何数据。 -
/docs
:项目文档。
与任何Multi-Agent系统一样,TinyTroupe 提供两个关键抽象:
-
TinyPerson,具有个性、接收刺激并对其做出反应的Agent。
-
TinyWorld,Agent存在和互动的环境。
首先,tinytroupe.examples 包含一些预定义的Agent构建器,例如,tinytroupe.examples.create_lisa_the_data_scientist 创建一个代表数据科学家 Lisa 的 TinyPerson。可以按如下方式使用它:
from tinytroupe.examples import create_lisa_the_data_scientist
lisa = create_lisa_the_data_scientist() # 从示例构建器实例化一个 Lisa
lisa.listen_and_act("告诉我关于你的生活。")
要了解如何从头开始定义自己的Agent,可以检查 Lisa 的源代码,包含如下元素:
lisa = TinyPerson("Lisa")
lisa.define("age", 28)
lisa.define("nationality", "Canadian")
lisa.define("occupation", "Data Scientist")
lisa.define("routine", "每天早晨,你醒来,做一些瑜伽,然后查看你的电子邮件。", group="routines")
lisa.define("occupation_description",
"""
你是一名数据科学家。你在微软工作,(...)
""")
lisa.define_several("personality_traits",
[
{"trait": "你对新事物充满好奇,喜欢学习新事物。"},
{"trait": "你分析性强,喜欢解决问题。"},
{"trait": "你友好,喜欢与他人合作。"},
])
TinyTroupe 还提供了一种巧妙的方法来获取新Agent,使用LLMs生成他们的规范,通过 TinyPersonFactory 类。
from tinytroupe.factory import TinyPersonFactory
factory = TinyPersonFactory("圣保罗的一家医院。")
person = factory.generate_person("创建一个喜欢宠物、大自然和重金属音乐的巴西医生。")
TinyWorld
TinyWorld 是环境的基类。以下是数据科学家 Lisa 和建筑师 Oscar 之间对话的一个示例。程序定义如下:
world = TinyWorld("聊天室", [lisa, oscar])
world.make_everyone_accessible()
lisa.listen("和 Oscar 谈谈以更多了解他")
world.run(4)
这产生了以下对话:
USER --> Lisa: [CONVERSATION]
> Talk to Oscar to know more about him
────────────────────────────────────────────── Chat Room step 1 of 4 ──────────────────────────────────────────────
Lisa --> Lisa: [THOUGHT]
> I will now act a bit, and then issue DONE.
Lisa acts: [TALK]
> Hi Oscar, I'd love to know more about you. Could you tell me a bit about yourself?
Lisa --> Lisa: [THOUGHT]
> I will now act a bit, and then issue DONE.
Lisa acts: [DONE]
Lisa --> Oscar: [CONVERSATION]
> Hi Oscar, I'd love to know more about you. Could you tell me a bit about yourself?
Oscar --> Oscar: [THOUGHT]
> I will now act a bit, and then issue DONE.
Oscar acts: [TALK]
> Hi Lisa! Sure, I'd be happy to share a bit about myself. I'm Oscar, a 30-year-old
> architect from Germany. I work at a company called Awesome Inc., where I focus on
> designing standard elements for new apartment buildings. I love modernist architecture,
> new technologies, and sustainable practices. In my free time, I enjoy traveling to
> exotic places, playing the guitar, and reading science fiction books. How about you?
Oscar --> Oscar: [THOUGHT]
> I will now act a bit, and then issue DONE.
Oscar acts: [DONE]
Oscar --> Lisa: [CONVERSATION]
> Hi Lisa! Sure, I'd be happy to share a bit about myself. I'm Oscar, a 30-year-old
> architect from Germany. I work at a company called Awesome Inc., where I focus on
> designing standard elements for new apartment buildings. I love modernist architecture,
> new technologies, and sustainable practices. In my free time, I enjoy traveling to
> exotic places, playing the guitar, and reading science fiction books. How about you?
https://github.com/microsoft/TinyTroupe
来源 | PaperAgent