Lesson 10 Telephone Conversation 2

博客包含诊所预约和长途电话的交流内容。在诊所预约中,患者与工作人员确定下午4点看诊;长途电话则询问拨打方式并提供号码。还列举了不同场景下的语句替换示例。

Hello ,Dr.Chen's clinic.May i help you?

Yes ,please. I'd like to make an appoinment to see Dr.Chen.

What's  your name,please?

My neame is Micky Chen.

Is 4 o'olock in the afternoon ok?

That's fine. Thank you.

 

I would like to make a long -distance call to California,please.

Person to person or station to station?

station to station.What's the number.please.

Area code 415,789-0277

One moment ,please.

Thank you.

 

substitution

 One

Hello,Dr.Chen's clinic.

Hello,Dr.Chen,s office.

Hello ,this is Dr.Chen's clinic.

Hello ,this is Dr.Chen's office.

Two

May I help you?

Can I help you?

What can I do for you?

Three

I'd like to make an appointment to see Dr.Chen.

I'd like to have a cup of tea.

I'd like to go with you.

Four

Is 4 o'olock in the afternoon ok?

Is 4 o'olock in the afternoon fine?

Is 4o'olock in the afternoon all right?

Five

I would like to make a long -distance call to California ,please.

I would like to place a long -distance call to California,please。

 You know some birds are not meant to be caged, their feathers are just too bright.

Conversation记忆存储主要涉及不同类型的记忆组件,其原理、方法和应用各有特点。 ### 原理 - **ConversationBufferMemory**:该组件的原理是记住每次与大语言模型(LLM)的对话内容,并在下一轮对话时将历史对话记录全部传给LLM,使LLM能够记住之前的对话内容,从而在后续对话中结合历史信息生成回复 [^3]。 - **ConversationSummaryMemory**:这种记忆类型会随着时间的推移创建对话的摘要。它对发生的对话进行总结,并将当前摘要存储在内存中,原理在于通过摘要的方式压缩对话中的信息,避免在提示中逐字保留过去的消息历史记录占用太多令牌 [^2]。 ### 方法 - **ConversationBufferMemory**:在Python代码中,通过`langchain.memory`导入`ConversationBufferMemory`类,然后实例化该类创建记忆力组件,再将其加入到`ConversationChain`中,实现对话内容的存储和传递。示例代码如下: ```python import os from dotenv import load_dotenv, find_dotenv _ = load_dotenv(find_dotenv()) # read local .env file import warnings warnings.filterwarnings('ignore') from langchain.chat_models import ChatOpenAI from langchain.chains import ConversationChain from langchain.memory import ConversationBufferMemory llm = ChatOpenAI(temperature=0.0) # 定义ConversationBufferMemory记忆力组件 memory = ConversationBufferMemory() conversation = ConversationChain( llm=llm, memory=memory, # 加入ConversationBufferMemory组件 verbose=True ) ``` - **ConversationSummaryMemory**:目前引用中未提及具体实现方法,但推测是在对话过程中不断对新的对话内容进行总结,并更新存储的摘要。 ### 应用 - **ConversationBufferMemory**:适用于需要LLM完整了解对话历史的场景,例如简单的问答系统,用户可能会基于之前的问题进行追问,LLM可以根据完整的历史对话提供更准确的回答 [^3]。 - **ConversationSummaryMemory**:对于较长的对话最为有用,如长时间的客服对话、多轮的咨询问答等场景,在这些场景中,逐字保留过去的消息历史记录会占用太多令牌,而通过摘要的方式可以在不占用过多资源的情况下,让LLM了解对话的大致内容 [^2]。
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值