日本語でのRasaを使用したチャットボットの作成
このガイドでは、Rasa を使用して日本語対応のチャットボットを作成し、「ビッグカメラ」などの IT ガジェットショップでの販売をサポートする方法について説明します。
より実践的な連携例については、以下のガイド記事もご覧ください:
👉 チャットボットを強化するための業務API連携サービスの紹介
より詳しい比較記事はこちらもぜひご覧ください:
RasaとChatGPT Builderの違いを徹底解説(日本語対応編)
さらに、次世代の自律型AIエージェントによる業務変革にも興味がある方はこちら:
自律型 Agentic AI で業務を変革する方法
ステップ 1: Rasa のインストール
Python がインストールされていることを確認し、pip を使用して Rasa をインストールします。
pip install rasa
ステップ 2: 新しい Rasa プロジェクトを初期化
新しい Rasa プロジェクトを作成します:
rasa init --no-prompt
このコマンドで、デフォルトのプロジェクト構造が生成されます。
ステップ 3: 日本語サポートの追加
config.yml ファイルを編集して、日本語をサポートするようにします。日本語を効果的に処理できるトークナイザーとパイプラインを使用します。
language: ja
pipeline:
- name: "JiebaTokenizer"
- name: "RegexFeaturizer"
- name: "LexicalSyntacticFeaturizer"
- name: "CountVectorsFeaturizer"
analyzer: "word"
- name: "CountVectorsFeaturizer"
analyzer: "char_wb"
min_ngram: 1
max_ngram: 4
- name: "DIETClassifier"
epochs: 100
- name: "EntitySynonymMapper"
- name: "ResponseSelector"
epochs: 100
- name: "FallbackClassifier"
threshold: 0.3
ステップ 4: インテントとレスポンスの定義
domain.yml ファイルに、チャットボットで使用するインテントとレスポンスを定義します。
intents:
- greet
- ask_discount
- ask_camera_features
- check_stock
- thank_you
responses:
utter_greet:
- text: こんにちは!ビッグカメラ IT ガジェットショップへようこそ!
utter_ask_discount:
- text: このカメラは今だけ特別価格で提供されています!どのモデルに興味がありますか?
utter_ask_camera_features:
- text: ご希望のカメラの特徴を教えてください。高画質ですか?ズームレンズですか?
utter_check_stock:
- text: ご希望のモデル名を教えてください。在庫状況を確認します。
utter_thank_you:
- text: ありがとうございます!他に質問があればお気軽にお問い合わせください。
ステップ 5: トレーニングデータの作成
data/nlu.yml ファイルに日本語でトレーニングデータを追加します。
version: "3.0"
nlu:
- intent: greet
examples: |
- こんにちは
- ハロー
- intent: ask_discount
examples: |
- 特別価格の商品はありますか?
- 値引きはありますか?
- intent: ask_camera_features
examples: |
- このカメラにはどんな特徴がありますか?
- 高画質のカメラはどれですか?
- intent: check_stock
examples: |
- このモデルは在庫がありますか?
- 在庫状況を教えてください。
- intent: thank_you
examples: |
- ありがとう
- 感謝します
ステップ 6: カスタムアクションの作成
在庫を確認するカスタムアクションを actions/actions.py ファイルに定義します。
from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
class ActionCheckStock(Action):
def name(self) -> Text:
return "action_check_stock"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
# 在庫情報の例
stock_data = {
"camera_x": "在庫あり",
"camera_y": "在庫なし",
}
model = tracker.get_slot("camera_model")
if model in stock_data:
stock_status = stock_data[model]
response = f"モデル {model} の在庫状況: {stock_status}"
else:
response = "指定されたモデルは見つかりませんでした。"
dispatcher.utter_message(text=response)
return []
domain.yml ファイルを更新して、カスタムアクションとスロットを追加します。
actions:
- action_check_stock
slots:
camera_model:
type: text
ステップ 7: ストーリーの作成
在庫確認のストーリーを data/stories.yml に追加します。
version: "3.0"
stories:
- story: Check Stock
steps:
- intent: check_stock
- action: utter_check_stock
- slot_was_set:
- camera_model: "camera_x"
- action: action_check_stock
ステップ 8: チャットボットのテスト
以下のコマンドを使用してチャットボットを実行します。
rasa train
rasa shell
日本語でテストメッセージを入力して動作を確認します。
ステップ 9: チャットボットのデプロイ
Rasa X を使用するか、ウェブインターフェースと統合してチャットボットをデプロイします。
ステップ 10: 継続的な改善
チャットボットのパフォーマンスを分析し、トレーニングデータを最適化して、さまざまなユーザーの問い合わせに対応できるようモデルを改善します。
Rasa のワークフロー
以下は、Rasa のワークフローを MermaidJS で視覚化したものです。
graph TD
User[ユーザー入力] -->|メッセージ送信| NLU[NLU パイプライン]
NLU -->|インテントとエンティティを分類| Core[Rasa Core]
Core -->|ポリシーに従う| Action[アクションサーバー]
Action -->|カスタムアクションまたはレスポンスを実行| Bot[ボットレスポンス]
Bot -->|ユーザーに返信| User
subgraph Rasa システム
NLU
Core
Action
end
このガイドを参考に、日本語対応の Rasa チャットボットを作成して、「ビッグカメラ」や他の IT ガジェットショップの販売を支援してください。
Get in Touch with us
Related Posts
- The Accounting Software Your Firm Uses Is Built for Your Clients, Not for You
- 2026年本地大模型(Local LLM)硬件选型实用指南
- Choosing Hardware for Local LLMs in 2026: A Practical Sizing Guide
- Why Your Finance Team Spends 40% of Their Week on Work AI Can Now Do
- 用纯开源方案搭建生产级 SOC:Wazuh + DFIR-IRIS + 自研集成层实战记录
- How We Built a Real Security Operations Center With Open-Source Tools
- FarmScript:我们如何从零设计一门农业IoT领域特定语言
- FarmScript: How We Designed a Programming Language for Chanthaburi Durian Farmers
- 智慧农业项目为何止步于试点阶段
- Why Smart Farming Projects Fail Before They Leave the Pilot Stage
- ERP项目为何总是超支、延期,最终令人失望
- ERP Projects: Why They Cost More, Take Longer, and Disappoint More Than Expected
- AI Security in Production: What Enterprise Teams Must Know in 2026
- 弹性无人机蜂群设计:具备安全通信的无领导者容错网状网络
- Designing Resilient Drone Swarms: Leaderless-Tolerant Mesh Networks with Secure Communications
- NumPy广播规则详解:为什么`(3,)`和`(3,1)`行为不同——以及它何时会悄悄给出错误答案
- NumPy Broadcasting Rules: Why `(3,)` and `(3,1)` Behave Differently — and When It Silently Gives Wrong Answers
- 关键基础设施遭受攻击:从乌克兰电网战争看工业IT/OT安全
- Critical Infrastructure Under Fire: What IT/OT Security Teams Can Learn from Ukraine’s Energy Grid
- LM Studio代码开发的系统提示词工程:`temperature`、`context_length`与`stop`词详解













