Textgen
Almost state of art text generation library
Install / Use
/learn @Emekaborisama/TextgenREADME
Ps: we are adding transformer model soon
<h1 align="center"> <p>Text Gen :goat:</p> <p align="center">
<img alt="python" src="https://img.shields.io/badge/python-%3E%3D3.6-blue?logo=python">
<img alt="tensorflow" src="https://img.shields.io/badge/tensorflow-%3E%3D2.3.0-orange?logo=tensorflow">
<a href="https://pypi.org/project/text-gen/">
<img alt="PyPI" src="https://img.shields.io/pypi/v/text-gen?color=%234285F4&label=release&logo=pypi&logoColor=%234285F4">
</a>
How to use it
Install text-gen
pip install -U text-gen
import the library
from text_gen import ten_textgen as ttg
Load your data. your data must be in a text format.
Download the example data from the example folder
load data
data = 'rl.csv'
text = ttg.loaddata(data)
build our Model Architeture
pipeline = ttg.tentext(text)
seq_text = pipeline.sequence(padding_method = 'pre')
configg = pipeline.configmodel(seq_text, lstmlayer = 128, activation = 'softmax', dropout = 0.25)
train model
model_history = pipeline.fit(loss = 'categorical_crossentropy', optimizer = 'adam', batch = 300, metrics = 'accuracy', epochs = 500, verbose = 0, patience = 10)
generate text using the phrase
pipeline.predict('hello love', word_length = 200, segment = True)
plot loss and accuracy
pipeline.plot_loss_accuracy()
Hyper parameter optimization
Tune your model to know the best optimizer, activation method to use.
pipeline.hyper_params(epochs = 500)
pipeline.saveModel('model')
use a saved model for prediction
#the corpus is the train text file
ttg.load_model_predict(corpus = corpus, padding_method = 'pre', modelname = '../input/model2/model2textgen.h5', sample_text = 'yo yo', word_length = 100)
<h1 align="center">
<span> Give us a star :star: </span> 🐉
</h1>
If you want to contribute, take a look at the issues and the Futurework.md file
Contributors
