security: remove trust_remote_code=True from model loading

Phi-2 uses the standard PhiForCausalLM architecture and does not require
custom code execution. trust_remote_code=True allows arbitrary Python
from the HuggingFace repo to run during loading, creating an unnecessary
supply-chain risk.
This commit is contained in:
kigland
2026-03-08 15:16:53 +08:00
parent 11a7d3408f
commit d50c6b5acf
+1 -2
View File
@@ -18,14 +18,13 @@ class CMAESTokenOptimizer:
self.pca_dims = pca_dims
print("[*] Loading surrogate model (microsoft/phi-2) for continuous embedding space... This may take a minute.")
self.tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-2", trust_remote_code=True)
self.tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-2")
self.tokenizer.pad_token = self.tokenizer.eos_token
self.model = AutoModelForCausalLM.from_pretrained(
"microsoft/phi-2",
device_map="auto",
torch_dtype=torch.float16,
trust_remote_code=True
)
self.d_model = self.model.config.hidden_size