安装RasaX
Posted dagger
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装RasaX相关的知识,希望对你有一定的参考价值。
brew install postgresql
pip install rasa-x -i https://pypi.rasa.com/simple
python版本要<3.9,否则报错
ERROR: Packages require a different Python. 3.9.6 not in:
\'<3.9,>=3.7\' (required by rasa-x 1.1.4 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-1.1.4-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.9,>=3.7\' (required by rasa-x 1.1.3 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-1.1.3-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.9,>=3.7\' (required by rasa-x 1.1.2 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-1.1.2-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.9,>=3.7\' (required by rasa-x 1.1.1 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-1.1.1-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.9,>=3.7\' (required by rasa-x 1.1.0 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-1.1.0-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.32.5 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.32.5-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.32.4 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.32.4-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.32.3 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.32.3-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.32.2 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.32.2-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.32.1 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.32.1-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.32.0 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.32.0-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.31.6 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.31.6-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.31.5 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.31.5-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.31.4 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.31.4-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.31.3 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.31.3-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.31.2 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.31.2-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.31.1 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.31.1-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.31.0 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.31.0-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.30.1 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.30.1-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.30.0 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.30.0-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.29.3 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.29.3-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.29.2 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.29.2-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.29.1 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.29.1-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.29.0 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.29.0-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.28.6 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.28.6-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.28.5 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.28.5-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.28.4 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.28.4-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.28.3 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.28.3-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.28.2 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.28.2-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.28.1 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.28.1-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.28.0 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.28.0-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.27.8 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.27.8-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.27.7 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.27.7-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.27.6 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.27.6-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.27.5 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.27.5-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.27.4 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.27.4-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.27.3 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.27.3-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.27.2 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.27.2-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.27.1 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.27.1-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
\'<3.8,>=3.6\' (required by rasa-x 0.27.0 (from https://pypi.rasa.com/api/package/rasa-x/rasa_x-0.27.0-py3-none-any.whl (from https://pypi.rasa.com/simple/rasa-x/)))
rasa学习
一、 什么是rasa
Rasa是一个用于自动文本和基于语音的对话的开源机器学习框架。了解消息,保持对话以及连接到消息传递通道和API
官方推荐安装方式(安装rasa和easa X):
pip install rasa-x --extra-index-url https://pypi.rasa.com/simple
如果您不想使用Rasa X,请改为运行
pip install rasa
注意:
如果你想确保为你可能需要的任何组件安装了依赖项,并且你不介意附加的依赖项,你可以使用以下代码安装一切
pip install -r alt_requirements/requirements_full.txt
二、创建一个新项目
1. 创建rasa项目
rasa init --no-prompt
该命令创建Rasa项目所需的所有文件。如果你遗漏了旗帜,你会被问到一些关于你希望如何设置项目的问题。
会创建以下文件:
__init__.py 一个帮助python找到你动作的空文件 actions.py 自定义操作的代码 config.yml ‘*‘ 配置NLU和Core型号 credentials.yml 连接其他服务的详细信息 data/nlu.md ‘*‘ 你的NLU训练数据 data/stories.md ‘*‘ 你的故事 domain.yml ‘*‘ 你助手的域名 endpoints.yml 连接到fb messenger等频道的详细信息 models/<timestamp>.tar.gz 你的初始模型
要检查是否已创建所有文件,请运行:
ls -l
2. 定义一个域
domain.yml文件
intents 你期望用户说的东西。
entities 您想要从消息中提取的信息片段。
actions 你的机器人可以做和说的东西
slots 在会话期间跟踪的信息(例如用户年龄)
templates 你的机器人可以说的东西的模板字符串
intents: - greet - goodbye - mood_affirm - mood_deny - mood_great - mood_unhappy actions: - utter_greet - utter_cheer_up - utter_did_that_help - utter_happy - utter_goodbye templates: utter_greet: - text: "Hey! How are you?" buttons: - title: "great" payload: "great" - title: "super sad" payload: "super sad" utter_cheer_up: - text: "Here is something to cheer you up:" image: "https://i.imgur.com/nGF1K8f.jpg" utter_did_that_help: - text: "Did that help you?" utter_happy: - text: "Great carry on!" utter_goodbye: - text: "Bye"
Rasa Core取intent,entities以及内部的对话状态,并且选择的所述一个actions应该下一个执行。如果该动作只是向用户说明,Rasa将在域中查找匹配模板(动作名称等于完全模板, utter_greet如上例所示),填写所有变量并进行响应。对于不仅仅发送消息的操作,您可以将它们定义为python类,并通过它们的模块路径在域中引用它们。
3. 定义一个解释器
解释器负责解析消息。它执行自然语言理解(NLU)并将消息转换为结构化输出。在这个例子中,我们将使用Rasa NLU来达到这个目的。
在Rasa NLU中,我们需要定义我们的机器人应该能够以Rasa NLU训练数据格式处理的用户消息。在本教程中,我们将使用Markdown格式来获取NLU训练数据。我们来创建一些意图示例data/nlu.md:
## intent:greet - hey - hello - hi - hello there - good morning - good evening - moin - hey there - let‘s go - hey dude - goodmorning - goodevening - good afternoon ## intent:goodbye - cu - good by - cee you later - good night - good afternoon - bye - goodbye - have a nice day - see you around - bye bye - see you later ## intent:mood_affirm - yes - indeed - of course - that sounds good - correct ## intent:mood_deny - no - never - I don‘t think so - don‘t like that - no way ## intent:mood_great - perfect - very good - great - amazing - feeling like a king - wonderful - I am feeling very good - I am great - I am amazing - I am going to save the world - super - extremely good - so so perfect - so good - so perfect ## intent:mood_unhappy - my day was horrible - I am sad - I don‘t feel very well - I am disappointed - super sad - I‘m so sad - sad - very sad - unhappy - not so good - not very good - extremly sad - so saad - so sad
我们现在可以使用我们的示例来训练NLU模型(确保首先 安装Rasa NLU 以及 spaCy)
4. 定义故事
到目前为止,我们已经有了一个NLU模型,一个定义我们的机器人可以采取的动作的域以及它应该处理的输入(意图和实体)。我们仍然错过了中心部分,故事告诉我们的机器人在对话的哪一点做什么。
一个故事是,对话系统训练数据样本。有两种不同的方式来创建故事(你可以混合它们):
- 手动创建故事,直接将它们写入文件
- 使用交互式学习创建故事。
我们将通过直接写入故事来创建故事stories.md。故事以##一个字符串作为标识符开始。用户操作以星号开头,机器人操作由以短划线开头的行指定。故事的结尾用换行符表示。
## happy path <!-- name of the story - just for debugging --> * greet - utter_greet * mood_great <!-- user utterance, in format _intent[entities] --> - utter_happy ## sad path 1 <!-- this is already the start of the next story --> * greet - utter_greet <!-- action of the bot to execute --> * mood_unhappy - utter_cheer_up - utter_did_that_help * mood_affirm - utter_happy ## sad path 2 * greet - utter_greet * mood_unhappy - utter_cheer_up - utter_did_that_help * mood_deny - utter_goodbye ## say goodbye * goodbye - utter_goodbye
请注意,虽然直接用手写故事比使用交互式学习要快得多,但在使用插槽时需要特别小心,因为它们需要在故事中正确设置
5. 命令
rasa init 使用示例训练数据,操作和配置文件创建新项目。
rasa train 使用您的NLU数据和故事训练模型,保存训练有素的模型./models。
rasa interactive 启动交互式学习会话,通过聊天创建新的培训数据。
rasa shell 加载训练有素的模型,并让您在命令行上与助手交谈。
rasa run 使用训练有素的模型启动Rasa服务器。有关详细信息,请参阅运行服务器文档。
rasa run actions 使用Rasa SDK启动操作服务器。
rasa visualize 可视化故事。
rasa test 使用您的测试NLU数据和故事测试训练有素的Rasa模型。
rasa data split nlu 根据指定的百分比执行NLU数据的拆分。
rasa data convert nlu 在不同格式之间转换NLU训练数据。
rasa -h 显示所有可用命令。
以上是关于安装RasaX的主要内容,如果未能解决你的问题,请参考以下文章