Class MarianCosineScorer

Class Documentation

class MarianCosineScorer

MarianCosineScorer takes a Marian sequence2sequence transformer model and produces sentence-wise cosine similarities for two sentence embeddings.

Public Functions

std::vector<float> score(const std::string &input1, const std::string &input2)

input1 and input2 are big strings with multiple sentences separated by ‘


Both inputs have to have the same number of separated lines. Returns a vector of similarity scores in order corresponding to input sentence order.

bool load(const std::string &modelPath, const std::string &vocabPath)

modelPath is a Marian model, vocabPath a matching SentencePiece model with *.spm suffix.