Coder Social home page Coder Social logo

tf2-transformer-chatbot's Introduction

Transformer Chatbot with TensorFlow 2.1

Build an end-to-end chatbot with Transformer in TensorFlow 2.1. Checkout the my tutorial on blog.tensorflow.org.

Updates

  • 18 Jan 2019: Added notebook with Google Colab TPU support in TensorFlow 2.1.

Packages

pip install -r requirements.txt

Dataset

  • We will use the conversations in movies and TV shows provided by Cornell Movie-Dialogs Corpus, which contains more than 220 thousands conversational exchanges between more than 10k pairs of movie characters, as our dataset.
  • We pre-process our dataset in the following order:
    • Extract max_samples conversation pairs into list of questions and answers.
    • Pre-process each sentence by removing special characters in each sentence.
    • Build tokenizer (map text to ID and ID to text) using TensorFlow Datasets SubwordTextEncoder.
    • Tokenize each sentence and add start_token and end_token to indicate the start and end of each sentence.
    • Filter out sentence that has more than max_length tokens.
    • Pad tokenized sentences to max_length
  • Check dataset.py implementation.

Model

transformer model plot

  • check model.py for the implementation of Multi-Headed Attention, Positional Encoding and Transformer.

Run

  • check all availble flags and hyper-parameters python main.py --help
python main.py --batch_size 256 --epochs 50 --max_samples 50000

Samples

input:		where have you been?
output:		i m not talking about that .

input:		it's a trap!
output:		no , it s not .

tf2-transformer-chatbot's People

Contributors

bryanlimy avatar

Watchers

James Cloos avatar paper2code - bot 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.