news 2026/5/28 18:54:02

BERT模型应用智能客服方案

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
BERT模型应用智能客服方案

方案旨在解决企业自有业务场景下,且设备预算有限的小成本智能客服方案。bert模型可运行在仅CPU设备环境,且相应速度迅速,可实现企业级智能体的搭建需求。同时结合freeswitch语音识别,即可完成呼叫中心智能客服功能,freeswitch语音识别可参照往期文章,有业务需求可邮箱mokeily99@126.com或主页咨询

一、bert模型功能

  • 文本分类(如情感分析)
  • 命名实体识别(NER)
  • 意图判断
  • 语义相似度计算

模型可以通过少量数据的训练及微调即可实现简单的智能客服功能

二、应用方案

1、数据清洗

针对准备好的训练数据和用户提问进行数据清洗,包括分词、停用词剔除等操作,使意图更加明确和清晰

2、bert模型选型

前期尝试了bert的bert-base-chinese中文模型,但是该模型词语完整性边界不足,bert-base-chinese是按照单个字来作为边界,这对于中文分析有一定局限性,所以选择了chinese-bert-wwm-ext模型。chinese-bert-wwm-ext模型是以词作为词语边界。能够很好的针对中文进行分析和判断。方案使用chinese-bert-wwm-ext核心逻辑就是通过用户输入判断用户意图从而实现对应回答。

3、模型训练微调

刚下载下来的模型是没法直接应用到某个领域的,需要喂数据进行学习,模型就像一个刚毕业的大学生,虽然很聪明且有一定学习基础,但是在某个领域是无法成为专家的,进到企业后通过工作学习后才能迅速掌握专业知识和能力。bert模型通过几十条或几百条数据训练即可完成一个简单的智能体例如(数据建议又针对性以及不通语句相同含义数据):

{"text": "我想订一张明天去北京的机票", "intent": "book_ticket", "slots": {"time": "明天", "destination": "北京"}}, {"text": "查询一下上海的天气", "intent": "query_weather", "slots": {"location": "上海"}}, {"text": "帮我查一下订单", "intent": "query_order", "slots": {}}, {"text": "后天去上海", "intent": "book_ticket", "slots": {"time": "后天", "destination": "上海"}}, {"text": "出发地是广州", "intent": "book_ticket", "slots": {"origin": "广州"}}, {"text": "你好", "intent": "greeting", "slots": {}}, {"text": "把时间改成上午", "intent": "modify_slot", "slots": {"time": "上午"}}, {"text": "预订下周一从深圳到杭州的机票", "intent": "book_ticket", "slots": {"time": "下周一", "origin": "深圳", "destination": "杭州"}}, {"text": "北京今天天气怎么样", "intent": "query_weather", "slots": {"location": "北京", "time": "今天"}}, {"text": "我要买两张后天去成都的票", "intent": "book_ticket", "slots": {"number": "两张", "time": "后天", "destination": "成都"}}, {"text": "从武汉出发", "intent": "book_ticket", "slots": {"origin": "武汉"}}, {"text": "目的地是南京", "intent": "book_ticket", "slots": {"destination": "南京"}}, {"text": "帮我取消订单", "intent": "cancel_order", "slots": {}}, {"text": "上海明天会下雨吗", "intent": "query_weather", "slots": {"location": "上海", "time": "明天"}}, {"text": "谢谢", "intent": "thanks", "slots": {}}, {"text": "我想查询从北京到上海的航班", "intent": "book_ticket", "slots": {"origin": "北京", "destination": "上海"}}, {"text": "广州的天气如何", "intent": "query_weather", "slots": {"location": "广州"}}, {"text": "帮我预订明天的机票", "intent": "book_ticket", "slots": {"time": "明天"}}, {"text": "我要去深圳", "intent": "book_ticket", "slots": {"destination": "深圳"}}, {"text": "订单号是多少", "intent": "query_order", "slots": {}}, {"text": "订一张后天飞往成都的机票", "intent": "book_ticket", "slots": {"time": "后天", "destination": "成都"}}, {"text": "查询北京后天的天气", "intent": "query_weather", "slots": {"location": "北京", "time": "后天"}}, {"text": "从北京到上海的航班", "intent": "book_ticket", "slots": {"origin": "北京", "destination": "上海"}}, {"text": "明天去广州", "intent": "book_ticket", "slots": {"time": "明天", "destination": "广州"}}, {"text": "预订深圳的机票", "intent": "book_ticket", "slots": {"destination": "深圳"}}, {"text": "杭州天气怎么样", "intent": "query_weather", "slots": {"location": "杭州"}}, {"text": "我要订下周三去武汉的票", "intent": "book_ticket", "slots": {"time": "下周三", "destination": "武汉"}}, {"text": "查询南京的天气", "intent": "query_weather", "slots": {"location": "南京"}}, {"text": "从成都出发去北京", "intent": "book_ticket", "slots": {"origin": "成都", "destination": "北京"}}, {"text": "帮我订一张机票", "intent": "book_ticket", "slots": {}}, {"text": "今天天气如何", "intent": "query_weather", "slots": {"time": "今天"}}, {"text": "预订后天去西安的航班", "intent": "book_ticket", "slots": {"time": "后天", "destination": "西安"}}, {"text": "查询一下订单状态", "intent": "query_order", "slots": {}}, {"text": "我要退掉订单", "intent": "cancel_order", "slots": {}}, {"text": "早上好", "intent": "greeting", "slots": {}}, {"text": "从上海到广州的机票", "intent": "book_ticket", "slots": {"origin": "上海", "destination": "广州"}}, {"text": "明天北京的天气", "intent": "query_weather", "slots": {"location": "北京", "time": "明天"}}, {"text": "订两张去深圳的票", "intent": "book_ticket", "slots": {"number": "两张", "destination": "深圳"}}, {"text": "查询广州今天气温", "intent": "query_weather", "slots": {"location": "广州", "time": "今天"}}, {"text": "我要去北京出差", "intent": "book_ticket", "slots": {"destination": "北京"}}, {"text": "下个月去上海", "intent": "book_ticket", "slots": {"time": "下个月", "destination": "上海"}}, {"text": "从杭州出发", "intent": "book_ticket", "slots": {"origin": "杭州"}}, {"text": "目的地成都", "intent": "book_ticket", "slots": {"destination": "成都"}}, {"text": "帮我查订单", "intent": "query_order", "slots": {}}, {"text": "取消我的预订", "intent": "cancel_order", "slots": {}}, {"text": "您好", "intent": "greeting", "slots": {}}, {"text": "预订明天从北京到上海的机票", "intent": "book_ticket", "slots": {"time": "明天", "origin": "北京", "destination": "上海"}}, {"text": "上海后天天气", "intent": "query_weather", "slots": {"location": "上海", "time": "后天"}}, {"text": "我要三张去武汉的票", "intent": "book_ticket", "slots": {"number": "三张", "destination": "武汉"}}, {"text": "查询深圳的天气情况", "intent": "query_weather", "slots": {"location": "深圳"}}, {"text": "从乌鲁木齐到北京的航班", "intent": "book_ticket", "slots": {"origin": "乌鲁木齐", "destination": "北京"}}, {"text": "预订去乌鲁木齐的机票", "intent": "book_ticket", "slots": {"destination": "乌鲁木齐"}}, {"text": "从哈尔滨到广州", "intent": "book_ticket", "slots": {"origin": "哈尔滨", "destination": "广州"}}, {"text": "明天从西安出发", "intent": "book_ticket", "slots": {"time": "明天", "origin": "西安"}}, {"text": "去呼和浩特", "intent": "book_ticket", "slots": {"destination": "呼和浩特"}}, {"text": "从石家庄到郑州", "intent": "book_ticket", "slots": {"origin": "石家庄", "destination": "郑州"}}, {"text": "预订拉萨的机票", "intent": "book_ticket", "slots": {"destination": "拉萨"}}, {"text": "从银川出发去西宁", "intent": "book_ticket", "slots": {"origin": "银川", "destination": "西宁"}}, {"text": "查询乌鲁木齐的天气", "intent": "query_weather", "slots": {"location": "乌鲁木齐"}}, {"text": "哈尔滨今天气温", "intent": "query_weather", "slots": {"location": "哈尔滨", "time": "今天"}}, {"text": "从北京飞往上海", "intent": "book_ticket", "slots": {"origin": "北京", "destination": "上海"}}, {"text": "自广州到深圳", "intent": "book_ticket", "slots": {"origin": "广州", "destination": "深圳"}}, {"text": "由成都出发", "intent": "book_ticket", "slots": {"origin": "成都"}}, {"text": "前往杭州", "intent": "book_ticket", "slots": {"destination": "杭州"}}, {"text": "到达南京", "intent": "book_ticket", "slots": {"destination": "南京"}}, {"text": "从重庆到武汉的航班", "intent": "book_ticket", "slots": {"origin": "重庆", "destination": "武汉"}}, {"text": "明天从天津出发去北京", "intent": "book_ticket", "slots": {"time": "明天", "origin": "天津", "destination": "北京"}}, {"text": "后天从长沙到厦门", "intent": "book_ticket", "slots": {"time": "后天", "origin": "长沙", "destination": "厦门"}}, {"text": "大后天去昆明", "intent": "book_ticket", "slots": {"time": "大后天", "destination": "昆明"}}, {"text": "从贵阳出发到南宁", "intent": "book_ticket", "slots": {"origin": "贵阳", "destination": "南宁"}}, {"text": "预订下周一从青岛到大连的机票", "intent": "book_ticket", "slots": {"time": "下周一", "origin": "青岛", "destination": "大连"}}, {"text": "从苏州到无锡", "intent": "book_ticket", "slots": {"origin": "苏州", "destination": "无锡"}}, {"text": "明天从宁波出发", "intent": "book_ticket", "slots": {"time": "明天", "origin": "宁波"}}, {"text": "去温州", "intent": "book_ticket", "slots": {"destination": "温州"}}, {"text": "从福州到台北", "intent": "book_ticket", "slots": {"origin": "福州", "destination": "台北"}}, {"text": "预订海口的机票", "intent": "book_ticket", "slots": {"destination": "海口"}}, {"text": "从三亚出发", "intent": "book_ticket", "slots": {"origin": "三亚"}}, {"text": "明天从兰州到西宁", "intent": "book_ticket", "slots": {"time": "明天", "origin": "兰州", "destination": "西宁"}}, {"text": "从包头到鄂尔多斯", "intent": "book_ticket", "slots": {"origin": "包头", "destination": "鄂尔多斯"}}, {"text": "查询呼和浩特的天气", "intent": "query_weather", "slots": {"location": "呼和浩特"}}, {"text": "拉萨明天天气", "intent": "query_weather", "slots": {"location": "拉萨", "time": "明天"}}, {"text": "从乌鲁木齐飞往北京", "intent": "book_ticket", "slots": {"origin": "乌鲁木齐", "destination": "北京"}}, {"text": "预订明天从哈尔滨到广州的机票", "intent": "book_ticket", "slots": {"time": "明天", "origin": "哈尔滨", "destination": "广州"}}, {"text": "从西安到成都的航班", "intent": "book_ticket", "slots": {"origin": "西安", "destination": "成都"}}, {"text": "后天从重庆出发去昆明", "intent": "book_ticket", "slots": {"time": "后天", "origin": "重庆", "destination": "昆明"}}, {"text": "从贵阳到桂林", "intent": "book_ticket", "slots": {"origin": "贵阳", "destination": "桂林"}}, {"text": "明天去张家界", "intent": "book_ticket", "slots": {"time": "明天", "destination": "张家界"}}, {"text": "从珠海到澳门", "intent": "book_ticket", "slots": {"origin": "珠海", "destination": "澳门"}}, {"text": "预订下个月从厦门到台北的机票", "intent": "book_ticket", "slots": {"time": "下个月", "origin": "厦门", "destination": "台北"}}, {"text": "从烟台到威海", "intent": "book_ticket", "slots": {"origin": "烟台", "destination": "威海"}}, {"text": "明天从徐州出发", "intent": "book_ticket", "slots": {"time": "明天", "origin": "徐州"}}, {"text": "去洛阳", "intent": "book_ticket", "slots": {"destination": "洛阳"}}, {"text": "从开封到郑州", "intent": "book_ticket", "slots": {"origin": "开封", "destination": "郑州"}},

4、业务逻辑设计

bert模型虽然有着自己的独特优点,但是也存在一定缺陷,bert模型是单论语义编码器所以记忆功能需要手动实现。单次目的性对话周期可以通过模型+槽位来实现,例如用户想预定明天北京到上海的机票,通过模型+槽位的方式即可实现以下功能

用户:我想预定机票 机器人客服:请问您要从哪里出发? 用户:北京 机器人客服:请问目的地是哪? 用户:上海 机器人客服:请问出发时间是什么时候? 用户:明天上午 机器人客服:好的,已为您预定明天上午从北京到上海的机票。

这样一次单目的性对话即可完成,系统可根据模型意图结合对应槽位进行话术变更,本例中槽位分别是“出发地","目的地","时间"。

多次目的性对话就需要手动进行存储和调取来精准识别用户意图。例如用户完成以上对话后,又发起新的订票对话,我们就需要判断用户是否要改签或者退订上次的机票。所以多轮对话就要根据实际业务场景进行灵活改动

三、测试样例

按照以上方案做了一个小的测试样例,用户可以通过页面回话输入问题得到相应回答。由于没有回话存储和数据入库所以多轮对话没法做出正确调整,只是作为展示样例供参考。如有合作意向可邮箱或主页联系

训练数据没有全面覆盖,只是简单演示模型

智能客服测试系统http://123.56.168.73:5000/

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/5/28 18:54:01

创业团队如何通过Taotoken平衡AI实验成本与模型效果

🚀 告别海外账号与网络限制!稳定直连全球优质大模型,限时半价接入中。 👉 点击领取海量免费额度 创业团队如何通过Taotoken平衡AI实验成本与模型效果 对于资源有限的创业团队和独立开发者而言,在产品原型开发和A/B测试…

作者头像 李华
网站建设 2026/5/28 18:53:03

第13章:AI辅助Gas优化高级技巧——从存储布局到汇编

本章你将收获:存储槽打包(Packing)原理与实现;使用immutable和constant降低Gas;函数选择器冲突与优化;内联汇编优化高频操作;循环与条件短路优化;实战:将高频调用的ERC20转账Gas从80k降至45k;AI辅助分析Gas报告并生成优化方案。 📌 本章导读 Gas优化是智能合约开发…

作者头像 李华
网站建设 2026/5/28 18:49:18

KH Coder终极指南:零代码文本挖掘与内容分析神器

KH Coder终极指南:零代码文本挖掘与内容分析神器 【免费下载链接】khcoder KH Coder: for Quantitative Content Analysis or Text Mining 项目地址: https://gitcode.com/gh_mirrors/kh/khcoder 面对海量文本数据,你是否曾感到无从下手&#xff…

作者头像 李华
网站建设 2026/5/28 18:48:19

BilibiliDown终极指南:三分钟掌握B站视频下载与音频提取技巧

BilibiliDown终极指南:三分钟掌握B站视频下载与音频提取技巧 【免费下载链接】BilibiliDown (GUI-多平台支持) B站 哔哩哔哩 视频下载器。支持稍后再看、收藏夹、UP主视频批量下载|Bilibili Video Downloader 😳 项目地址: https://gitcode.com/gh_mir…

作者头像 李华
网站建设 2026/5/28 18:48:13

SysDVR终极指南:免费实现Switch游戏画面电脑同步的完整教程

SysDVR终极指南:免费实现Switch游戏画面电脑同步的完整教程 【免费下载链接】SysDVR Stream switch games to your PC via USB or network 项目地址: https://gitcode.com/gh_mirrors/sy/SysDVR 你是否渴望将Switch游戏画面无缝传输到电脑大屏幕上&#xff0…

作者头像 李华
网站建设 2026/5/28 18:48:04

AI英语伴学智能体的开发

开发一个AI英语伴学智能体(Agent),核心在于构建一个能够“听懂、会说、能纠错、懂陪伴”的数智化虚拟助教。相比于传统的刷题软件,伴学智能体更强调双向互动和个性化情感陪伴。以下是该系统开发的核心架构与实施路径:一…

作者头像 李华