add shallow fusion (#147)
This commit is contained in:
@@ -22,21 +22,27 @@ class OnlineRnnLM : public OnlineLM {
|
||||
|
||||
explicit OnlineRnnLM(const OnlineLMConfig &config);
|
||||
|
||||
std::vector<Ort::Value> GetInitStates() override;
|
||||
std::pair<Ort::Value, std::vector<Ort::Value>> GetInitStates() override;
|
||||
|
||||
/** Rescore a batch of sentences.
|
||||
/** ScoreToken a batch of sentences.
|
||||
*
|
||||
* @param x A 2-D tensor of shape (N, L) with data type int64.
|
||||
* @param y A 2-D tensor of shape (N, L) with data type int64.
|
||||
* @param states It contains the states for the LM model
|
||||
* @return Return a pair containingo
|
||||
* - negative loglike
|
||||
* - log_prob of NN LM
|
||||
* - updated states
|
||||
*
|
||||
* Caution: It returns negative log likelihood (nll), not log likelihood
|
||||
*/
|
||||
std::pair<Ort::Value, std::vector<Ort::Value>> Rescore(
|
||||
Ort::Value x, Ort::Value y, std::vector<Ort::Value> states) override;
|
||||
std::pair<Ort::Value, std::vector<Ort::Value>> ScoreToken(
|
||||
Ort::Value x, std::vector<Ort::Value> states) override;
|
||||
|
||||
/** This function updates lm_lob_prob and nn_lm_scores of hyp
|
||||
*
|
||||
* @param scale LM score
|
||||
* @param hyps It is changed in-place.
|
||||
*
|
||||
*/
|
||||
void ComputeLMScore(float scale, Hypothesis *hyp) override;
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
|
||||
Reference in New Issue
Block a user