自然语言处理学习日记7

1.对话管理模块
解析:对话管理[DM]控制着人机对话的进程,对话管理通过对自然语言理解模块的输出[即意图、槽位、槽位信息]的处理来进行和用户的交互和反应。针对带着明确意图的用户,在对话管理过程中用户不但可以完善或修正自己需求,管理系统也可以在用户需求不够具体的时候明确或者澄清用户的需求,以达到最终的任务完成。对话系统主要包括2部分,分别为状态追踪和对话策略。

2.状态追踪模块
解析:状态追踪模块包括持续对话的各种信息,根据旧状态、用户状态[意图、槽位、槽位信息]与系统状态[即通过与数据库的查询情况]来更新当前的对话状态。对话策略与所在任务场景息息相关,通常作为对话管理模块的输出,比如对该场景下缺失槽位的反问策略等。如下所示:
[1]对话状态维护:根据上一个时刻的状态和系统行为,结合当前时刻状态下的用户行为,来确定当前时刻的对话状态。
[2]生成系统决策:根据当前时刻的对话状态以及产生的系统行为,决定下一步的系统行为,可以表示观测到的用户输入,以及系统的反馈行为。

3.MITIE
解析:MITIE即MIT的NLP团队发布的一个信息抽取库和工具。它是一款免费且先进的信息抽取工具,目前包含了命名实体抽取、二元关系检测功能,另外也提供了训练自定义抽取器和关系检测器的工具。如下所示:

git clone https://github.com/mit-nlp/MITIE.git
cd MITIE
python setup.py install
from mitie import *

4.Rasa组成
解析:
[1]Rasa NLU:只要实现自然语言理解功能,本质上就是识别句子的意图和实体。
[2]Rasa Core:对话状态跟踪和对话策略学习。
[3]Rasa X:可视化编辑工具,更方便NLU、NLG数据的管理,故事的编写。
[4]Rasa UI:一个用于Rasa NLU后端的Web应用程序。
[5]rasa-sdk:SDK for the development of custom actions for Rasa.

5.Rasa工程目录
解析:
[1]__init__.py:an empty file that helps python find your actions
[2]actions.py:code for your custom actions
[3]config.yml[重要]:configuration of your NLU and Core models
[4]credentials.yml:details for connecting to other services
[5]data/nlu.md[重要]:your NLU training data
[6]data/stories.md[重要]:your stories
[7]domain.yml[重要]:your assistant’s domain
[8]endpoints.yml:details for connecting to channels like fb messenger
[9]models/<timestamp>.tar.gz:your initial model

6.Rasa X
解析:
[1]Understand messages
[2]Hold conversations
[3]Interactive learning
[4]Connect to messaging channels and APIs
[5]View and annotate conversations
[6]Get feedback from testers
[7]Version and manage models
[8]Deploy anywhere
[8]Analytics
[10]Role-based access control
[11]Multiple deployment environments
[12]Single Sign On
[13]Service Level Agreements [SLAs]

7.安装Rasa和Rasa X
解析:pip install rasa-x --extra-index-url https://pypi.rasa.com/simple

8.单独安装Rasa
解析:pip install rasa

9.Rasa命令
解析:
[1]rasa init:使用示例训练数据,操作和配置文件创建新项目
[2]rasa train:使用NLU数据和故事训练模型
[3]rasa interactive:启动交互式学习会话,通过聊天创建新的训练数据
[4]rasa shell:加载训练有素的模型,并在命令行上与助手交谈
[5]rasa run:使用训练有素的模型启动Rasa服务器
[6]rasa run actions:使用Rasa SDK启动操作服务器
[7]rasa visualize:可视化故事
[8]rasa test:使用测试NLU数据和故事测试训练有素的Rasa模型
[9]rasa data split nlu:根据指定的百分比执行NLU数据的拆分
[10]rasa data convert nlu:在不同格式之间转换NLU训练数据
[11]rasa -h:显示所有可用命令

10.OpenShift
解析:OpenShift是红帽的云开发平台即服务[PaaS]。

11.pip install -e .
解析:

pip install [options] [-e] <vcs project url> ...
pip install [options] [-e] <local project path> ...

12.virtualenv
解析:

pip install virtualenv
virtualenv -p /usr/bin/python --no-site-packages xxx
source venv/bin/activate
deactivate

13.virtualenvwrapper
解析:

pip install virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/.vitualenvwrapper.sh
mkvirtualenv -p /usr/bin/python xxx
workon xxx
deactivate

说明:无论是virtualenv还是virtualenvwrapper在Ubuntu 16.04上面都不行。

14.Ubuntu16.04使用Python建立虚拟环境
解析:

python3 -m venv venv_name
source venv_name/bin/activate

15.Slack
解析:Slack是聊天群组+大规模工具集成+文件整合+统一搜索。截至2014年底,Slack已经整合了电子邮件、短信、Google Drives、Twitter、Trello、Asana、GitHub等65种工具和服务,可以把各种碎片化的企业沟通和协作集中到一起。

16.对话系统Rasa中的Actions
解析:Actions是机器针对用户输入的响应,Rasa中有四种actions:
[1]Utterance actions:以utter_开头,用来发送特定的消息给用户。
[2]Retrieval actions:以respond_开头,用来发送检索模型挑选的消息。
[3]Custom actions:运行任意代码,发送任意数量的消息。
[4]Default actions:比如,action_listen,action_restart,action_default_fallback。

17.Rasa Core核心概念
解析:intents,entities,slots,templates,actions,domains,stories,responses,forms,policies。

18.Rasa入门例子
[1]创建一个新的工程

  • __init__.py:an empty file that helps python find your actions
  • actions.py:code for your custom actions
  • config.yml[*]:configuration of your NLU and Core models
  • credentials.yml:details for connecting to other services
  • data/nlu.md[*]:your NLU training data
  • data/stories.md[*]:your stories
  • domain.yml[*]:your assistant’s domain
  • endpoints.yml:details for connecting to channels like fb messenger
  • models/<timestamp>.tar.gz:your initial model

[2]查看NLU训练数据
nlu.md是训练rasa nlu模块的数据集。
[3]定义模型配置
主要是rasa nlu和rasa core的配置,比如language、pipeline、policies等。
[4]写第一个故事[Story]
stories.md是训练rasa core模块的数据集。
[5]定义一个Domain
domain.yml主要包括intents、templates、actions等。

  • intents:things you expect users to say
  • actions:things your assistant can do and say
  • templates:template strings for the things your assistant can say

[6]训练一个模型[Model]
模型将会存储在models/目录中。
[7]和聊天机器人[Chatbot]对话
可以通过rasa shell[命令行]或者rasa x[web界面]的方式进行对话。

19.tensorflow安装
pip install tensorflow==1.15.0 --trusted-host pypi.douban.com

20.rasa-sdk
解析:使用该sdk写个性化的action,对应的文件为actions.py。pip install rasa-sdk。开启action服务的命令为:rasa run actions。如果没有安装rasa,那么使用命令python -m rasa_sdk --actions actions。默认的action如下所示:

  • action_listen
  • action_restart
  • action_default_fallback
  • action_deactivate_form
  • action_revert_fallback_events
  • action_default_ask_affirmation
  • action_default_ask_rephrase
  • action_back

21.Klein
解析:Klein是一个使用Python来开发可用于生产环境Web服务的微型框架。它基于使用非常广泛且经过良好测试的组件,比如Werkzeug和Twisted,以及近乎完全的测试覆盖率。

22.Form Events
解析:
[1]A form action event [e.g. - restaurant_form] is used in the beginning when first starting a form, and also while resuming the form action when the form is already active.
[2]A form activation event [e.g. - form{“name”: “restaurant_form”}] is used right after the first form action event.
[3]A form deactivation event [e.g. - form{“name”: null}], which is used to deactivate the form.

23.Slot Events
解析:Slot events are written as - slot{“slot_name”: “value”}. If your custom action resets a slot value to None, the corresponding event for that would be -slot{“slot_name”: null}.

24.rasa中的story
解析:Story样本数据就是Rasa Core对话系统要训练的样本,它描述了人机对话交互过程成可能出现的故事情节,通过对Stories样本和domain的训练得到人机对话系统所需的对话模型。

25.可视化Stories
解析:Rasa Core中提供了rasa_core.visualize模块可视化故事,这有利于更容易掌握设计故事流程。命令如下:

python -m rasa_core.visualize -d domain.yml -s data/stories.md -o graph.html -c config.yml

其中,-m指定运行模块;-d指定domain.yml文件路径;-s指定story路径;-o指定输出文件名;-c指定Policy配置文件。最终,在项目根目录得到一个graph.html,用浏览器即可打开。

参考文献:
[1]《聊天机器人:入门、进阶与实战》
[2]mit-nlp/MITIE:https://github.com/mit-nlp/MITIE
[3]paschmann/rasa-ui:https://github.com/paschmann/rasa-ui
[4]Training Data Format:https://rasa.com/docs/rasa/nlu/training-data-format/#training-data-format
[5]Choosing a Pipeline:https://rasa.com/docs/rasa/nlu/choosing-a-pipeline/#choosing-a-pipeline
[6]Policies:https://rasa.com/docs/rasa/core/policies/#policies
[7]Stories:https://rasa.com/docs/rasa/core/stories/#stories
[8]Actions:https://rasa.com/docs/rasa/core/actions/#custom-actions
[9]Forms:https://rasa.com/docs/rasa/core/forms/#forms
[10]Messaging and Voice Channels:https://rasa.com/docs/rasa/user-guide/messaging-and-voice-channels/#messaging-and-voice-channels
[11]Components:https://rasa.com/docs/rasa/nlu/components/#components
[12]Entity Extraction:https://rasa.com/docs/rasa/nlu/entity-extraction/#entity-extraction
[13]Rasa Community Forum:https://forum.rasa.com/
[14]Control your own automation destiny:https://rasa.com/product/pricing/
[15]Virtualenv:https://virtualenv.pypa.io/en/latest/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

NLP工程化

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值