`trust_remote_code=True` is hard-coded in the Hugging Face and vLLM wrappers and cannot be turned off
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 50/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- huggingface, python
調査の方向性
The hard-coded trust_remote_code=True sits in lagent/llms/huggingface.py (tokenizer and model from_pretrained calls), lagent/llms/vllm_wrapper.py (LLM(...) and AsyncEngineArgs(...)), and lagent/actions/web_visitor.py (tokenizer load). Start by reading how model_kwargs and tokenizer_kwargs are merged into those calls, since that is where the duplicate-keyword TypeError comes from. Done means both parameters are exposed on the four classes and forwarded to every call, and the default stays True. The design of the parameter names and defaults should be confirmed with maintainers first.
索引モデルが issue の本文から書いたものです。
説明
The local model wrappers always pass trust_remote_code=True, with no way for the caller to disable it and no way to pin a Hub revision:
- lagent/llms/huggingface.py#L77-L80:
AutoTokenizer.from_pretrained(..., trust_remote_code=True, **tokenizer_kwargs) - lagent/llms/huggingface.py#L107-L108 and #L299-L300:
AutoModel/AutoModelForCausalLM.from_pretrained(path, trust_remote_code=True, **model_kwargs) - lagent/llms/vllm_wrapper.py#L38-L42
LLM(model=self.path, trust_remote_code=True, ...), and #L110-L114:AsyncEngineArgs(model=self.path, trust_remote_code=True, ...) - lagent/actions/web_visitor.py#L114-L116:
AutoTokenizer.from_pretrained(tokenizer_path, trust_remote_code=True)
Why it matters
- With
trust_remote_code=True, Transformers and vLLM import and run the Python files shipped in the model repo. Because norevisionis pinned, that code is whatever the Hub repo's default branch holds at load time, so an update or a compromised upstream repo runs new code in the agent process. - Callers cannot opt out: passing
trust_remote_code=Falseinmodel_kwargs/tokenizer_kwargsraisesTypeError: got multiple values for keyword argument 'trust_remote_code'. That makes the wrappers unusable in setups that require it to be off, even for models that do not need custom code.
I understand trust_remote_code was added on purpose (#49, #50) so that InternLM and Qwen checkpoints load out of the box, so this is not a request to remove it.
Suggested fix
- Add
trust_remote_code: bool = True(keeping today's default) andrevision: Optional[str] = Noneparameters toHFTransformer,VllmModel,AsyncVllmModelandWebVisitor, and forward both to everyfrom_pretrained/LLM(...)call instead of the hard-coded keyword. - Document that a commit hash for
revisionis recommended whenevertrust_remote_codeis on.
Found with lacan-scan v7.6.4 (rule AIS203), checked by hand.
- 主要言語
- Python
- スター
- 2.3k
- フォーク
- 249
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
InternLM/lagent のほかの issue
-
OpenAI shuts down gpt-3.5-turbo and gpt-4o-2024-05-13 on 2026-10-23: default model_type values need updating対応中かも @qiyuhuating が 53 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
InternLM/lagent の issue をすべて見る
似ている issue
-
accepted
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
future-agi/future-agi#5908 ·
メンテナーはふだん 1 日以内に返信
-
Placeholder export disables HTML image input for picture description対応中かも @cloudiful が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
docling-project/docling-serve#817 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
Techiebutler/freeframe#687 ·
メンテナーはふだん 1 日以内に返信
-
Parse truncated verbose GC logs up to the first XML error対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug verbose GC
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
IBM/javacore-analyser#677 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 2 日以内に返信