You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 21, 2022. It is now read-only.
In a jsonargparse issue it was commented that to make lightning-transformers work, it was required to change the type Type["AutoModel"] to just Type, see jsonargparse#146 comment. Forward references like "AutoModel" are not currently supported in jsonargparse. This support could be added, but looking at the source of lightning-transformers this forward reference seems like a mistake. A type hint like Type[<class>] means that the accepted values are the <class> or any subclass of it. I could be wrong, but it seemed to me that the models don't inherit from AutoModel. Is this just a bug and the type should be just Type?
AutoModel inherits from a class _BaseAutoModelClass (see modeling_auto.py#L838) and that one does define .from_pretrained(), but my question remains. I debugged a couple of lightning-transformers unit tests to see which kind of classes were given to the downstream_model_type parameter. One example is transformers.models.auto.modeling_auto.AutoModelForCausalLM. This does not inherit from AutoModel, but it does inherit from _BaseAutoModelClass. See:
The type hint would need to be Type[_BaseAutoModelClass] instead of Type[AutoModel].
Fine, this can be changed.
why does it have to be a forward reference?
It doesn't have to. It's like this because it's conditionally imported under TYPE_CHECKING, probably to avoid unnecessarily importing transformers for just an annotation. Could be changed.
In a jsonargparse issue it was commented that to make lightning-transformers work, it was required to change the type
Type["AutoModel"]
to justType
, see jsonargparse#146 comment. Forward references like"AutoModel"
are not currently supported in jsonargparse. This support could be added, but looking at the source of lightning-transformers this forward reference seems like a mistake. A type hint likeType[<class>]
means that the accepted values are the<class>
or any subclass of it. I could be wrong, but it seemed to me that the models don't inherit fromAutoModel
. Is this just a bug and the type should be justType
?https://github.com/Lightning-AI/lightning-transformers/blob/bf8a215af13d07c31b052788f7b694412e6a32f7/lightning_transformers/core/model.py#L50
The text was updated successfully, but these errors were encountered: