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/

相关推荐
jinxindeep13 小时前
CVPR26最佳论文提名:NitroGen,面向通用游戏智能体的 视觉-动作基础模型
人工智能·游戏
小雨下雨的雨16 小时前
井字棋AI机器人实现详解 - Minimax算法实战-鸿蒙PC Electron框架完成
前端·人工智能·算法·华为·electron·鸿蒙
我没胡说八道19 小时前
高校论文AI检测优化工具对比研究与实测分析(2026)
人工智能·深度学习·机器学习·计算机视觉·aigc·论文
秦亚伟19 小时前
AI浪潮重塑融资租赁行业新格局
人工智能
love530love19 小时前
LiveTalking 数字人项目 Windows 部署完全指南(EPGF 架构)
人工智能·windows·python·架构·livetalking·epgf
元启数宇19 小时前
喷淋AI布点实战:8小时人工布点→20分钟自动出图
人工智能
哈哈,柳暗花明19 小时前
人工智能专业术语详解(H)
人工智能·专业术语
圣殿骑士-Khtangc19 小时前
AI 编程工具 2026 实战横评:Cursor 3 vs Claude Code vs Copilot,开发者选型完全指南
人工智能·copilot
云器科技19 小时前
云器Lakehouse 2026年5月版本发布:拥抱 AI Agent,重塑数据智能开发新范式
人工智能
小鹰-上海鹰谷-电子实验记录本19 小时前
第六届党建引领科创生态座谈会 | 邓光辉博士出席分享AI赋能创新药科研新范式
人工智能·ai·电子实验记录本·药企合规