Modify the vocab selection algorithm.

This commit is contained in:
Sang-Kil Park 2024-02-05 00:50:27 +09:00 committed by GitHub
parent 531b470546
commit 15c2df9126
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -334,9 +334,9 @@ class Params:
class BpeVocab:
def __init__(self, fname_tokenizer: Path, fname_added_tokens: Path | None) -> None:
self.bpe_tokenizer = json.loads(open(str(fname_tokenizer), encoding="utf-8").read())
try:
if isinstance(self.bpe_tokenizer.get('model'), dict):
self.vocab = self.bpe_tokenizer["model"]["vocab"]
except (KeyError, TypeError):
else:
self.vocab = self.bpe_tokenizer
added_tokens: dict[str, int]
if fname_added_tokens is not None: