Created
February 21, 2023 15:38
-
-
Save pacman100/9b3c1faf966f21c945529f6ad945c019 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ | |
│ /tmp/ipykernel_2299032/1843815119.py:2 in <module> │ | |
│ │ | |
│ [Errno 2] No such file or directory: '/tmp/ipykernel_2299032/1843815119.py' │ | |
│ │ | |
│ /home/sourab/miniconda3/envs/ml/lib/python3.10/site-packages/optimum/onnxruntime/modeling_ort.py │ | |
│ :581 in from_pretrained │ | |
│ │ | |
│ 578 │ │ Returns: │ | |
│ 579 │ │ │ `ORTModel`: The loaded ORTModel model. │ | |
│ 580 │ │ """ │ | |
│ ❱ 581 │ │ return super().from_pretrained( │ | |
│ 582 │ │ │ model_id, │ | |
│ 583 │ │ │ from_transformers=from_transformers, │ | |
│ 584 │ │ │ force_download=force_download, │ | |
│ │ | |
│ /home/sourab/miniconda3/envs/ml/lib/python3.10/site-packages/optimum/modeling_base.py:341 in │ | |
│ from_pretrained │ | |
│ │ | |
│ 338 │ │ │ trust_remote_code = False │ | |
│ 339 │ │ │ | |
│ 340 │ │ from_pretrained_method = cls._from_transformers if from_transformers else cls._f │ | |
│ ❱ 341 │ │ return from_pretrained_method( │ | |
│ 342 │ │ │ model_id=model_id, │ | |
│ 343 │ │ │ config=config, │ | |
│ 344 │ │ │ revision=revision, │ | |
│ │ | |
│ /home/sourab/miniconda3/envs/ml/lib/python3.10/site-packages/optimum/onnxruntime/modeling_seq2se │ | |
│ q.py:1125 in _from_transformers │ | |
│ │ | |
│ 1122 │ │ save_dir = TemporaryDirectory() │ | |
│ 1123 │ │ save_dir_path = Path(save_dir.name) │ | |
│ 1124 │ │ │ | |
│ ❱ 1125 │ │ model = TasksManager.get_model_from_task( │ | |
│ 1126 │ │ │ task, │ | |
│ 1127 │ │ │ model_id, │ | |
│ 1128 │ │ │ subfolder=subfolder, │ | |
│ │ | |
│ /home/sourab/miniconda3/envs/ml/lib/python3.10/site-packages/optimum/exporters/tasks.py:974 in │ | |
│ get_model_from_task │ | |
│ │ | |
│ 971 │ │ │ The instance of the model. │ | |
│ 972 │ │ │ | |
│ 973 │ │ """ │ | |
│ ❱ 974 │ │ framework = TasksManager.determine_framework(model_name_or_path, subfolder=subfo │ | |
│ 975 │ │ if task == "auto": │ | |
│ 976 │ │ │ task = TasksManager.infer_task_from_model(model_name_or_path, subfolder=subf │ | |
│ 977 │ │ model_class = TasksManager.get_model_class_for_task(task, framework) │ | |
│ │ | |
│ /home/sourab/miniconda3/envs/ml/lib/python3.10/site-packages/optimum/exporters/tasks.py:830 in │ | |
│ determine_framework │ | |
│ │ | |
│ 827 │ │ │ elif (full_model_path / TF2_WEIGHTS_NAME).is_file(): │ | |
│ 828 │ │ │ │ framework = "tf" │ | |
│ 829 │ │ │ else: │ | |
│ ❱ 830 │ │ │ │ raise FileNotFoundError( │ | |
│ 831 │ │ │ │ │ "Cannot determine framework from given checkpoint location." │ | |
│ 832 │ │ │ │ │ f" There should be a {WEIGHTS_NAME} for PyTorch" │ | |
│ 833 │ │ │ │ │ f" or {TF2_WEIGHTS_NAME} for TensorFlow." │ | |
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ | |
FileNotFoundError: Cannot determine framework from given checkpoint location. There should be a pytorch_model.bin | |
for PyTorch or tf_model.h5 for TensorFlow. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from peft import PeftModel, PeftConfig | |
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer | |
model_id = "smangrul/twitter_complaints_google_flan-t5-xxl_LORA_SEQ_2_SEQ_LM" | |
config = PeftConfig.from_pretrained(model_id) | |
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path) | |
model = AutoModelForSeq2SeqLM.from_pretrained(config.base_model_name_or_path) | |
model = PeftModel.from_pretrained(model, model_id) | |
model.base_model.model.save_pretrained("./temp_lora") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from optimum.onnxruntime import ORTModelForSeq2SeqLM | |
model = ORTModelForSeq2SeqLM.from_pretrained("./temp_lora", from_transformers=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment