model: validate left and right pairs before merging them
This commit is contained in:
parent
63a394068c
commit
20e3593863
@ -169,6 +169,10 @@ func (spm SentencePieceModel) Encode(s string, addSpecial bool) ([]int32, error)
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if id := spm.vocab.Encode(string(left.runes) + string(right.runes)); id < 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
merges[pair.a].runes = append(left.runes, right.runes...)
|
merges[pair.a].runes = append(left.runes, right.runes...)
|
||||||
merges[pair.b].runes = nil
|
merges[pair.b].runes = nil
|
||||||
merges[pair.a].n = right.n
|
merges[pair.a].n = right.n
|
||||||
|
Loading…
x
Reference in New Issue
Block a user