dicee.abstracts
Classes
Abstract class for Trainer class for knowledge graph embedding models |
|
Abstract/base class for using knowledge graph embedding models interactively. |
|
Abstract class for Callback class for knowledge graph embedding models |
|
Abstract class for Callback class for knowledge graph embedding models |
Module Contents
- class dicee.abstracts.AbstractTrainer(args, callbacks)[source]
Abstract class for Trainer class for knowledge graph embedding models
Parameter
- argsstr
?
- callbacks: list
?
- attributes
- callbacks
- is_global_zero = True
- global_rank = 0
- local_rank = 0
- strategy = None
- on_fit_start(*args, **kwargs)[source]
A function to call callbacks before the training starts.
Parameter
args
kwargs
- rtype:
None
- on_fit_end(*args, **kwargs)[source]
A function to call callbacks at the ned of the training.
Parameter
args
kwargs
- rtype:
None
- on_train_epoch_end(*args, **kwargs)[source]
A function to call callbacks at the end of an epoch.
Parameter
args
kwargs
- rtype:
None
- class dicee.abstracts.BaseInteractiveKGE(path: str = None, url: str = None, construct_ensemble: bool = False, model_name: str = None, apply_semantic_constraint: bool = False)[source]
Abstract/base class for using knowledge graph embedding models interactively.
Parameter
- path_of_pretrained_model_dirstr
?
- construct_ensemble: boolean
?
model_name: str apply_semantic_constraint : boolean
- construct_ensemble = False
- apply_semantic_constraint = False
- configs
- get_bpe_token_representation(str_entity_or_relation: List[str] | str) List[List[int]] | List[int] [source]
- Parameters:
str_entity_or_relation (corresponds to a str or a list of strings to be tokenized via BPE and shaped.)
- Return type:
A list integer(s) or a list of lists containing integer(s)
- get_padded_bpe_triple_representation(triples: List[List[str]]) Tuple[List, List, List] [source]
- Parameters:
triples
- property name
- index_triple(head_entity: List[str], relation: List[str], tail_entity: List[str]) Tuple[torch.LongTensor, torch.LongTensor, torch.LongTensor] [source]
Index Triple
Parameter
head_entity: List[str]
String representation of selected entities.
relation: List[str]
String representation of selected relations.
tail_entity: List[str]
String representation of selected entities.
Returns: Tuple
pytorch tensor of triple score
- get_entity_embeddings(items: List[str])[source]
Return embedding of an entity given its string representation
Parameter
- items:
entities
- get_relation_embeddings(items: List[str])[source]
Return embedding of a relation given its string representation
Parameter
- items:
relations
- class dicee.abstracts.AbstractCallback[source]
Bases:
abc.ABC
,lightning.pytorch.callbacks.Callback
Abstract class for Callback class for knowledge graph embedding models
Parameter
- on_init_end(*args, **kwargs)[source]
Call at the beginning of the training.
Parameter
trainer:
model:
- rtype:
None
- on_fit_start(trainer, model)[source]
Call at the beginning of the training.
Parameter
trainer:
model:
- rtype:
None
- on_train_epoch_end(trainer, model)[source]
Call at the end of each epoch during training.
Parameter
trainer:
model:
- rtype:
None
- class dicee.abstracts.AbstractPPECallback(num_epochs, path, epoch_to_start, last_percent_to_consider)[source]
Bases:
AbstractCallback
Abstract class for Callback class for knowledge graph embedding models
Parameter
- num_epochs
- path
- sample_counter = 0
- epoch_count = 0
- alphas = None
- on_fit_start(trainer, model)[source]
Call at the beginning of the training.
Parameter
trainer:
model:
- rtype:
None