All Projects → bryanlimy → tf2-transformer-chatbot

bryanlimy / tf2-transformer-chatbot

Licence: MIT license
Transformer Chatbot in TensorFlow 2 with TPU support.

Programming Languages

Jupyter Notebook
11667 projects
python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to tf2-transformer-chatbot

Seq2seqchatbots
A wrapper around tensor2tensor to flexibly train, interact, and generate data for neural chatbots.
Stars: ✭ 466 (+395.74%)
Mutual labels:  chatbot, transformer
pytorch-transformer-chatbot
PyTorch v1.2에서 생긴 Transformer API 를 이용한 간단한 Chitchat 챗봇
Stars: ✭ 44 (-53.19%)
Mutual labels:  chatbot, transformer
Tensorflow 2.x Tutorials
TensorFlow 2.x version's Tutorials and Examples, including CNN, RNN, GAN, Auto-Encoders, FasterRCNN, GPT, BERT examples, etc. TF 2.0版入门实例代码,实战教程。
Stars: ✭ 6,088 (+6376.6%)
Mutual labels:  tensorflow-tutorials, tensorflow-2
Transformer In Generating Dialogue
An Implementation of 'Attention is all you need' with Chinese Corpus
Stars: ✭ 121 (+28.72%)
Mutual labels:  chatbot, transformer
Chatgirl
ChatGirl is an AI ChatBot based on TensorFlow Seq2Seq Model. ChatGirl 一个基于 TensorFlow Seq2Seq 模型的聊天机器人。(包含预处理过的 twitter 英文数据集,训练,运行,工具代码,来波 Star 。)QQ群:167122861
Stars: ✭ 105 (+11.7%)
Mutual labels:  chatbot, tensorflow-tutorials
Tensorlayer
Deep Learning and Reinforcement Learning Library for Scientists and Engineers 🔥
Stars: ✭ 6,796 (+7129.79%)
Mutual labels:  chatbot, tensorflow-tutorials
Xpersona
XPersona: Evaluating Multilingual Personalized Chatbot
Stars: ✭ 54 (-42.55%)
Mutual labels:  chatbot, transformer
Moel
MoEL: Mixture of Empathetic Listeners
Stars: ✭ 38 (-59.57%)
Mutual labels:  chatbot, transformer
Multiturndialogzoo
Multi-turn dialogue baselines written in PyTorch
Stars: ✭ 106 (+12.77%)
Mutual labels:  chatbot, transformer
Tensorflow Ml Nlp
텐서플로우와 머신러닝으로 시작하는 자연어처리(로지스틱회귀부터 트랜스포머 챗봇까지)
Stars: ✭ 176 (+87.23%)
Mutual labels:  chatbot, transformer
zhamao-framework
协程、高性能、灵活的聊天机器人 & Web 开发框架(炸毛框架)
Stars: ✭ 99 (+5.32%)
Mutual labels:  chatbot
chatbot
kbqa task-oriented qa seq2seq ir neo4j jena seq2seq tf chatbot chat
Stars: ✭ 32 (-65.96%)
Mutual labels:  chatbot
FAQ-Bot-QQ
一个基于Mirai框架的Q群问答机器人
Stars: ✭ 30 (-68.09%)
Mutual labels:  chatbot
image-classification
A collection of SOTA Image Classification Models in PyTorch
Stars: ✭ 70 (-25.53%)
Mutual labels:  transformer
TF-Model-Deploy-Tutorial
A tutorial exploring multiple approaches to deploy a trained TensorFlow (or Keras) model or multiple models for prediction.
Stars: ✭ 51 (-45.74%)
Mutual labels:  tensorflow-tutorials
transform-graphql
⚙️ Transformer function to transform GraphQL Directives. Create model CRUD directive for example
Stars: ✭ 23 (-75.53%)
Mutual labels:  transformer
transformer
A PyTorch Implementation of "Attention Is All You Need"
Stars: ✭ 28 (-70.21%)
Mutual labels:  transformer
keras-chatbot-web-api
Simple keras chat bot using seq2seq model with Flask serving web
Stars: ✭ 51 (-45.74%)
Mutual labels:  chatbot
BossNAS
(ICCV 2021) BossNAS: Exploring Hybrid CNN-transformers with Block-wisely Self-supervised Neural Architecture Search
Stars: ✭ 125 (+32.98%)
Mutual labels:  transformer
Transformer-ocr
Handwritten text recognition using transformers.
Stars: ✭ 92 (-2.13%)
Mutual labels:  transformer

Transformer Chatbot with TensorFlow 2

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

Updates

  • 16 June 2022:
    • Update setup.sh script to install Apple Silicon version of TensorFlow 2.9 (only use this if you're feeling adventurous).
    • Updated the two custom layers, PositionalEncoding and MultiHeadAttentionLayer, to allow model saving via model.save() or tf.keras.models.save_model().
    • train.py showcase how to call model.save() and tf.keras.models.load_model().
  • 8 Dec 2020: Updated support to TensorFlow 2.3.1 and TensorFlow Datasets 4.1.0
  • 18 Jan 2020: Added notebook with Google Colab TPU support in TensorFlow 2.1.

Packages

Setup

  • create new anaconda environment and initialize environment chatbot
    conda create -n chatbot python=3.8
    conda activate chatbot
    
  • run installation script
    sh setup.sh
    
  • Note: the script would install CUDA and cuDNN via conda if installing on a Linux system, or tensorflow-metal for devices with Apple Silicon (Note that there are tons of bugs with TensorFlow on Apple Silicon GPU, e.g. Adam optimizer does not work).

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 available flags and hyper-parameters python main.py --help
python train.py --output_dir runs/save_model --batch_size 256 --epochs 50 --max_samples 50000
  • the final trained model will be saved to runs/save_model.

Samples

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

input:		it's a trap!
output:		no , it s not .
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].