Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BPETokenizer ¶
type BPETokenizer struct {
*bpetokenizer.BPETokenizer
EosTokenID int
BosTokenID int
PadTokenID int
DecoderStartTokenID int
ExtraSpecialTokenIDs map[int]string
}
func (*BPETokenizer) Detokenize ¶
func (m *BPETokenizer) Detokenize(tokenIds []int, stripPaddingTokens bool) string
Detokenize returns the text of the input token IDs removing the padding token.
type SentencePieceTokenizer ¶
type SentencePieceTokenizer struct {
*sentencepiece.Tokenizer
EosTokenID int
BosTokenID int
PadTokenID int
DecoderStartTokenID int
}
func (*SentencePieceTokenizer) Detokenize ¶
func (m *SentencePieceTokenizer) Detokenize(tokenIds []int, stripPaddingTokens bool) string
Detokenize returns the text of the input token IDs removing the padding token.
type TextGeneration ¶
type TextGeneration struct {
// Model is the model used for conditional generation.
Model *bart.ModelForConditionalGeneration
// Tokenizer is the tokenizer used for conditional generation.
Tokenizer Tokenizer
}
TextGeneration contains the ModelForConditionalGeneration and the Tokenizer used for conditional generation tasks. For example, Machine Translation and Summarization.
func LoadTextGeneration ¶
func LoadTextGeneration(modelPath string) (*TextGeneration, error)
LoadTextGeneration returns a TextGeneration loading the model, the embeddings and the tokenizer from a directory.
func (*TextGeneration) Generate ¶
func (m *TextGeneration) Generate(ctx context.Context, text string, opts *textgeneration.Options) (textgeneration.Response, error)
Generate generates a text from the input.
Click to show internal directories.
Click to hide internal directories.