dicee.config

Configuration module for DICE embeddings.

Provides the Namespace class with default configuration values for training knowledge graph embedding models.

Classes

Namespace

Extended Namespace with default KGE training configuration.

Module Contents

class dicee.config.Namespace(**kwargs)

Bases: argparse.Namespace

Extended Namespace with default KGE training configuration.

Provides sensible defaults for all training parameters while allowing easy customization through command-line arguments or direct assignment.

dataset_dir: str | None = None

The path of a folder containing train.txt, and/or valid.txt and/or test.txt

save_embeddings_as_csv: bool = False

Embeddings of entities and relations are stored into CSV files to facilitate easy usage.

storage_path: str = 'Experiments'

A directory named with time of execution under –storage_path that contains related data about embeddings.

path_to_store_single_run: str | None = None

A single directory created that contains related data about embeddings.

path_single_kg = None

Path of a file corresponding to the input knowledge graph

sparql_endpoint = None

An endpoint of a triple store.

ultra_checkpoint: str | None = None
ultra_dim: int = 64
ultra_num_layers: int = 6
ultra_query_batch_size: int = 8
trix_checkpoint: str | None = None
trix_dim: int = 32
trix_query_batch_size: int = 8
flock_checkpoint: str | None = None
flock_dim: int = 64
flock_walk_num: int = 128
flock_walk_len: int = 128
flock_refinements: int = 6
flock_num_layers: int = 1
flock_attention_heads: int = 4
flock_test_samples: int = 1
flock_query_batch_size: int = 1
flock_seed: int | None = None
flock_prefetch_walks: bool = True
flock_compact_state: bool = True
flock_compile_sampler: bool = True
flock_pack_walks: bool = True
graph_inference_backend: str = 'auto'
graph_relation_cache_mb: int = 64
graph_projection_cache_mb: int = 64
graph_inference_compile: bool = False
grouped_negative_sampling: bool = False

Sample a fixed-size group of negatives per positive (positive in column 0) via GroupedNegativeSamplingDataset instead of the flat NegSample layout. Requires scoring_technique=’NegSample’, entity prediction, no byte_pair_encoding.

strict_negative_sampling: bool = False

With grouped/adversarial sampling, exclude every known-true triple from the negative candidate pool instead of sampling entities uniformly at random.

adversarial_temperature: float | None = None

Softmax temperature for self-adversarial weighting of negatives by their own score (dicee.models.sampled_loss.grouped_adversarial_bce); implies grouped sampling. 0 weights negatives uniformly; higher values weight high-scoring (harder) negatives more. None disables adversarial weighting.

model: str = 'Keci'

KGE model

optim: str = 'Adam'

Optimizer

embedding_dim: int = 64

Size of continuous vector representation of an entity/relation

num_epochs: int = 150

Number of pass over the training data

batch_size: int = 1024

Mini-batch size if it is None, an automatic batch finder technique applied

lr: float = 0.1

Learning rate

add_noise_rate: float | None = None

The ratio of added random triples into training dataset

gpus = None

Number GPUs to be used during training

callbacks

10}}

Type:

