{"record":{"id":"9371675af5f2f3ce","repo":"microsoft/qlib","slug":"unknown-base-model-name-s-937167","errorCode":null,"errorMessage":"unknown base model name `%s`","messagePattern":"unknown base model name `(.+?)`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/contrib/model/pytorch_hist.py","lineNumber":285,"sourceCode":"\n        x_train, y_train, stock_index_train = df_train[\"feature\"], df_train[\"label\"], df_train[\"stock_index\"]\n        x_valid, y_valid, stock_index_valid = df_valid[\"feature\"], df_valid[\"label\"], df_valid[\"stock_index\"]\n\n        save_path = get_or_create_path(save_path)\n\n        stop_steps = 0\n        best_score = -np.inf\n        best_epoch = 0\n        evals_result[\"train\"] = []\n        evals_result[\"valid\"] = []\n\n        # load pretrained base_model\n        if self.base_model == \"LSTM\":\n            pretrained_model = LSTMModel()\n        elif self.base_model == \"GRU\":\n            pretrained_model = GRUModel()\n        else:\n            raise ValueError(\"unknown base model name `%s`\" % self.base_model)\n\n        if self.model_path is not None:\n            self.logger.info(\"Loading pretrained model...\")\n            pretrained_model.load_state_dict(torch.load(self.model_path))\n\n        model_dict = self.HIST_model.state_dict()\n        pretrained_dict = {\n            k: v for k, v in pretrained_model.state_dict().items() if k in model_dict  # pylint: disable=E1135\n        }\n        model_dict.update(pretrained_dict)\n        self.HIST_model.load_state_dict(model_dict)\n        self.logger.info(\"Loading pretrained model Done...\")\n\n        # train\n        self.logger.info(\"training...\")\n        self.fitted = True\n\n        for step in range(self.n_epochs):","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/contrib/model/pytorch_hist.py#L267-L303","documentation":"HISTModel.fit only knows how to build a pretrained base model for two names: 'LSTM' (LSTMModel) and 'GRU' (GRUModel). Any other value of self.base_model raises this ValueError before training starts, because the pretrained-weight transfer into the HIST graph requires one of those two architectures.","triggerScenarios":"Constructing HISTModel(d_model=..., base_model='Transformer') or any string other than 'LSTM'/'GRU' (including lowercase 'lstm', 'gru', or None) and then calling fit().","commonSituations":"Copying a config from another qlib model (e.g. pytorch_transformer or ADD) whose model_type is Transformer/ALSTM and passing it to HIST unchanged; case mismatch ('gru' vs 'GRU'); typo in the workflow YAML task.model.class argument.","solutions":["Set base_model to exactly 'GRU' or 'LSTM' (case-sensitive) when constructing HISTModel","If you configured via workflow YAML, check task -> model -> kwargs -> base_model","If you need a different base architecture, subclass HISTModel and extend the if/elif chain in fit with your model class"],"exampleFix":"# before\nmodel = HISTModel(base_model=\"Transformer\")\n\n# after\nmodel = HISTModel(base_model=\"GRU\")","handlingStrategy":"validation","validationCode":"assert model.base_model in (\"LSTM\", \"GRU\"), f\"base_model must be LSTM or GRU, got {model.base_model!r}\"","typeGuard":"def is_valid_hist_base_model(name: str) -> bool:\n    return name in (\"LSTM\", \"GRU\")","tryCatchPattern":"try:\n    model.fit(dataset)\nexcept ValueError as e:\n    if \"unknown base model\" in str(e):\n        model.base_model = \"GRU\"  # or fail config validation earlier\n    else:\n        raise","preventionTips":["Validate base_model against the model's supported set when parsing config","Keep per-model config files rather than one shared hyperparameter block"],"tags":["qlib","hist","invalid-argument","config"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}