mirror of
https://github.com/huggingface/transformers.git
synced 2025-08-01 18:51:14 +06:00
Auto api Value Error addition to Troubleshoot (#21708)
* troubleshooting guide: added an error description for missing auto-mapping * minor polishing * changed the example * Apply suggestions from code review Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com> * Update docs/source/en/troubleshooting.mdx Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> --------- Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com> Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
This commit is contained in:
parent
0ffa22f9f6
commit
04d90ac49e
@ -174,3 +174,25 @@ tensor([[ 0.0082, -0.2307],
|
|||||||
|
|
||||||
- Some models don't have a padding token.
|
- Some models don't have a padding token.
|
||||||
- For some use-cases, users want a model to attend to a padding token.
|
- For some use-cases, users want a model to attend to a padding token.
|
||||||
|
|
||||||
|
## ValueError: Unrecognized configuration class XYZ for this kind of AutoModel
|
||||||
|
|
||||||
|
Generally, we recommend using the [`AutoModel`] class to load pretrained instances of models. This class
|
||||||
|
can automatically infer and load the correct architecture from a given checkpoint based on the configuration. If you see
|
||||||
|
this `ValueError` when loading a model from a checkpoint, this means the Auto class couldn't find a mapping from
|
||||||
|
the configuration in the given checkpoint to the kind of model you are trying to load. Most commonly, this happens when a
|
||||||
|
checkpoint doesn't support a given task.
|
||||||
|
For instance, you'll see this error in the following example because there is no GPT2 for question answering:
|
||||||
|
|
||||||
|
```py
|
||||||
|
>>> from transformers import AutoProcessor, AutoModelForQuestionAnswering
|
||||||
|
|
||||||
|
>>> processor = AutoProcessor.from_pretrained("gpt2-medium")
|
||||||
|
>>> model = AutoModelForQuestionAnswering.from_pretrained("gpt2-medium")
|
||||||
|
ValueError: Unrecognized configuration class <class 'transformers.models.gpt2.configuration_gpt2.GPT2Config'> for this kind of AutoModel: AutoModelForQuestionAnswering.
|
||||||
|
Model type should be one of AlbertConfig, BartConfig, BertConfig, BigBirdConfig, BigBirdPegasusConfig, BloomConfig, ...
|
||||||
|
```
|
||||||
|
|
||||||
|
In rare cases, this can also happen when using some exotic models with architectures that don't map to any of the
|
||||||
|
AutoModelForXXX classes due to the specifics of their API. For example, you can use [`AutoProcessor`] to load BLIP-2's processor,
|
||||||
|
but to load a pretrained BLIP-2 model itself, you must explicitly use [`Blip2ForConditionalGeneration`] as even [`AutoModel`] won't work.
|
||||||
|
Loading…
Reference in New Issue
Block a user