跳到主要內容

發表文章

目前顯示的是有「NLU」標籤的文章

快速建立 NLU 模型

Step 1. 準備環境 conda create --name=rasa-env python=3.8 conda activate rasa-env pip install rasa[full] Step 2. 初始化工作目錄 import rasa from rasa.cli.scaffold import create_initial_project create_initial_project("MY_NLP_PROJECT") import os os.chdir("MY_NLP_PROJECT") Step 3. 開始訓練 rasa train nlu Step 4. 測試 #import rasa from rasa.core.agent import Agent interpreter = Agent.load("./models/nlu-20211213-035921-charitable-score.tar.gz") import asyncio import nest_asyncio nest_asyncio.apply() asyncio.run(interpreter.parse_message("kill"))

十分鐘快速了解 Rasa Core

一個聰明的Chatbot 必須要能夠理解使用者說的話, 才能給予最精準的反饋, 要打造出這樣的功能, 可以使用諸如以下的線上語意識別服務 Google DialogFlow, Microsoft Luis, 以及Facebook Wit等等   這些語意識別的服務猶如Chatbot的大腦語言中樞, 用來了解每句對話背後的意圖 有了意圖之後, 程式可以根據意圖的種類來回答問題 if intent == 'MAKE_ORDER' : print( 'okay total price is $100' ) elif intent == 'CHECK_SHOPPING_CART' : print( 'there are milk, beef, ...' ) elif intent == 'CHANGE_PYMENT' : print( 'change complete' ) else: print( 'hi' ) 但光是了解自然語言是不夠的, 若要打造出更人性化的Chatbot, 還需要作到對話管理, 上下文理解等等... Rasa Core 想要作到對話管理, 不妨試試Open Source Rasa Core 功能介紹 Rasa Core可以用神經網路去學習預先定義好的對話邏輯(順序), 學完之後就能根據先前對話的資訊, 來推測Chatbot接下來的最佳反饋應該是什麼 什麼是 Stories, Domain, Action, Policy Stories 用來定義對話邏輯 一個適當的對話一定會有前後順序, 上下文關係, Story 就是用來描述這種上下文關係的資訊 ## happy path               <!-- 故事名 - just for debugging --> * _greet   - utter_greet * _mood_great               <!-- user utteranc...

[簡易教學] 使用Google DialogFlow十分鐘內建立聊天機器人

How to create Google DialogFlow chatbot in10 minutes 前言 隨著Machine Learning的技術越來越成熟, 越來越多的雲端大廠也開始提供自家的AI solution給大眾使用, 如  Google DialogFlow, MS Luis, FB Wit, Amazon Alexa... DialogFlow 是Google 提供的自然語言處理服務, 能夠將文字轉換成電腦看得懂的結構性資料, 再傳遞給後端介接的Web Service處理, 現在的聊天機器人大多都是使用這種架構 DialogFlow response 的簡單範例, { "queryResult" : { "queryText" : "find some hotel in taipei" , "parameters" : { "geo-city" : "Taipei" }, "intent" : { "displayName" : "FindHotel" }, "intentDetectionConfidence" : 1 , "languageCode" : "en" } } intentName 就是使用者意圖, chatbot 可以根據意圖去執行對應的商用邏輯 parameter 則是語句當中的關鍵字, chatbot可以用這些關鍵字當成查詢資料庫的條件, 最後再將答案反饋給使用者  Integration 作為輸入的來源, DialogFlow 目前支援自家的Google Assistant, 還有其他頻道像是 Line, Skype, Facebook ..., 也就是說使用DialogFlow開發的機器人, 不一定只能用在Google Assistant上, 還可以串到Skype, 臉書,,,等等 以下教學, 如何快速建...

Misaligned entity annotation in sentence

I got this information when I tried to train my model. Misaligned entity annotation in sentence The problem is my utterance. for example It was supposed to be "whats the warranty" not "whats thewarranty" It results in Rasa is not able to use start value and end value to extract the entities.