Skip to content

Commit

Permalink
fix Tokenizer load error when the path of the being-converted model i…
Browse files Browse the repository at this point in the history
…s not writable (#669)
  • Loading branch information
irexyc authored Nov 9, 2023
1 parent 013000d commit 18170ee
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lmdeploy/tokenizer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) OpenMMLab. All rights reserved.
import json
import os
import os.path as osp
from typing import Optional, Sequence, Union

Expand Down Expand Up @@ -125,7 +126,8 @@ def __init__(self, model_dir: str):
# save tokenizer.json to reuse
if not osp.exists(backend_tokenizer_file) and model_file_exists:
if hasattr(self.model, 'backend_tokenizer'):
self.model.backend_tokenizer.save(backend_tokenizer_file)
if os.access(model_dir, os.W_OK):
self.model.backend_tokenizer.save(backend_tokenizer_file)

if self.model.eos_token_id is None:
generation_config_file = osp.join(model_dir,
Expand Down

0 comments on commit 18170ee

Please sign in to comment.