1/23

目前实现了 用户智能体的设计 模拟推特简单推文交互


用户智能体设计

langchain作为框架 langsmith数据观测

利用提示词工程实现 角色扮演 记忆存储 写推文 阅读推文的能力

  • 角色扮演

alt text

  • langchain提供的记忆存储功能

alt text

  • 读写推文

利用提示词让用户智能体写/读推文

alt text


推特社交网络实现

推特 两个主要模块 推荐(for you)系统推荐算法 关注(follow)你关注的人发的推文

创建一定数量的用户智能体,输入邻接矩阵表示用户间的关注关系

选择一个用户写一个初始推文,关注他的用户进行阅读,用户阅读后会给出阅读后的感受,由分类器分析读后感受给用户是否支持刚读过的推文进行评级,当达到一定水平用户也会写他的推文。

alt text

采用广度优先 进行一步一步的消息传递

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def social_network_simulation():
network=[
[0,1,1,0,0],
[1,0,1,1,1],
[0,1,0,1,1],
[0,0,1,0,0],
[0,0,0,1,0]
]
agent_list=[]
tweeted_list=[0,0,0,0,0]
send_list=[0,0,0,0,0]
receive_list=[1,0,0,0,0]

for i in range(1,6):
agent = Agent(i)
agent_list.append(agent)

agent_classifier = Classifier()

while sum(receive_list) != 0:
print(receive_list)
send_list = receive_list
receive_list = [0,0,0,0,0]
for i in range(5):
if send_list[i]:
tweeted_list[i]=1
receive_list[i]=0
tweet = agent_list[i].produce_tweet()
for j in range(5):
if network[i][j]:
res = agent_list[j].receive_tweet(tweet, classifier=agent_classifier)
# res = 2
if int(res)>=1 and tweeted_list[j]!=1:
receive_list[j]=1