All Projects → CyberZHG → Keras Gpt 2

CyberZHG / Keras Gpt 2

Licence: mit
Load GPT-2 checkpoint and generate texts

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Keras Gpt 2

Phonlp
PhoNLP: A BERT-based multi-task learning toolkit for part-of-speech tagging, named entity recognition and dependency parsing (NAACL 2021)
Stars: ✭ 56 (-50.44%)
Mutual labels:  language-model
Bio embeddings
Get protein embeddings from protein sequences
Stars: ✭ 86 (-23.89%)
Mutual labels:  language-model
Pytorch gbw lm
PyTorch Language Model for 1-Billion Word (LM1B / GBW) Dataset
Stars: ✭ 101 (-10.62%)
Mutual labels:  language-model
Gpt2
PyTorch Implementation of OpenAI GPT-2
Stars: ✭ 64 (-43.36%)
Mutual labels:  language-model
Full stack transformer
Pytorch library for end-to-end transformer models training, inference and serving
Stars: ✭ 71 (-37.17%)
Mutual labels:  language-model
Bit Rnn
Quantize weights and activations in Recurrent Neural Networks.
Stars: ✭ 86 (-23.89%)
Mutual labels:  language-model
Tner
Language model finetuning on NER with an easy interface, and cross-domain evaluation. We released NER models finetuned on various domain via huggingface model hub.
Stars: ✭ 54 (-52.21%)
Mutual labels:  language-model
Transformers
🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
Stars: ✭ 55,742 (+49229.2%)
Mutual labels:  language-model
Greek Bert
A Greek edition of BERT pre-trained language model
Stars: ✭ 84 (-25.66%)
Mutual labels:  language-model
Pyclue
Python toolkit for Chinese Language Understanding(CLUE) Evaluation benchmark
Stars: ✭ 91 (-19.47%)
Mutual labels:  language-model
Indonesian Language Models
Indonesian Language Models and its Usage
Stars: ✭ 64 (-43.36%)
Mutual labels:  language-model
Nezha chinese pytorch
NEZHA: Neural Contextualized Representation for Chinese Language Understanding
Stars: ✭ 65 (-42.48%)
Mutual labels:  language-model
Text Gan Tensorflow
TensorFlow GAN implementation using Gumbel Softmax
Stars: ✭ 87 (-23.01%)
Mutual labels:  language-model
Char rnn lm zh
language model in Chinese,基于Pytorch官方文档实现
Stars: ✭ 57 (-49.56%)
Mutual labels:  language-model
Openseq2seq
Toolkit for efficient experimentation with Speech Recognition, Text2Speech and NLP
Stars: ✭ 1,378 (+1119.47%)
Mutual labels:  language-model
Vietnamese Electra
Electra pre-trained model using Vietnamese corpus
Stars: ✭ 55 (-51.33%)
Mutual labels:  language-model
Pytorch Openai Transformer Lm
🐥A PyTorch implementation of OpenAI's finetuned transformer language model with a script to import the weights pre-trained by OpenAI
Stars: ✭ 1,268 (+1022.12%)
Mutual labels:  language-model
Getlang
Natural language detection package in pure Go
Stars: ✭ 110 (-2.65%)
Mutual labels:  language-model
Easy Bert
A Dead Simple BERT API for Python and Java (https://github.com/google-research/bert)
Stars: ✭ 106 (-6.19%)
Mutual labels:  language-model
Tongrams
A C++ library providing fast language model queries in compressed space.
Stars: ✭ 88 (-22.12%)
Mutual labels:  language-model

Keras GPT-2

Travis Coverage Version Downloads License

[中文|English]

Load pretrained weights and predict with GPT-2.

Install

pip install keras-gpt-2

Demo

import os
from keras_gpt_2 import load_trained_model_from_checkpoint, get_bpe_from_files, generate


model_folder = 'xxx/yyy/117M'
config_path = os.path.join(model_folder, 'hparams.json')
checkpoint_path = os.path.join(model_folder, 'model.ckpt')
encoder_path = os.path.join(model_folder, 'encoder.json')
vocab_path = os.path.join(model_folder, 'vocab.bpe')


print('Load model from checkpoint...')
model = load_trained_model_from_checkpoint(config_path, checkpoint_path)
print('Load BPE from files...')
bpe = get_bpe_from_files(encoder_path, vocab_path)
print('Generate text...')
output = generate(model, bpe, ['From the day forth, my arm'], length=20, top_k=1)

# If you are using the 117M model and top_k equals to 1, then the result will be:
# "From the day forth, my arm was broken, and I was in a state of pain. I was in a state of pain,"
print(output[0])
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].