{"record":{"id":"a4ce340266251748","repo":"binary-husky/gpt_academic","slug":"self-model-name","errorCode":null,"errorMessage":"不能正常加载{self.model_name}的参数！","messagePattern":"不能正常加载(.+?)的参数！","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"request_llms/local_llm_class.py","lineNumber":152,"sourceCode":"\n    def run(self):\n        # 🏃‍♂️🏃‍♂️🏃‍♂️ run in child process\n        # 第一次运行，加载参数\n        self.child.flush = lambda *args: None\n        self.child.write = lambda x: self.child.send(self.std_tag + x)\n        reset_tqdm_output()\n        self.set_state(\"`尝试加载模型`\")\n        try:\n            with redirect_stdout(self.child):\n                self._model, self._tokenizer = self.load_model_and_tokenizer()\n        except:\n            self.set_state(\"`加载模型失败`\")\n            self.running = False\n            from toolbox import trimmed_format_exc\n            self.child.send(\n                f'[Local Message] 不能正常加载{self.model_name}的参数.' + '\\n```\\n' + trimmed_format_exc() + '\\n```\\n')\n            self.child.send('[FinishBad]')\n            raise RuntimeError(f\"不能正常加载{self.model_name}的参数！\")\n\n        self.set_state(\"`准备就绪`\")\n        while True:\n            # 进入任务等待状态\n            kwargs = self.child.recv()\n            # 收到消息，开始请求\n            try:\n                for response_full in self.llm_stream_generator(**kwargs):\n                    self.child.send(response_full)\n                    # print('debug' + response_full)\n                self.child.send('[Finish]')\n                # 请求处理结束，开始下一个循环\n            except:\n                from toolbox import trimmed_format_exc\n                self.child.send(\n                    f'[Local Message] 调用{self.model_name}失败.' + '\\n```\\n' + trimmed_format_exc() + '\\n```\\n')\n                self.child.send('[Finish]')\n","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/request_llms/local_llm_class.py#L134-L170","documentation":"In the local-LLM loader subprocess, any exception while calling load_model_and_tokenizer (model download, transformers/vllm init, out-of-memory) is caught, reported to the parent process via self.child.send with a trimmed traceback, and then re-raised as RuntimeError('不能正常加载{model}的参数！'). The generic raise masks the original cause, so the child message with the real traceback is the useful artifact.","triggerScenarios":"Instantiating a local model singleton (e.g. qwen/local model via get_local_llm_predict_fns) when model weights cannot be downloaded or loaded: bad model path in config, transformers version mismatch, CUDA OOM, no network to HuggingFace, or wrong trust_remote_code settings.","commonSituations":"First run of a local model with insufficient VRAM/RAM; model_name_or_path pointing to a nonexistent local directory; corporate proxy blocking HF downloads; recent transformers release dropping support for a legacy model class.","solutions":["Check the chatbot/child-process message: it embeds trimmed_format_exc() with the original traceback — read it to find the true cause.","Verify the local model path in config.py exists and contains config.json/weights; fix the path or re-download.","Free GPU memory (close other processes, pick a smaller quantization) if the underlying error is CUDA OOM.","Pin/downgrade transformers (and related libs) to versions the model card requires."],"exampleFix":"# before\nexcept:\n    ...\n    raise RuntimeError(f\"不能正常加载{self.model_name}的参数！\")\n\n# after: chain the original exception\nexcept Exception:\n    self.set_state(\"`加载模型失败`\")\n    self.running = False\n    from toolbox import trimmed_format_exc\n    self.child.send(f'[Local Message] 不能正常加载{self.model_name}的参数.' + '\\n```\\n' + trimmed_format_exc() + '\\n```\\n')\n    self.child.send('[FinishBad]')\n    raise RuntimeError(f\"不能正常加载{self.model_name}的参数！\") from e","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    handle = spawn_local_model(...)\nexcept RuntimeError as e:\n    # the child message piped into chatbot contains the real traceback\n    if '不能正常加载' in str(e):\n        show_loader_traceback(); suggest_memory_or_path_fix()","preventionTips":["Pre-download and verify model weights before starting the server.","Check GPU/RAM headroom against the model card before selecting a local model.","Pin transformers/torch versions known to work with the model."],"tags":["local-llm","model-loading","subprocess","cuda","transformers"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}