BifurcationDetector

Description

Component for aggressive decoding. Find the bifurcation index of predicted tokens, between source tokens, starting from previous suffix match index, and predicted tokens. Concat predicted tokens, starting from bifurcation index, to the back of current tokens. This forms the output tokens. Detect suffix match index in source tokens, between source tokens and output tokens. Detection is based on finding the appearances of last n-gram in output tokens in source tokens. A match is considered found if source tokens contain a single matching n-gram. Return the index of the start of the n-gram in source tokens. No matching if found if src tokens contain multiple or zero matching n-grams. Return -1.

 

Input parameters

 

specified_outputs_name :Β array, this parameter lets you manually assign custom names to the output tensors of a node.

Β Graphs in :Β cluster, ONNX model architecture.

src tokensΒ – T : object, encoder input ids.
cur tokensΒ – T : object, decoder input ids.
prev suffix match idxΒ – T : object, previous suffix match index.
pred tokensΒ – T : object, predicted token ids from aggressive decoding.

Β Parameters :Β cluster,

max ngram sizeΒ : integer, the maximum NGram size for suffix matching.
Default value β€œ0”.
min ngram sizeΒ : integer, the minimum NGram size for suffix matching.
Default value β€œ0”.
Β training?Β :Β boolean, whether the layer is in training mode (can store data for backward).
Default value β€œTrue”.
Β lda coeff :Β float, defines the coefficient by which the loss derivative will be multiplied before being sent to the previous layer (since during the backward run we go backwards).
Default value β€œ1”.

Β name (optional) :Β string,Β name of the node.

Output parameters

 

Β Graphs out :Β cluster, ONNX model architecture.

tokensΒ – T : object, decoder input ids after merging predicted tokens.
suffix_match_idxΒ – T : object, new suffix match index.

Type Constraints

TΒ in (tensor(int64)) : Constrain to integer types.

Example

All these exemples are snippets PNG, you can drop these Snippet onto the block diagram and get the depicted code added to your VI (Do not forget to install Deep Learning library to run it).
Table of Contents