Callbacks, e.g., {“PPE”

Type:

{ “last_percent_to_consider”

backend: str = 'pandas'

Backend to read, process, and index input knowledge graph. pandas, polars and rdflib available

separator: str = '\\s+'

separator for extracting head, relation and tail from a triple

trainer: str = 'torchCPUTrainer'

‘torchCPUTrainer’ (CPU/single GPU), ‘PL’ (PyTorch Lightning multi-GPU), ‘torchDDP’ (native DDP), ‘TP’ (Tensor Parallelism - implements ‘Multiple Run Ensemble Learning with Low-Dimensional Knowledge Graph Embeddings’)

Type:

Trainer for knowledge graph embedding model. Options

scoring_technique: str = 'KvsAll'

Scoring technique for knowledge graph embedding models

neg_ratio: int = 0

Negative ratio for a true triple in NegSample training_technique

weight_decay: float = 0.0

Weight decay for all trainable params

normalization: str = 'None'

LayerNorm, BatchNorm1d, or None

init_param: str | None = None

xavier_normal or None

gradient_accumulation_steps: int = 0

Not tested e

num_folds_for_cv: int = 0

Number of folds for CV

eval_model: str = 'train_val_test'

[“None”, “train”, “train_val”, “train_val_test”, “test”]

Type:

Evaluate trained model choices

eval_tie_policy: str = 'sort'

sort (legacy), optimistic, random, or pessimistic.

Type:

Prediction ties

eval_tie_seed: int | None = None

Independent random tie seed; None uses random_seed.

save_model_at_every_epoch: int | None = None

Not tested

label_smoothing_rate: float = 0.0

Smooths dataset targets toward a uniform distribution at construction time (dicee/dataset_classes/_label_based.py, _negative_sampling.py), independent of loss_fn. Also passed as smoothness_ratio to loss_fn=”LS”/”CombinedLSandLR”/ “AggregatedLSandLR” (see dicee/losses/custom_losses.py).

num_core: int = 0

Number of CPUs to be used in the mini-batch loading process

random_seed: int = 0

Random Seed

log_level: str = 'INFO'

DEBUG, INFO, WARNING, ERROR, or CRITICAL. Dataset info, timing, and checkpoint messages are logged at INFO; set to WARNING or higher to silence them.

Type:

Logging verbosity

sample_triples_ratio: float | None = None

Read some triples that are uniformly at random sampled. Ratio being between 0 and 1

read_only_few: int | None = None

Read only first few triples

pykeen_model_kwargs

Additional keyword arguments for pykeen models

pl_trainer_kwargs

Additional keyword arguments for the PyTorch Lightning Trainer

kernel_size: int = 3

Size of a square kernel in a convolution operation

num_of_output_channels: int = 32

Number of slices in the generated feature map by convolution.

margin: float = 4.0

Margin used by margin-based scoring functions (e.g. TransE, TransH, RotatE), and by torch.nn.MarginRankingLoss when scoring_technique=’NegSampleMargin’

p: int = 0

P parameter of Clifford Embeddings

q: int = 1

Q parameter of Clifford Embeddings

input_dropout_rate: float = 0.0

Dropout rate on embeddings of input triples

hidden_dropout_rate: float = 0.0

Dropout rate on hidden representations of input triples

feature_map_dropout_rate: float = 0.0

Dropout rate on a feature map generated by a convolution operation

byte_pair_encoding: bool = False

Byte pair encoding

Type:

WIP

adaptive_swa: bool = False

Adaptive stochastic weight averaging

swa: bool = False

Stochastic weight averaging

swag: bool = False

Stochastic weight averaging - Gaussian

ema: bool = False

Exponential Moving Average

twa: bool = False

Trainable weight averaging

block_size: int | None = None

block size of LLM

continual_learning: str | None = None

Path of a pretrained model size of LLM

auto_batch_finding: bool = False

A flag for using auto batch finding

eval_every_n_epochs: int = 0

Evaluate model every n epochs. If 0, no evaluation is applied.

save_every_n_epochs: bool = False

Save model every n epochs. If True, save model at every epoch.

eval_at_epochs: list | None = None

List of epoch numbers at which to evaluate the model (e.g., 1 5 10).

n_epochs_eval_model: str = 'val_test'

Evaluating link prediction performance on data splits while performing periodic evaluation.

adaptive_lr

“cca”}’

Type:

Adaptive learning rate parameters, e.g., ‘{“scheduler_name”

swa_start_epoch: int | None = None

Epoch at which to start applying stochastic weight averaging.

swa_c_epochs: int = 1

Number of epochs to average over for SWA, SWAG, EMA, TWA.

loss_fn: str | None = None

Overrides the default entity/relation-prediction loss with one of the classes in dicee/losses/custom_losses.py: “LS”, “LRLoss”, “BCELoss”, “WeightedBCELoss”, “CombinedLSandLR”, “AdaptiveLabelSmoothingLoss”, “AdaptiveLabelRelaxationLoss”, “ConfidenceBasedAdaptiveLabelRelaxationLoss”, “CombinedAdaptiveLSandAdaptiveLR”, “AggregatedLSandLR”, “ACLS”. None (default) keeps the framework’s own BCEWithLogitsLoss/CrossEntropyLoss/MarginRankingLoss selection. See the docstring of each class for what it actually does and known caveats.

label_relaxation_alpha: float = 0.1

alpha for loss_fn=”LRLoss”/”CombinedLSandLR”/”AggregatedLSandLR” (dicee.losses.custom_losses.LabelRelaxationLoss).

amwa: bool = False

Adaptive Momentum Weight Averaging

amwa_start_epoch: int = 0

Epoch at which to start applying AMWA.

amwa_c_epochs: int = 1

Number of epochs between AMWA updates.

amwa_monitor: str = 'MRR'

Validation metric used by AMWA to compare BaseNet and StableNet.

amwa_maximize: bool = True

Whether larger values of amwa_monitor are better.

amwa_beta: float | None = None

Fixed beta for AMWA. If None, use adaptive beta_n.

amwa_beta_window: int = 10

Number of recent delta values used to estimate beta_n.

amwa_beta_init: float = 1.0

Initial beta used before enough delta history exists.

amwa_beta_floor: float = 1e-08

Numerical floor for beta_n.

__iter__()