py : pad with unknown tokens when data is missing
ggml-ci
This commit is contained in:
parent
9b464b4e81
commit
a1372737e0
1 changed files with 9 additions and 0 deletions
|
@ -1098,6 +1098,15 @@ class OutputFile:
|
|||
scores.append(score)
|
||||
toktypes.append(toktype)
|
||||
|
||||
# pad with unknown tokens and print warnings
|
||||
# ref: https://github.com/ggerganov/llama.cpp/issues/4958
|
||||
if len(tokens) < vocab.vocab_size:
|
||||
for i in range(len(tokens), vocab.vocab_size):
|
||||
tokens.append(f"<unk{i}>".encode("utf-8"))
|
||||
scores.append(-1000.0)
|
||||
toktypes.append(gguf.TokenType.UNKNOWN)
|
||||
print(f"Warning: token {i} not found in vocab - padding with {tokens[-1]}")
|
||||
|
||||
return tokens, scores, toktypes
|
||||
|
||||
def add_meta_vocab(self, vocab: Vocab) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue