Closed jiqing-feng closed 4 days ago
Hi @echarlaix , you were right; it's difficult to get the task from the local model. I think we should let users assign tasks in the API because it is hard to remember all IPEXModel classes, such as IPEXModelForCausalLM
. With my changes, users can easily use it by IPEXModel.from_pretrained("gpt2", task="text-generation")
.
It is more friendly for users, WDYT?
The transformers AutoModel
doesn't map task classes, but rather feature-extraction
models. For example using AutoModel
with a bert-base-uncased
model will return the core BertModel
(with no task head) https://github.com/huggingface/transformers/blob/dc76e9fa7f0d19ff7cfc33bd3a22acd7df167fce/src/transformers/models/bert/modeling_bert.py#L956.
same thing for llama for example it will return the LlamaModel
class https://github.com/huggingface/transformers/blob/dc76e9fa7f0d19ff7cfc33bd3a22acd7df167fce/src/transformers/models/llama/modeling_llama.py#L869.
model = AutoModel.from_pretrained("facebook/opt-125m")
print(model.__class__) # <class 'transformers.models.opt.modeling_opt.OPTModel'>
This feature will result in a big API difference and confusion around the feature-extraction
task and its specific auto class.
The transformers
AutoModel
doesn't map task classes, but ratherfeature-extraction
models. For example usingAutoModel
with abert-base-uncased
model will return the coreBertModel
(with no task head) https://github.com/huggingface/transformers/blob/dc76e9fa7f0d19ff7cfc33bd3a22acd7df167fce/src/transformers/models/bert/modeling_bert.py#L956. same thing for llama for example it will return theLlamaModel
class https://github.com/huggingface/transformers/blob/dc76e9fa7f0d19ff7cfc33bd3a22acd7df167fce/src/transformers/models/llama/modeling_llama.py#L869.model = AutoModel.from_pretrained("facebook/opt-125m") print(model.__class__) # <class 'transformers.models.opt.modeling_opt.OPTModel'>
This feature will result in a big API difference and confusion around the
feature-extraction
task.
Thanks @IlyasMoutawwakil ! I realized it and have changed the API to support assigned task instead of mapping task by the model. Do you mind take a review? Thx!
Refer to https://github.com/huggingface/optimum-intel/pull/780#issuecomment-2192981222
My last comment is about the new changes.
This feature will result in a big API difference and confusion around the feature-extraction task and its specific auto class. (
AutoModel
vsIPEXModel
)
The current API is based on the simplicity of going from the transformers AutoModelForxxx
to IPEXModelForxxx
or OVModelForxxxx
, which allows them to go from one backend to another and use the one that gives the best hardware compatibility and/or utilization.
Also the pipeline
function already allow for the "single entry point" API.
My last comment is about the new changes.
This feature will result in a big API difference and confusion around the feature-extraction task and its specific auto class. (
AutoModel
vsIPEXModel
)The current API is based on the simplicity of going from the transformers
AutoModelForxxx
toIPEXModelForxxx
orOVModelForxxxx
, which allows them to go from one backend to another and use the one that gives the best hardware compatibility and/or utilization.Also the
pipeline
function already allow for the "single entry point" API.
Sorry for not making it clear; my change has no impact on IPEXModel except you pass the parameter task
. I will close it if you think exposing the parameter task
is not acceptable, but I want to make sure I have clarified it. Thx :)
Sorry for not making it clear; my change has no impact on IPEXModel except you pass the parameter
task
. I will close it if you think exposing the parametertask
is not acceptable, but I want to make sure I have clarified it. Thx :)
Thanks a lot @jiqing-feng, closing it
Hi @echarlaix. This PR enables auto mapping for model class, which mean we can use
IPEXModel
to load any supported task, for exampleIPEXModel.from_pretrained("meta-llama/Llama-2-7b-chat-hf")
will map theIPEXModelForCausalLM
class to export the model.The usage is the same as
AutoModel
from transformers.