API Reference
Transformers.HuggingFace.HGFConfigTransformers.Layers.ApplyEmbedTransformers.Layers.CrossAttentionTransformers.Layers.CrossAttentionTransformers.Layers.EmbedTransformers.Layers.EmbedDecoderTransformers.Layers.FixedLenPositionEmbedTransformers.Layers.ForkTransformers.Layers.NSplitTransformers.Layers.PostNormTransformerBlockTransformers.Layers.PostNormTransformerDecoderBlockTransformers.Layers.PreNormTransformerBlockTransformers.Layers.PreNormTransformerDecoderBlockTransformers.Layers.SelfAttentionTransformers.Layers.SelfAttentionTransformers.Layers.SinCosPositionEmbedTransformers.Layers.TransformerTransformers.Layers.TransformerBlockTransformers.Layers.TransformerDecoderBlockTransformers.TextEncoders.TrfTextEncoderTransformers.TextEncoders.TrfTextEncoderFlux.Losses.crossentropyFlux.Losses.logitcrossentropyTransformers.HuggingFace.get_model_typeTransformers.HuggingFace.get_state_dictTransformers.HuggingFace.load_configTransformers.HuggingFace.load_configTransformers.HuggingFace.load_hgf_pretrainedTransformers.HuggingFace.load_modelTransformers.HuggingFace.load_modelTransformers.HuggingFace.load_state_dictTransformers.HuggingFace.load_tokenizerTransformers.HuggingFace.save_configTransformers.HuggingFace.save_modelTransformers.HuggingFace.state_dict_to_namedtupleTransformers.Layers.no_dropoutTransformers.Layers.set_dropoutTransformers.Layers.testmodeTransformers.TextEncoders.bert_cased_tokenizerTransformers.TextEncoders.bert_uncased_tokenizerTransformers.TextEncoders.gpt_tokenizerTransformers.TextEncoders.set_annotateTransformers.TextEncoders.set_configTransformers.TextEncoders.set_decodeTransformers.TextEncoders.set_onehotTransformers.TextEncoders.set_processTransformers.TextEncoders.set_textprocessTransformers.TextEncoders.set_tokenizerTransformers.TextEncoders.set_vocabTransformers.TextEncoders.text_standardizeTransformers.enable_gpuTransformers.enable_gpuTransformers.firsttokenTransformers.firsttokenTransformers.lasttokenTransformers.lasttokenTransformers.lengthselectTransformers.safe_crossentropyTransformers.safe_logitcrossentropyTransformers.skipboundarytokenTransformers.skipfirsttokenTransformers.skiplasttokenTransformers.todeviceTransformers.todeviceTransformers.togpudeviceTransformers.togpudeviceTransformers.unsafe_crossentropyTransformers.unsafe_logitcrossentropyTransformers.HuggingFace.@hgf_str
Flux.Losses.crossentropy — Methodcrossentropy(ŷ::AbstractArray, y::AbstractArray, m::AbstractSeqMask; ϵ)
crossentropy(sum, ŷ::AbstractArray, y::AbstractArray, m::AbstractSeqMask; ϵ)Flux.crossentropy with an extra sequence mask for masking out non-needed token loss. y is the labels. By default it take the mean by dividing the number of valid tokens. This can be change to simply sum the valid losses by add the first argument sum. See also safe_crossentropy
Flux.Losses.logitcrossentropy — Methodlogitcrossentropy(ŷ::AbstractArray, y::AbstractArray, m::AbstractSeqMask)
logitcrossentropy(sum, ŷ::AbstractArray, y::AbstractArray, m::AbstractSeqMask)Flux.logitcrossentropy with an extra sequence mask for masking out non-needed token loss. y is the labels. By default it take the mean by dividing the number of valid tokens. This can be change to simply sum the valid losses by add the first argument sum. See also safe_logitcrossentropy
Transformers.enable_gpu — Functionenable_gpu(t=true)Enable gpu for todevice, disable with enable_gpu(false). The backend is selected by Flux.gpu_backend!. Should only be used in user scripts.
Transformers.firsttoken — Methodfirsttoken(x, m::AbstractSeqMask)Slice the first token from the hidden states. The "first" token is defined by the sequence mask.
Transformers.firsttoken — Methodfirsttoken(x)Slice the first tokens from the hidden states, normally equivalent to x[:, begin, :].
See also: lengthselect, skipboundarytoken
Transformers.lasttoken — Methodlasttoken(x, m::AbstractSeqMask)Slice the last token from the hidden states. The "last" token is defined by the sequence mask.
Transformers.lasttoken — Methodlasttoken(x)Slice the first tokens from the hidden states, normally equivalent to x[:, end, :].
See also: lengthselect, skipboundarytoken
Transformers.lengthselect — Methodlengthselect(x, i)selectdim on the "length" dimension (2 for most array and 1 for integer array).
Transformers.safe_crossentropy — Methodsafe_crossentropy(ŷ::AbstractArray, y::AbstractArray, m::AbstractSeqMask; ϵ)
safe_crossentropy(sum, ŷ::AbstractArray, y::AbstractArray, m::AbstractSeqMask; ϵ)crossentropy. If the label y is an integer array, then it would also call maximum on the label to make sure no label number is large then the first dimension of ŷ. See also unsafe_crossentropy.
Transformers.safe_logitcrossentropy — Methodsafe_logitcrossentropy(ŷ::AbstractArray, y::AbstractArray, m::AbstractSeqMask)
safe_logitcrossentropy(sum, ŷ::AbstractArray, y::AbstractArray, m::AbstractSeqMask)logitcrossentropy. If the label y is an integer array, then it would also call maximum on the label to make sure no label number is large then the first dimension of ŷ. See also unsafe_logitcrossentropy.
Transformers.skipboundarytoken — Methodskipboundarytoken(x; first=1, last=1)Select (lengthselect) the non-boundary tokens from the hidden states, normally equivalent to x[:, begin+first:end-last, :].
See also: lengthselect
Transformers.skipfirsttoken — Methodskipfirsttoken(x)Slice the non-first tokens from the hidden states, normally equivalent to x[:, 2:end, :].
See also: lengthselect, skipboundarytoken, skiplasttoken
Transformers.skiplasttoken — Methodskiplasttoken(x)Slice the non-last tokens from the hidden states, normally equivalent to x[:, 1:end-1, :].
See also: lengthselect, skipboundarytoken, skipfirsttoken
Transformers.todevice — Methodtodevice(x)Move data to device, only when gpu is enable with enable_gpu, basically equal Flux.gpu. Otherwise just Flux.cpu.
Transformers.togpudevice — Methodtogpudevice(x)Move data to gpu device, backend selected by Flux.gpu_backend!.
Transformers.unsafe_crossentropy — Methodunsafe_crossentropy(ŷ::AbstractArray, y::AbstractArray{<:Integer}, m::AbstractSeqMask; ϵ)
unsafe_crossentropy(sum, ŷ::AbstractArray, y::AbstractArray{<:Integer}, m::AbstractSeqMask; ϵ)Compute crossentropy with integer labels. The prefix "unsafe" means that if y contain any number larger than the first dimension of ŷ, the behavior is undefined. See also safe_crossentropy.
Transformers.unsafe_logitcrossentropy — Methodunsafe_logitcrossentropy(ŷ::AbstractArray, y::AbstractArray{<:Integer}, m::AbstractSeqMask)
unsafe_logitcrossentropy(sum, ŷ::AbstractArray, y::AbstractArray{<:Integer}, m::AbstractSeqMask)Compute logitcrossentropy with integer labels. The prefix "unsafe" means that if y contain any number larger than the first dimension of ŷ, the behavior is undefined. See also safe_logitcrossentropy.