`trust_remote_code=True` is hard-coded in the Hugging Face and vLLM wrappers and cannot be turned off
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 50/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- huggingface, python
- Ambito
- machine-learning, security
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 2.3k
- Fork
- 249
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di InternLM/lagent
-
OpenAI shuts down gpt-3.5-turbo and gpt-4o-2024-05-13 on 2026-10-23: default model_type values need updatingForse già presa @qiyuhuating l’ha presa 53 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Tutte le issue di InternLM/lagent
Issue simili
-
accepted
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
future-agi/future-agi#5908 ·
I maintainer di solito rispondono entro 1 giorno
-
Placeholder export disables HTML image input for picture descriptionForse già presa @cloudiful l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
docling-project/docling-serve#817 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
Techiebutler/freeframe#687 ·
I maintainer di solito rispondono entro 1 giorno
-
Parse truncated verbose GC logs up to the first XML errorForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug verbose GC
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
IBM/javacore-analyser#677 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 2 giorni