Closed voxmenthe closed 3 weeks ago
Ok, I think we need to add a CLI option to let enable trust_remote_code
for the conversion script.
@voxmenthe it turns out we don't need an option for this. Just press Y
when the command prompts you to trust remote code for the tokenizer and it should run fine. And make sure sentencepiece
is installed pip install sentencepiece
.
mlx version: 0.16 mlx-lm version: 0.15.2 python version: Python 3.12.4
Steps to duplicate:
Error trace: [INFO] Loading configuration_internlm2.py: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8.84k/8.84k [00:00<00:00, 29.2MB/s] model-00006-of-00021.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 1.94G/1.94G [03:46<00:00, 8.56MB/s] model-00007-of-00021.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 1.96G/1.96G [04:00<00:00, 8.17MB/s] model-00008-of-00021.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 1.94G/1.94G [04:26<00:00, 7.28MB/s] model-00009-of-00021.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 1.96G/1.96G [03:33<00:00, 9.18MB/s] model-00010-of-00021.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 1.94G/1.94G [03:31<00:00, 9.16MB/s] model-00011-of-00021.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 1.96G/1.96G [03:36<00:00, 9.07MB/s] model-00012-of-00021.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 1.94G/1.94G [03:35<00:00, 8.97MB/s] model-00013-of-00021.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 1.96G/1.96G [03:35<00:00, 9.09MB/s] model-00014-of-00021.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 1.94G/1.94G [03:31<00:00, 9.14MB/s] model-00015-of-00021.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 1.96G/1.96G [03:48<00:00, 8.57MB/s] model-00016-of-00021.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 1.94G/1.94G [03:33<00:00, 9.08MB/s] model-00017-of-00021.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 1.96G/1.96G [03:45<00:00, 8.71MB/s] model-00018-of-00021.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 1.94G/1.94G [03:38<00:00, 8.87MB/s] model-00019-of-00021.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 1.96G/1.96G [03:35<00:00, 9.11MB/s] model-00020-of-00021.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 1.56G/1.56G [02:41<00:00, 9.69MB/s] model-00021-of-00021.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉| 1.14G/1.14G [01:45<00:00, 10.8MB/s] model.safetensors.index.json: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 27.2k/27.2k [00:00<00:00, 51.5MB/s] modeling_internlm2.py: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 81.0k/81.0k [00:00<00:00, 3.58MB/s] special_tokens_map.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 713/713 [00:00<00:00, 6.26MB/s] tokenization_internlm2.py: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8.81k/8.81k [00:00<00:00, 60.4MB/s] tokenization_internlm2_fast.py: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 7.80k/7.80k [00:00<00:00, 55.8MB/s] tokenizer.model: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.48M/1.48M [00:00<00:00, 6.35MB/s] tokenizer_config.json: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.51k/2.51k [00:00<00:00, 9.45MB/s] The repository for /Users/jeffcoggshall/ExtremeSSD/huggingface_cache/models--internlm--internlm2_5-20b-chat/snapshots/3a276a1dedc6863be72505a6a721c7c59d0f818c contains custom code which must be executed to correctly load the model. You can inspect the repository content at https://hf.co//Users/jeffcoggshall/ExtremeSSD/huggingface_cache/models--internlm--internlm2_5-20b-chat/snapshots/3a276a1dedc6863be72505a6a721c7c59d0f818c. You can avoid this prompt in future by passing the argument
trust_remote_code=True
.Do you wish to run the custom code? [y/N] Traceback (most recent call last): File "/Users/jeffcoggshall/venvs/py3124/lib/python3.12/site-packages/transformers/dynamic_module_utils.py", line 613, in resolve_trust_remote_code answer = input( ^^^^^^ File "/Users/jeffcoggshall/venvs/py3124/lib/python3.12/site-packages/transformers/dynamic_module_utils.py", line 594, in _raise_timeout_error raise ValueError( ValueError: Loading this model requires you to execute custom code contained in the model repository on your local machine. Please set the option
trust_remote_code=True
to permit loading of this model.During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "/Users/jeffcoggshall/venvs/py3124/lib/python3.12/site-packages/mlx_lm/convert.py", line 62, in
main()
File "/Users/jeffcoggshall/venvs/py3124/lib/python3.12/site-packages/mlx_lm/convert.py", line 58, in main
convert(vars(args))
File "/Users/jeffcoggshall/venvs/py3124/lib/python3.12/site-packages/mlx_lm/utils.py", line 701, in convert
model, config, tokenizer = fetch_from_hub(model_path, lazy=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jeffcoggshall/venvs/py3124/lib/python3.12/site-packages/mlx_lm/utils.py", line 499, in fetch_from_hub
tokenizer = load_tokenizer(model_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jeffcoggshall/venvs/py3124/lib/python3.12/site-packages/mlx_lm/tokenizer_utils.py", line 328, in load_tokenizer
AutoTokenizer.from_pretrained(model_path, tokenizer_config_extra),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jeffcoggshall/venvs/py3124/lib/python3.12/site-packages/transformers/models/auto/tokenization_auto.py", line 861, in from_pretrained
trust_remote_code = resolve_trust_remote_code(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jeffcoggshall/venvs/py3124/lib/python3.12/site-packages/transformers/dynamic_module_utils.py", line 626, in resolve_trust_remote_code
raise ValueError(
ValueError: The repository for /Users/jeffcoggshall/ExtremeSSD/huggingface_cache/models--internlm--internlm2_5-20b-chat/snapshots/3a276a1dedc6863be72505a6a721c7c59d0f818c contains custom code which must be executed to correctly load the model. You can inspect the repository content at https://hf.co//Users/jeffcoggshall/ExtremeSSD/huggingface_cache/models--internlm--internlm2_5-20b-chat/snapshots/3a276a1dedc6863be72505a6a721c7c59d0f818c.
Please pass the argument
trust_remote_code=True
to allow custom code to be run.