All Projects → Separius → Bert Keras

Separius / Bert Keras

Licence: gpl-3.0
Keras implementation of BERT with pre-trained weights

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Bert Keras

finetuner
Finetuning any DNN for better embedding on neural search tasks
Stars: ✭ 442 (-46.1%)
Mutual labels:  transfer-learning, pretrained-models
Getting Things Done With Pytorch
Jupyter Notebook tutorials on solving real-world problems with Machine Learning & Deep Learning using PyTorch. Topics: Face detection with Detectron 2, Time Series anomaly detection with LSTM Autoencoders, Object Detection with YOLO v5, Build your first Neural Network, Time Series forecasting for Coronavirus daily cases, Sentiment Analysis with BERT.
Stars: ✭ 738 (-10%)
Mutual labels:  transfer-learning, transformer
ObjectNet
PyTorch implementation of "Pyramid Scene Parsing Network".
Stars: ✭ 15 (-98.17%)
Mutual labels:  transfer-learning, pretrained-models
super-gradients
Easily train or fine-tune SOTA computer vision models with one open source training library
Stars: ✭ 429 (-47.68%)
Mutual labels:  transfer-learning, pretrained-models
Bert Multitask Learning
BERT for Multitask Learning
Stars: ✭ 380 (-53.66%)
Mutual labels:  pretrained-models, transformer
MinTL
MinTL: Minimalist Transfer Learning for Task-Oriented Dialogue Systems
Stars: ✭ 61 (-92.56%)
Mutual labels:  transformer, transfer-learning
SIGIR2021 Conure
One Person, One Model, One World: Learning Continual User Representation without Forgetting
Stars: ✭ 23 (-97.2%)
Mutual labels:  transformer, transfer-learning
Open-Source-Models
Address book for computer vision models.
Stars: ✭ 30 (-96.34%)
Mutual labels:  transfer-learning, pretrained-models
Flow Forecast
Deep learning PyTorch library for time series forecasting, classification, and anomaly detection (originally for flood forecasting).
Stars: ✭ 368 (-55.12%)
Mutual labels:  transfer-learning, transformer
Abstractive Summarization With Transfer Learning
Abstractive summarisation using Bert as encoder and Transformer Decoder
Stars: ✭ 358 (-56.34%)
Mutual labels:  transfer-learning, transformer
Context-Transformer
Context-Transformer: Tackling Object Confusion for Few-Shot Detection, AAAI 2020
Stars: ✭ 89 (-89.15%)
Mutual labels:  transformer, transfer-learning
Nmt Keras
Neural Machine Translation with Keras
Stars: ✭ 501 (-38.9%)
Mutual labels:  theano, transformer
ProteinLM
Protein Language Model
Stars: ✭ 76 (-90.73%)
Mutual labels:  transfer-learning, pretrained-models
transformer-models
Deep Learning Transformer models in MATLAB
Stars: ✭ 90 (-89.02%)
Mutual labels:  transformer, pretrained-models
sparsezoo
Neural network model repository for highly sparse and sparse-quantized models with matching sparsification recipes
Stars: ✭ 264 (-67.8%)
Mutual labels:  transfer-learning, pretrained-models
Filipino-Text-Benchmarks
Open-source benchmark datasets and pretrained transformer models in the Filipino language.
Stars: ✭ 22 (-97.32%)
Mutual labels:  transformer, transfer-learning
Imagenet
Pytorch Imagenet Models Example + Transfer Learning (and fine-tuning)
Stars: ✭ 134 (-83.66%)
Mutual labels:  transfer-learning, pretrained-models
vietnamese-roberta
A Robustly Optimized BERT Pretraining Approach for Vietnamese
Stars: ✭ 22 (-97.32%)
Mutual labels:  transformer, pretrained-models
AITQA
resources for the IBM Airlines Table-Question-Answering Benchmark
Stars: ✭ 12 (-98.54%)
Mutual labels:  transformer, transfer-learning
Nlp Paper
NLP Paper
Stars: ✭ 484 (-40.98%)
Mutual labels:  transfer-learning, transformer

Status: Archive (code is provided as-is, no updates expected)

BERT-keras

Keras implementation of Google BERT(Bidirectional Encoder Representations from Transformers) and OpenAI's Transformer LM capable of loading pretrained models with a finetuning API.

Update: With TPU support both for inference and training like this colab notebook thanks to @HighCWu

How to use it?

# this is a pseudo code you can read an actual working example in tutorial.ipynb or the colab notebook
text_encoder = MyTextEncoder(**my_text_encoder_params) # you create a text encoder (sentence piece and openai's bpe are included)
lm_generator = lm_generator(text_encoder, **lm_generator_params) # this is essentially your data reader (single sentence and double sentence reader with masking and is_next label are included)
task_meta_datas = [lm_task, classification_task, pos_task] # these are your tasks (the lm_generator must generate the labels for these tasks too)
encoder_model = create_transformer(**encoder_params) # or you could simply load_openai() or you could write your own encoder(BiLSTM for example)
trained_model = train_model(encoder_model, task_meta_datas, lm_generator, **training_params) # it does both pretraing and finetuning
trained_model.save_weights('my_awesome_model') # save it
model = load_model('my_awesome_model', encoder_model) # load it later and use it!

Notes

  • The general idea of this library is to use OpenAI's/Google's pretrained model for transfer learning
  • In order to see how the BERT model works, you can check this colab notebook
  • In order to be compatible with both BERT and OpenAI I had to assume a standard ordering for the vocabulary, I'm using OpenAI's so in the loading function of BERT there is a part to change the ordering; but this is an implementation detail and you can ignore it!
  • Loading OpenAI model is tested with both tensorflow and theano as backend
  • Loading a Bert model is not possible on theano backend yet but the tf version is working and it has been tested
  • Training and fine-tuning a model is not possible with theano backend but works perfectly fine with tensorflow
  • You can use the data generator and task meta data for most of the NLP tasks and you can use them in other frameworks
  • There are some unit tests for both dataset and transformer model (read them if you are not sure about something)
  • Even tough I don't like my keras code, it's readable :)
  • You can use other encoders, like LSTM or BiQRNN for training if you follow the model contract (have the same inputs and outputs as transformer encoder)
  • Why should I use this instead of the official release?, first this one is in Keras and second it has a nice abstraction over token-level and sentence-level NLP tasks which is framework independent
  • Why keras? pytorch version is already out! (BTW you can use this data generator for training and fine-tuning that model too)
  • I strongly advise you to read the tutorial.ipynb (I don't like notebooks so this is a poorly designed notebook, but read it anyway)

Important code concepts

  • Task: there are two general tasks, sentence level tasks(like is_next and sentiment analysis), and token level tasks(like PoS and NER)
  • Sentence: a sentence represents an example with it's labels and everything, for each task it provides a target(single one for sentence level tasks and per token label for token level tasks) and a mask, for token levels we need to not only ignore paddings but also we might want to predict class on first char of a word (like the BERT paper(first piece of a multi piece word)) and for sentence levels we want a extraction point(like start token in BERT paepr)
  • TaskWeightScheduler: for training we might want to start with language modeling and smoothly move to classification, they can be easily implemented with this class
  • attention_mask: with this you can 1.make your model causal 2.ignore paddings 3.do your crazy idea :D
  • special_tokens: pad, start, end, delimiter, mask

Ownership

Neiron

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].