{"record":{"id":"1e9750631104a1f3","repo":"hankcs/HanLP","slug":"the-class-pretrainedbartmodel-has-been-depreciat","errorCode":null,"errorMessage":"The class `PretrainedBartModel` has been depreciated, please use `BartPretrainedModel` instead.","messagePattern":"The class `PretrainedBartModel` has been depreciated, please use `BartPretrainedModel` instead\\.","errorType":"console","errorClass":"FutureWarning","httpStatus":null,"severity":"warning","filePath":"hanlp/components/amr/amrbart/model_interface/modeling_bart.py","lineNumber":530,"sourceCode":"\n    def _set_gradient_checkpointing(self, module, value=False):\n        if isinstance(module, (BartDecoder, BartEncoder)):\n            module.gradient_checkpointing = value\n\n    @property\n    def dummy_inputs(self):\n        pad_token = self.config.pad_token_id\n        input_ids = torch.tensor([[0, 6, 10, 4, 2], [0, 8, 12, 2, pad_token]], device=self.device)\n        dummy_inputs = {\n            \"attention_mask\": input_ids.ne(pad_token),\n            \"input_ids\": input_ids,\n        }\n        return dummy_inputs\n\n\nclass PretrainedBartModel(BartPretrainedModel):\n    def __init_subclass__(self):\n        warnings.warn(\n            \"The class `PretrainedBartModel` has been depreciated, please use `BartPretrainedModel` instead.\",\n            FutureWarning,\n        )\n\n\nBART_START_DOCSTRING = r\"\"\"\n    This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the\n    library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads\n    etc.)\n\n    This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.\n    Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage\n    and behavior.\n\n    Parameters:\n        config ([`BartConfig`]):\n            Model configuration class with all the parameters of the model. Initializing with a config file does not\n            load the weights associated with the model, only the configuration. Check out the","sourceCodeStart":512,"sourceCodeEnd":548,"githubUrl":"https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/amr/amrbart/model_interface/modeling_bart.py#L512-L548","documentation":"FutureWarning emitted by __init_subclass__ whenever anything subclasses the deprecated alias PretrainedBartModel (from the vendored AMR-BART modeling file). It mirrors HuggingFace's deprecation; the real class is BartPretrainedModel.","triggerScenarios":"Defining any class PretrainedBartModel as base, or importing old user code / third-party code that subclasses PretrainedBartModel during class definition.","commonSituations":"Porting older HF-style BART fine-tuning code into HanLP's AMR component; version upgrades from when the alias was the public name.","solutions":["Replace the base class with BartPretrainedModel","If the subclasser is third-party code you can't change, filter FutureWarning for this message","Pin/upgrade to a HanLP version consistent with your vendored modeling file"],"exampleFix":"# before\nclass MyBart(PretrainedBartModel): ...\n# after\nclass MyBart(BartPretrainedModel): ...","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"import warnings\nwith warnings.catch_warnings():\n    warnings.filterwarnings('ignore', category=FutureWarning, message='.*PretrainedBartModel.*')\n    import my_old_bart_module  # subclasses the alias","preventionTips":["Subclass BartPretrainedModel in new code","Pin compatible library versions when vendoring old modeling files"],"tags":["deprecation","transformers","bart"],"backgroundTag":"deprecated-class-usage","analyzedSha":"ddb1299bddff079e447af52ec12549c50636bfa8","analyzedAt":"2026-08-27T03:36:54.287Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}