pulsatrix 1.1.0
Loading...
Searching...
No Matches
pulsatrix::WordLevelModel Class Reference

Each piece is one token, looked up in a vocabulary; unknown pieces become the unknown token. More...

#include <tokenizer_components.hpp>

Inheritance diagram for pulsatrix::WordLevelModel:
Collaboration diagram for pulsatrix::WordLevelModel:

Public Member Functions

 WordLevelModel (std::vector< std::string > vocab, const std::string &unk_token)
 
std::vector< ModelToken > tokenize (std::string_view piece) const override
 
std::optional< int64_t > token_to_id (std::string_view token) const override
 
std::optional< std::string > id_to_token (int64_t id) const override
 
int64_t vocab_size () const override
 One more than the largest id the model can produce.
 
- Public Member Functions inherited from pulsatrix::TokenModel
virtual ~TokenModel ()=default
 

Detailed Description

Each piece is one token, looked up in a vocabulary; unknown pieces become the unknown token.

Constructor & Destructor Documentation

◆ WordLevelModel()

pulsatrix::WordLevelModel::WordLevelModel ( std::vector< std::string >  vocab,
const std::string &  unk_token 
)
Parameters
vocabToken strings by id.
Exceptions
std::invalid_argumentif unk_token isn't in it, or a token repeats.

Member Function Documentation

◆ id_to_token()

std::optional< std::string > pulsatrix::WordLevelModel::id_to_token ( int64_t  id) const
overridevirtual

Implements pulsatrix::TokenModel.

◆ token_to_id()

std::optional< int64_t > pulsatrix::WordLevelModel::token_to_id ( std::string_view  token) const
overridevirtual

Implements pulsatrix::TokenModel.

◆ tokenize()

std::vector< ModelToken > pulsatrix::WordLevelModel::tokenize ( std::string_view  piece) const
overridevirtual

Implements pulsatrix::TokenModel.

◆ vocab_size()

int64_t pulsatrix::WordLevelModel::vocab_size ( ) const
inlineoverridevirtual

One more than the largest id the model can produce.

Implements pulsatrix::TokenModel.


The documentation for this class was generated from the following file: