Generation¶
-
class
Manteia.Generation.
Generation
(model=None, documents=None, seed=None)¶ This is the class to gnerate text in categorie a NLP task.
Args:
- model_name (
string
, optional, defaults to ‘bert’): give the name of a model.
- documents (
list
, optional, defaults to None): A list of documents.
- labels (
float
, optional, defaults to None): A list of labels.
Example:
from Manteia.Generation import Generation from Manteia.Dataset import Dataset from Manteia.Model import * ds=Dataset('Short_Jokes') model = Model(model_name ='gpt2-medium') text_loader = Create_DataLoader_generation(ds.documents_train[:3000]) model.load_tokenizer() model.load_class() model.devices() model.configuration(text_loader) gn=Generation(model) gn.model.fit_generation(text_loader) output = model.predict_generation('What did you expect ?') output_text = decode_text(output,model.tokenizer) print(output_text)
- model_name (