Giter VIP home page Giter VIP logo

rasa-faq-bot's Introduction

rasa-faq-bot

Using Rasa to build a FAQ bot 中文版本

GitHub stars GitHub issues GitHub license

Introduction

Rasa is a powerful dialog framework that we can easily use it to build a practical dialog system.

FAQ(Frequently Asked Questions) bot is the most important part of the smart customer service products, which help users to solve general problems.

Usually we collect common questions and answers from actual scenarios and we call these standard question-and-answer pairs for the knowledge base. FAQ-bot will intelligently answer user questions based on this knowledge base.

So, in this project, we will use Rasa to build a smart faq-bot!

Get Started

1. Run the shell and activate bert-service

We store the knowledge in data/nlu/faq.json,which includes lots of question-and-answer pairs. We use bert-service to calculate the similarity between the user question and the questions in the knowledge base. Then we choose the most similar question and return the corresponding answer to the user.

  • Specific operation:
    • Install bert-serving-server and bert-serving-client,More information about bert-as-service
    • Download pre-trained BERT model,unzip it(for example, cased_L-24_H-1024_A-16.zip).
    • Next, you need to change "BERT_ENGLISH_MODEL_DIR" into your model path
      -bert-serving-start \
      -pooling_layer -4 -3 -2 -1 \
      -model_dir=BERT_ENGLISH_MODLE_DIR \
      -num_worker=8 \
      -max_seq_len=16
    • Run the shell
     ./run_bert_service.sh

2. Run Rasa custom actions

We design our own customer actions in actions.py which which is how the dialog responds to the user when it receives the customer's information. If the user's intent is faq, then go to the knowledge base to find the best match and give the user answers. If there is no match to the right question, we will also tell the user "Sorry, this question is beyond my ability."

  • Change the port in endpoints.yml to keep the port the same as the port of rasa actions(default port is 5055):
action_endpoint:
  url: "http://localhost:5055/webhook"
  • Run rasa actions:
rasa run actions

Then you can get a log like this:

│2019-08-09 11:10:32 INFO     rasa_sdk.endpoint  - Starting action endpoint server...
│(1000, 3072)
│2019-08-09 11:10:33 INFO     rasa_sdk.executor  - Registered function for 'action_get_answer'.
│2019-08-09 11:10:33 INFO     rasa_sdk.endpoint  - Action endpoint is up and running. on ('0.0.0.0', 5055)

3. Run Rasa X

rasa x

And you can get a log like this:

Starting Rasa X in local mode... �🚀                                                                                               
 
The server is running at http://localhost:5005/login?username=me&password=zrjV0BwYSzYP

Copy the link into your browser, then you can access your rasa x page.

Dialog example

4. Note

  • Sometimes when the service is started, the port is already in use. At this time, it is better to kill the process of the relevant port directly.
  • If the error is about the database is locked,just delete rasa.db and tracker.db.
  • You'd better use compatible rasa and rasa x,this project uses rasa 1.2.2 and rasa x 0.20.1(they are compatible)
  • Use your own data to train a model:
    • Follow the data foemat in data/nlu/faq.json,replace it by your own data
    • Run process.py(Default data size is at most 1000 pieces,you can modify the process.py on your own)
    • Run actions.py

rasa-faq-bot's People

Contributors

1120172175 avatar nghuyong avatar usvyatsky avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.