`trust_remote_code=True` is hard-coded in the Hugging Face and vLLM wrappers and cannot be turned off
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 50/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- huggingface, python
- Lĩnh vực
- machine-learning, security
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 2.3k
- Fork
- 249
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của InternLM/lagent
-
OpenAI shuts down gpt-3.5-turbo and gpt-4o-2024-05-13 on 2026-10-23: default model_type values need updatingCó thể đã có người làm @qiyuhuating đã nhận 53 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Tất cả issue của InternLM/lagent
Issue tương tự
-
accepted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
future-agi/future-agi#5908 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Placeholder export disables HTML image input for picture descriptionCó thể đã có người làm @cloudiful đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
docling-project/docling-serve#817 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
Techiebutler/freeframe#687 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Parse truncated verbose GC logs up to the first XML errorCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug verbose GC
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
IBM/javacore-analyser#677 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
Maintainer thường phản hồi trong vòng 2 ngày