Comments (5)
cc @Rocketknight1 :)
from transformers.
Hi @ljw20180420, I'm not sure that a custom pipeline with a custom model in a totally different repo is supported. In particular, doing things this way makes it very hard to know what the model
kwarg to pipeline()
is supposed to mean - is it the repo you're loading the pipeline from or the repo you're loading the model from?
I think a better approach would be:
- Make sure the repos you're interested in, like
ljw20180420/SX_spcas9_inDelphi
are loadable with the relevant AutoModel classes - Add the pipeline code to each repo
- Check if you can load them with
pipe = pipeline(model="ljw20180420/SX_spcas9_inDelphi", trust_remote_code=True)
If that workflow creates problems, please let us know here!
from transformers.
Thank you @Rocketknight1. I now push the pipeline to the same repository as the model at "ljw20180420/SX_spcas9_inDelphi".
from transformers import pipeline
from transformers import AutoModel
inDelphi_model = AutoModel.from_pretrained("ljw20180420/SX_spcas9_inDelphi", trust_remote_code=True)
pipe = pipeline(model="ljw20180420/SX_spcas9_inDelphi", trust_remote_code=True)
AutoModel can load the model. But pipeline cannot be loaded.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ljw/new_fold/old_desktop/CRISPR_AI/.conda/lib/python3.11/site-packages/transformers/pipelines/__init__.py", line 833, in pipeline
targeted_task, task_options = clean_custom_task(custom_tasks[task])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ljw/new_fold/old_desktop/CRISPR_AI/.conda/lib/python3.11/site-packages/transformers/pipelines/__init__.py", line 544, in clean_custom_task
task_info["pt"] = tuple(getattr(transformers, c) for c in pt_class_names)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ljw/new_fold/old_desktop/CRISPR_AI/.conda/lib/python3.11/site-packages/transformers/pipelines/__init__.py", line 544, in <genexpr>
task_info["pt"] = tuple(getattr(transformers, c) for c in pt_class_names)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ljw/new_fold/old_desktop/CRISPR_AI/.conda/lib/python3.11/site-packages/transformers/utils/import_utils.py", line 1596, in __getattr__
raise AttributeError(f"module {self.__name__} has no attribute {name}")
AttributeError: module transformers has no attribute inDelphiModel
from transformers.
Hi @ljw20180420, okay! I took a quick look - I think one issue is that in config.json
, you probably want to replace "inDelphiModel"
in the pipeline impl
key with "AutoModel"
. The reason is that most pipelines are intended to work with multiple models, and so an AutoModel
category is expected here, rather than a single specific model.
If that config.json
was generated automatically by transformers
, let me know - that might be something we need to fix!
from transformers.
Thank you @Rocketknight1. I generate config.json
by Trainer.push_to_hub()
and Pipeline.push_to_hub()
.
My source codes are at [email protected]:ljw20180420/CRISPR_AI.git. In the folder CRISPR_AI, execute
inDelphi/report_bug.py
The source of report_bug.py is
from inDelphi.configuration_inDelphi import inDelphiConfig
from inDelphi.modeling_inDelphi import inDelphiModel
from inDelphi.pipeline_inDelphi import inDelphiPipeline
from transformers import Trainer
from transformers.pipelines import PIPELINE_REGISTRY
from transformers import pipeline
inDelphiConfig.register_for_auto_class()
inDelphiModel.register_for_auto_class()
inDelphi_model = inDelphiModel(inDelphiConfig())
trainer = Trainer(model = inDelphi_model)
trainer.push_to_hub()
from huggingface_hub import HfApi
api = HfApi()
while True:
try:
api.upload_file(
path_or_fileobj = "inDelphi/inDelphi_inertion_model.pkl",
path_in_repo = "inDelphi_inertion_model.pkl",
repo_id = "ljw20180420/tmp_trainer",
repo_type = "model"
)
break
except:
print("upload failed, retry")
PIPELINE_REGISTRY.register_pipeline(
task="predict CRISPR indel",
pipeline_class=inDelphiPipeline,
pt_model=inDelphiModel
)
pipe = pipeline(
task="predict CRISPR indel",
model="ljw20180420/tmp_trainer",
trust_remote_code=True
)
pipe.push_to_hub("tmp_trainer")
After trainer.push_to_hub()
, I upload an auxiliary file "inDelphi_inertion_model.pkl" (this should be irrelevant). The config.json
is
{
"DELLEN_LIMIT": 60,
"architectures": [
"inDelphiModel"
],
"auto_map": {
"AutoConfig": "configuration_inDelphi.inDelphiConfig",
"AutoModel": "modeling_inDelphi.inDelphiModel"
},
"mid_dim": 16,
"model_type": "inDelphi",
"seed": 63036,
"torch_dtype": "float32",
"transformers_version": "4.44.2"
}
After register the pipeline, pipe
can load the remote model correctly because config.json
have no attribute "custom_pipelines". Nevertheless, after pipe.push_to_hub("tmp_trainer")
, it will modify config.json
to
{
"DELLEN_LIMIT": 60,
"_name_or_path": "ljw20180420/tmp_trainer",
"architectures": [
"inDelphiModel"
],
"auto_map": {
"AutoConfig": "configuration_inDelphi.inDelphiConfig",
"AutoModel": "modeling_inDelphi.inDelphiModel"
},
"custom_pipelines": {
"predict CRISPR indel": {
"impl": "pipeline_inDelphi.inDelphiPipeline",
"pt": [
"inDelphiModel"
],
"tf": []
}
},
"mid_dim": 16,
"model_type": "inDelphi",
"seed": 63036,
"torch_dtype": "float32",
"transformers_version": "4.44.2"
}
The new attribute causes the bug.
from transformers.
Related Issues (20)
- can't resume lora training due to wandb logging num params
- Phi-3's tokenizer `.convert_ids_to_tokens` returns bytes instead of a string HOT 1
- The forced adoption of low_cpu_mem_usage behavior ruins models that require absolute position embedding. HOT 2
- Phi-3 maximum recursion depth exceeded when execute AutoModelForCausalLM.from_pretrained HOT 2
- for LlaVA output of image_hidden_states not possible? HOT 1
- Bug with finetuning Gemma 2 models HOT 3
- DINOV2 generate different outputs for the same inputs HOT 6
- Can't run docker because of flash attention 2? HOT 1
- Training Resumes with Increased Loss Despite Checkpoint Loading HOT 1
- How do LLMs identify generation start point during fine-tuning? HOT 1
- [Nougat] image after NougatProcessor leads to Traceback HOT 1
- Add "EAT: Self-Supervised Pre-Training with Efficient Audio Transformer"
- How to install transformers==4.45, two or three days I can install successfully, but today cannot. HOT 2
- Accelerate x Trainer issue tracker: HOT 7
- ImportError: attempted relative import with no known parent package HOT 2
- List of Typos in the `transformers[en]` Docs
- bus error on version 4.43.0 with pretrained community CLIP model - MacOS HOT 5
- Can't save quantized models HOT 7
- [Docs] How to build offline HTML or Docset files for other documentation viewers? HOT 1
- Pipelines download the latest revision by default instead of the default/output revision HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transformers.