This class contains all methods shared by all BaseModels.
Does return a new object of this class.
aifeducation::AIFEMaster
-> aifeducation::AIFEBaseModel
-> BaseModelCore
Tokenizer
('TokenizerBase')
Objects of class TokenizerBase
.
Inherited methods
aifeducation::AIFEMaster$get_all_fields()
aifeducation::AIFEMaster$get_documentation_license()
aifeducation::AIFEMaster$get_ml_framework()
aifeducation::AIFEMaster$get_model_config()
aifeducation::AIFEMaster$get_model_description()
aifeducation::AIFEMaster$get_model_info()
aifeducation::AIFEMaster$get_model_license()
aifeducation::AIFEMaster$get_package_versions()
aifeducation::AIFEMaster$get_private()
aifeducation::AIFEMaster$get_publication_info()
aifeducation::AIFEMaster$get_sustainability_data()
aifeducation::AIFEMaster$is_configured()
aifeducation::AIFEMaster$is_trained()
aifeducation::AIFEMaster$set_documentation_license()
aifeducation::AIFEMaster$set_model_description()
aifeducation::AIFEMaster$set_model_license()
create_from_hf()
Creates BaseModel from a pretrained model
BaseModelCore$create_from_hf(model_dir = NULL, tokenizer_dir = NULL)
model_dir
tokenizer_dir
string
Path to the directory where the tokenizer is saved. Allowed values: any
Does return a new object of this class.
train()
Traines a BaseModel
BaseModelCore$train(
text_dataset,
p_mask = 0.15,
whole_word = TRUE,
val_size = 0.1,
n_epoch = 1L,
batch_size = 12L,
max_sequence_length = 250L,
full_sequences_only = FALSE,
min_seq_len = 50L,
learning_rate = 0.003,
sustain_track = FALSE,
sustain_iso_code = NULL,
sustain_region = NULL,
sustain_interval = 15L,
sustain_log_level = "warning",
trace = TRUE,
pytorch_trace = 1L,
log_dir = NULL,
log_write_interval = 2L
)
text_dataset
p_mask
whole_word
val_size
n_epoch
batch_size
max_sequence_length
full_sequences_only
min_seq_len
learning_rate
sustain_track
sustain_iso_code
sustain_region
sustain_interval
sustain_log_level
trace
pytorch_trace
log_dir
log_write_interval
Does nothing return.
count_parameter()
Method for counting the trainable parameters of a model.
BaseModelCore$count_parameter()
Returns the number of trainable parameters of the model.
plot_training_history()
Method for requesting a plot of the training history. This method requires the R package 'ggplot2' to work.
BaseModelCore$plot_training_history(
y_min = NULL,
y_max = NULL,
text_size = 10L
)
y_min
y_max
text_size
Returns a plot of class ggplot
visualizing the training process.
get_special_tokens()
Method for receiving the special tokens of the model
BaseModelCore$get_special_tokens()
Returns a matrix
containing the special tokens in the rows
and their type, token, and id in the columns.
get_tokenizer_statistics()
Tokenizer statistics
BaseModelCore$get_tokenizer_statistics()
Returns a data.frame
containing the tokenizer's statistics.
fill_mask()
Method for calculating tokens behind mask tokens.
BaseModelCore$fill_mask(masked_text, n_solutions = 5L)
masked_text
n_solutions
Returns a list
containing a data.frame
for every
mask. The data.frame
contains the solutions in the rows and reports
the score, token id, and token string in the columns.
dir_path
Path to the directory where to save the object.
folder_name
string
Name of the folder where the model should be saved. Allowed values: any
Function does nothing return. It is used to save an object on disk.
load_from_disk()
Loads an object from disk and updates the object to the current version of the package.
BaseModelCore$load_from_disk(dir_path)
dir_path
Path where the object set is stored.
Function does nothin return. It loads an object from disk.
get_model()
Get 'PyTorch' model
BaseModelCore$get_model()
Returns the underlying 'PyTorch' model.
get_model_type()
Type of the underlying model.
BaseModelCore$get_model_type()
Returns a string
describing the model's architecture.
get_final_size()
Size of the final layer.
BaseModelCore$get_final_size()
Returns an int
describing the number of dimensions of the last
hidden layer.
get_flops_estimates()
Flop estimates
BaseModelCore$get_flops_estimates()
Returns a data.frame
containing statistics about the flops.
set_publication_info()
Method for setting the bibliographic information of the model.
BaseModelCore$set_publication_info(type, authors, citation, url = NULL)
type
string
Type of information which should be changed/added.
developer
, and modifier
are possible.
authors
List of people.
citation
string
Citation in free text.
url
string
Corresponding URL if applicable.
Function does not return a value. It is used to set the private members for publication information of the model.
estimate_sustainability_inference_fill_mask()
Calculates the energy consumption for inference of the given task.
BaseModelCore$estimate_sustainability_inference_fill_mask(
text_dataset = NULL,
n = NULL,
sustain_iso_code = NULL,
sustain_region = NULL,
sustain_interval = 15L,
sustain_log_level = "warning",
trace = TRUE
)
text_dataset
n
sustain_iso_code
sustain_region
sustain_interval
sustain_log_level
trace
Returns nothing. Method saves the statistics internally.
The statistics can be accessed with the method get_sustainability_data("inference")
calc_flops_architecture_based()
Calculates FLOPS based on model's architecture.
BaseModelCore$calc_flops_architecture_based(batch_size, n_batches, n_epochs)
batch_size
n_batches
n_epochs
Returns a data.frame
storing the estimates.
clone()
The objects of this class are cloneable with this method.
BaseModelCore$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other R6 Classes for Developers:
AIFEBaseModel
,
AIFEMaster
,
ClassifiersBasedOnTextEmbeddings
,
DataManagerClassifier
,
LargeDataSetBase
,
ModelsBasedOnTextEmbeddings
,
TEClassifiersBasedOnProtoNet
,
TEClassifiersBasedOnRegular
,
TokenizerBase