GithubHelp home page GithubHelp logo

winleexz / question-and-answer-chatbot-with-dialogflow Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 2.0 147 KB

Question Answering Chatbot with DistilRoBERTa Sentence Embeddings, Dialogflow and Ngrok

Jupyter Notebook 100.00%
dialogflow dialogflow-fulfillment dialogflow-chatbot dialogflow-agent ngrok webhook chatbot conversational-bots distilroberta pre-trained-embeddings

question-and-answer-chatbot-with-dialogflow's Introduction

Question Answering System using DistilRoBERTa Embeddings and Dialogflow

Dialogflow is a natural language understanding platform that makes it easy to design and build a conversational user interface. For question and answering system, it offers a knowledge connector to the knowledge base so that it can generate the responses based on the list of question-answer pairs. At the point of writing, this connector is still a beta feature.

How It Works

Each time a user enters a query into the chatbot, the Dialogflow will send the query to the local server via webhook and ngrok. The model in the local server selects the closest matching response from the knowledge base and then returns the most likely response to the query. This response is then sent back to the user in Dialogflow. In this instance, i have illustrated it with a HR domain example. But any domain works as well.

Overview

Step 1: Set up in Dialogflow

  1. Sign up for a Dialogflow account on https://cloud.google.com/dialogflow/docs/
  2. Create a project and an agent in Dialogflow based on the steps on https://developers.google.com/assistant/conversational/df-asdk/dialogflow/project-agent. If you have multiple intents in the agent, you may add training phrases to this HR_FAQ intent. However, there is no need to add the responses as the responses will be generated from our model in the local server.

Step 2: Develop Model in Python using Flask

Pre-trained DistilRoBERTa model is used to extract the sentence embeddings due to the small number of question-answer pairs in the knowledge base. Other variations of pre-trained model will also work, as long as the response time is within reasonable time limit. RoBERTa model was considered but not selected as the final model as it took about 16 seconds to generate a response as compared to 2 seconds by DistilRoBERTa.

Based on the sentence embeddings, cosine similarity is calculated between the query and questions to identify the most similar question. The model then uses the retrieval approach to search for the corresponding answer that matches the most similar question.

Model

Step 3: Deploy Model & Integrate with Dialogflow using Webhook & Ngrok

  1. Download ngrok on your computer at https://ngrok.com/download. It is a popular tunneling tool to expose the application to the internet and receive the webhook from Dialogflow to the application.
  2. Start ngrok.
  3. We assume that our application is running locally on port 5000 for flask. Hence, type in "ngrok http 5000" into the ngrok application.
  4. Copy the https forwarding address to integrate with Dialogflow.
  5. Paste the https url to the Webhook field in the Fulfillment tab of Dialogflow. Add "/webhook" to the end of the url. The format of the final url will look like https://xxxxxxxxxxxx.io/webhook. For more information, you may refer to the "Enable and manage fulfillment" section on https://cloud.google.com/dialogflow/es/docs/fulfillment-webhook
  6. To enable fulfillment, go to the HR_FAQ intent and turn on the "enable webhook call for this intent". Click save.

Step 4: Test the Chatbot

Enter a test query in the test console of Dialogflow to make sure that the chatbot is working well.

question-and-answer-chatbot-with-dialogflow's People

Stargazers

 avatar  avatar  avatar

Watchers

 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.