API Documentation
TensorFlow Models
Ranking Model Constructors
|
Create a model using the architecture proposed in DCN V2: Improved Deep & Cross Network [1]. |
|
DLRM-model architecture. |
Retrieval Model Constructors
|
Builds a matrix factorization model. |
|
Builds the Two-tower architecture, as proposed in [1]. |
|
Build the Youtube-DNN retrieval model. |
Input Block Constructors
|
The entry block of the model to process input features from a schema. |
|
Input block for continuous features. |
|
|
|
Input block for embedding-lookups for categorical features. |
|
Input block for embedding-lookups for categorical features. This module produces 3-D tensors, this is useful for sequential models like transformers. :param feature_config: This specifies what TableConfig to use for each feature. For shared embeddings, the same TableConfig can be used for multiple features. :type feature_config: Dict[str, FeatureConfig] :param item_id: The name of the feature that’s used for the item_id. :type item_id: str, optional :param padding_idx: The symbol to use for padding. :type padding_idx: int :param pre: Transformations to apply on the inputs when the module is called (so before call). :type pre: Union[str, TabularTransformation, List[str], List[TabularTransformation]], optional :param post: Transformations to apply on the inputs after the module is called (so after call). :type post: Union[str, TabularTransformation, List[str], List[TabularTransformation]], optional :param aggregation: Aggregation to apply after processing the call-method to output a single Tensor. |
Model Building Block Constructors
|
Builds the DLRM architecture, as proposed in the following `paper https://arxiv.org/pdf/1906.00091.pdf`_ [1]_. |
|
A block that applies a multi-layer perceptron to the input. |
|
This block provides a way to create high-order feature interactions |
|
Builds the Two-tower architecture, as proposed in the following `paper https://doi.org/10.1145/3298689.3346996`_ [Xinyang19]. |
|
Returns a block for Matrix Factorization, which created the user and item embeddings based on the schema and computes the dot product between user and item L2-norm embeddings |
|
Modeling Prediction Task Constructors
|
Creates Multi-task prediction Blocks from schema |
|
Base-class for prediction tasks. |
|
Prediction task for binary classification. |
|
Prediction task for multi-class classification. |
|
Prediction task for regression-task. |
|
Prediction-task for item-retrieval. |
|
Function to create the NextItemPrediction task with the right parameters. :param schema: The schema object including features to use and their properties. :type schema: Schema :param weight_tying: The item_id embedding weights are shared with the prediction network layer. Defaults to True :type weight_tying: bool :param extra_pre_call: Optional extra pre-call block. Defaults to None. :type extra_pre_call: Optional[PredictionBlock] :param target_name: If specified, name of the target tensor to retrieve from dataloader. Defaults to None. :type target_name: Optional[str] :param task_name: name of the task. Defaults to None. :type task_name: Optional[str] :param task_block: The Block that applies additional layers op to inputs. Defaults to None. :type task_block: Block :param logits_temperature: Parameter used to reduce the model overconfidence, so that logits / T. Defaults to 1. :type logits_temperature: float :param l2_normalization: Apply L2 normalization before computing dot interactions. Defaults to False. :type l2_normalization: bool :param sampled_softmax: Compute the logits scores over all items of the catalog or generate a subset of candidates Defaults to False :type sampled_softmax: bool :param num_sampled: When sampled_softmax is enabled, specify the number of negative candidates to generate for each batch Defaults to 100 :type num_sampled: int :param min_sampled_id: The minimum id value to be sampled. Useful to ignore the first categorical encoded ids, which are usually reserved for <nulls>, out-of-vocabulary or padding. Defaults to 0. :type min_sampled_id: int :param post_logits: Optional extra pre-call block for post-processing the logits, by default None. You can for example use post_logits = mm.PopularitySamplingBlock(item_fequency) for populariy sampling correction. :type post_logits: Optional[PredictionBlock]. |
Model Pipeline Constructors
|
The SequentialLayer represents a sequence of Keras layers. It is a Keras Layer that can be used instead of tf.keras.layers.Sequential, which is actually a Keras Model. In contrast to keras Sequential, this layer can be used as a pure Layer in tf.functions and when exporting SavedModels, without having to pre-declare input and output shapes. In turn, this layer is usable as a preprocessing layer for TF Agents Networks, and can be exported via PolicySaver. Usage::. |
|
Merge multiple layers or TabularModule’s into a single output of TabularData. |
|
Multi-task prediction block. |
|
A block that applies a dense residual block to the input. |
|
|
|
|
|
Layer that’s specialized for tabular-data by integrating many often used operations. |
|
Transformation that filters out certain features from TabularData.” |
Masking Block Constructors
Transformation Block Constructors
|
Expand dims of selected input tensors. Example::. |
|
Convert all list-inputs to dense-tensors. |
|
Convert all list-inputs to sparse-tensors. |
|
Applies Stochastic replacement of sequence features |
|
Converts a Tensor to TabularData by converting it to a dictionary. |
Multi-Task Block Constructors
|
|
|
Data Loader Customization Constructor
Override class to customize data loading for backward compatibility with older NVTabular releases. |
Metrics
|
|
|
|
|
Sampling
|
|
|
Provides in-batch sampling [1]_ for two-tower item retrieval models. |
|
Provides a popularity-based negative sampling for the softmax layer to ensure training efficiency when the catalog of items is very large. |
Losses
|
Extends tf.keras.losses.SparseCategoricalCrossentropy by making from_logits=True by default (in this case an optimized softmax activation is applied within this loss, you should not include softmax activation manually in the output layer). |
|
Extends tf.keras.losses.SparseCategoricalCrossentropy by making from_logits=True by default (in this case an optimized softmax activation is applied within this loss, you should not include softmax activation manually in the output layer). |
|
The Bayesian Personalised Ranking (BPR) pairwise loss [1]_ |
|
The BPR-max pairwise loss proposed in [1]_ |
|
Pairwise hinge loss, as described in [1]_: max(0, 1 + r_uj - r_ui)), where r_ui is the score of the positive item and r_uj the score of negative items. |
|
Pairwise log loss, as described in [1]_: log(1 + exp(r_uj - r_ui)), where r_ui is the score of the positive item and r_uj the score of negative items. |
|
The TOP pairwise loss proposed in [1]_ |
|
The TOP1-max pairwise loss proposed in [1]_ |
|
An adapted version of the TOP pairwise loss proposed in [1]_, but following the current GRU4Rec implementation [2]_. |
Schema Functions
|
|
|
|
|
|
|
|
Filters out entries from input_dict, returns a dictionary where every entry corresponds to a column in the schema |
|
|
|
|
|
|
Provides a heristic (from Google) that suggests the embedding sizes as a function (forth root) of categorical features cardinalities, obtained from the schema. |
|
Provides a heuristic (from Google) that suggests the embedding dimension as a function (forth root) of the feature cardinality. |
Utilities
Miscellaneous Utility Functions
Analyses the feature map config and returns the name of the label feature (e.g. |
|
|
Analyses the feature map config and returns the name of the label feature (e.g. |
A context manager that prints the execution time of the block it manages |
|
Recursively finds size of objects |
|
Util function to load NVTabular Dataset from disk |
Registry Functions
Default name for a class or function. |
|
Dict-like class for managing function registrations. |
|
Creates a help string for names_list grouped by prefix. |