Skip to content

Conversation

wj-Mcat
Copy link
Contributor

@wj-Mcat wj-Mcat commented Jul 8, 2022

PR types

Bug fixes

PR changes

Models

Description

Environment

paddlenlp             2.3.3
paddleocr             2.5.0.3
paddlepaddle-gpu      2.3.0

Reproduction

import paddle

from paddlenlp.transformers import AutoModelForPretraining, AutoTokenizer, AutoModelForQuestionAnswering
from paddlenlp.transformers import AutoModelForMaskedLM, AutoModelForCausalLM
model = AutoModelForMaskedLM.from_pretrained('gpt2-en') 

error stacktrack message:

AttributeError: module 'paddlenlp.transformers.gpt.modeling' only supports the following classes: GPTModel, GPTPretrainedModel, GPTForPretraining, GPTPretrainingCriterion, GPTForGreedyGeneration, GPTLMHeadModel, GPTForTokenClassification, GPTForSequenceClassification, GPTForCausalLM
Hint: you can use interface AutoModelForTokenClassification.from_pretrainedor AutoModel.from_pretrainedor AutoModelForCausalLM.from_pretrainedor AutoModelForPretraining.from_pretrainedor AutoModelForSequenceClassification.from_pretrained to load 'gpt2-en'

Analysis

the error info of AutoModelForPretraining.from_pretrainedor is printed into the terminal. After checkout the source code, I find that the reason is from the following code:

source code

raise AttributeError(
    f"module '{import_class.__name__}' only supports the following classes: "
    + ", ".join(m for m in all_model_classes) + "\n"
    "Hint: you can use interface " +
    "or ".join(task + ".from_pretrained"
                for task in all_tasks) +
    f" to load '{pretrained_model_name_or_path}'\n")

Unit test

assert "or ".join(["1", "2"]) == "1or 2"

wj-Mcat added a commit to wj-Mcat/PaddleNLP that referenced this pull request Jul 11, 2022
@guoshengCS guoshengCS merged commit 6e1372f into PaddlePaddle:develop Jul 14, 2022
guoshengCS added a commit that referenced this pull request Aug 9, 2022
* add opt model

* update opt modeling

* complete all of test

* remove remote file link from opt configuration

* enable auto model with opt

* remove pretraining and criterion

* remove OPTLMHeadModel

* remove `remove_final_layer_norm`

* add example for opt text generation

* improve auto model & tokenizer

* keep the same code style

* revert changes fixed by #2764

* remove unused character

* use transformer-decoder-layer in opt

* align demo with huggingface website

* add opt op operations

* update faster entry

* add opt convert_param supporting

* add Makefile to manualy build faster transformer

* fix fp16 usage

* add performance & sample

* update opt modeling docstring

* update opt by comments

* remove Makefile && recover CMakeLists.txt

* update metric of opt

* update opt perf image

* update opt example

* remove opt & gpt image file to reduce size of repo

* remove bart file

* remove bart file to reduce the size of repo

Co-authored-by: Guo Sheng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants