{"record":{"id":"3cb81549a6338501","repo":"hankcs/HanLP","slug":"the-identifier-save-dir-resolves-to-a-nonexisten","errorCode":null,"errorMessage":"The identifier {save_dir} resolves to a nonexistent meta file {metapath}. {tips}","messagePattern":"The identifier (.+?) resolves to a nonexistent meta file (.+?)\\. (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"hanlp/utils/component_util.py","lineNumber":76,"sourceCode":"                       'embed': {'classpath': 'hanlp.layers.embeddings.word2vec.Word2VecEmbedding',\n                                 'embed': identifier, 'field': 'token', 'normalize': 'l2'},\n                       'hanlp_version': version.__version__}, metapath)\n        elif identifier in pretrained.fasttext.ALL.values():\n            save_dir = os.path.dirname(save_dir)\n            metapath = os.path.join(save_dir, 'config.json')\n            save_json({'classpath': 'hanlp.layers.embeddings.fast_text.FastTextEmbeddingComponent',\n                       'embed': {'classpath': 'hanlp.layers.embeddings.fast_text.FastTextEmbedding',\n                                 'filepath': identifier, 'src': 'token'},\n                       'hanlp_version': version.__version__}, metapath)\n        elif identifier in {pretrained.classifiers.LID_176_FASTTEXT_SMALL,\n                            pretrained.classifiers.LID_176_FASTTEXT_BASE}:\n            save_dir = os.path.dirname(save_dir)\n            metapath = os.path.join(save_dir, 'config.json')\n            save_json({'classpath': 'hanlp.components.classifiers.fasttext_classifier.FastTextClassifier',\n                       'model_path': identifier,\n                       'hanlp_version': version.__version__}, metapath)\n        else:\n            raise FileNotFoundError(f'The identifier {save_dir} resolves to a nonexistent meta file {metapath}. {tips}')\n    meta: dict = load_json(metapath)\n    cls = meta.get('classpath', cls)\n    if not cls:\n        cls = meta.get('class_path', None)  # For older version\n    if tf_model:\n        # tf models are trained with version < 2.1. To migrate them to 2.1, map their classpath to new locations\n        upgrade = {\n            'hanlp.components.tok_tf.TransformerTokenizerTF': 'hanlp.components.tokenizers.tok_tf.TransformerTokenizerTF',\n            'hanlp.components.pos.RNNPartOfSpeechTagger': 'hanlp.components.taggers.pos_tf.RNNPartOfSpeechTaggerTF',\n            'hanlp.components.pos_tf.RNNPartOfSpeechTaggerTF': 'hanlp.components.taggers.pos_tf.RNNPartOfSpeechTaggerTF',\n            'hanlp.components.pos_tf.CNNPartOfSpeechTaggerTF': 'hanlp.components.taggers.pos_tf.CNNPartOfSpeechTaggerTF',\n            'hanlp.components.ner_tf.TransformerNamedEntityRecognizerTF': 'hanlp.components.ner.ner_tf.TransformerNamedEntityRecognizerTF',\n            'hanlp.components.parsers.biaffine_parser.BiaffineDependencyParser': 'hanlp.components.parsers.biaffine_parser_tf.BiaffineDependencyParserTF',\n            'hanlp.components.parsers.biaffine_parser.BiaffineSemanticDependencyParser': 'hanlp.components.parsers.biaffine_parser_tf.BiaffineSemanticDependencyParserTF',\n            'hanlp.components.tok_tf.NgramConvTokenizerTF': 'hanlp.components.tokenizers.tok_tf.NgramConvTokenizerTF',\n            'hanlp.components.classifiers.transformer_classifier.TransformerClassifier': 'hanlp.components.classifiers.transformer_classifier_tf.TransformerClassifierTF',\n            'hanlp.components.taggers.transformers.transformer_tagger.TransformerTagger': 'hanlp.components.taggers.transformers.transformer_tagger_tf.TransformerTaggerTF',\n            'hanlp.components.tok.NgramConvTokenizer': 'hanlp.components.tokenizers.tok_tf.NgramConvTokenizerTF',","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/utils/component_util.py#L58-L94","documentation":"HanLP resolves a model identifier to a save directory containing config.json. If the path exists but no meta file (config.json) is found there — and the identifier is not a fasttext-style model — load_from_meta_file raises FileNotFoundError with the resolved path and a hint.","triggerScenarios":"Calling hanlp.load(...) / load_from_meta_file with a close-to-correct identifier whose directory exists but lacks config.json: e.g. omitting a trailing path segment, pointing at a cache dir, or a partially downloaded model.","commonSituations":"Typos in the model id (e.g. missing the task subfolder); interrupted first download leaving an incomplete directory; moving/renaming model folders so config.json is no longer beside the weights; older models whose meta uses different layout.","solutions":["Check the spelled-out metapath in the message — usually the identifier is off by one path segment; correct it against the model list in HanLP docs.","If the model was partially downloaded, delete the incomplete folder under the HanLP cache and retry the load to re-download.","If you relocated the model, ensure config.json sits next to the model file inside save_dir (or create one with classpath and model_path keys)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import os\nmeta = os.path.join(save_dir, 'config.json')\nassert os.path.isfile(meta), f'{meta} missing; check model id'","typeGuard":null,"tryCatchPattern":"try:\n    comp = hanlp.load(identifier)\nexcept FileNotFoundError as e:\n    # clean cache and retry once with corrected id\n    raise","preventionTips":["Keep model ids as constants copied from the official model table.","After downloads, verify config.json exists in the model dir."],"tags":["model-loading","file-not-found","hanlp"],"backgroundTag":"model-identifier-not-found","analyzedSha":"ddb1299bddff079e447af52ec12549c50636bfa8","analyzedAt":"2026-08-27T03:36:54.287Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}