You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**model_name** (str): Name of the small language model from Huggingface, use "microsoft/llmlingua-2-xlm-roberta-large-meetingbank" or "microsoft/llmlingua-2-bert-base-multilingual-cased-meetingbank" for LLMLingua-2. Defaults to "NousResearch/Llama-2-7b-hf".
280
280
-**device_map** (str): The computing environment. Options include 'cuda', 'cpu', 'mps', 'balanced', 'balanced_low_0', 'auto'. Default is 'cuda'.
281
-
-**model_config** (dict, optional): Configuration for the Huggingface model. Defaults to {}.
281
+
-**model_config** (dict, optional): Configuration for the Huggingface model. Defaults to {}. Supports `trust_remote_code` (defaults to `False` for security; see [Security Considerations](#security-considerations)).
282
282
-**open_api_config** (dict, optional): Configuration for OpenAI Embedding in coarse-level prompt compression. Defaults to {}.
283
283
-**use_llmlingua2** (bool, optional): Whether to use llmlingua-2 for prompt compression. Defaults is False.
-**recovered_response** (str): The recovered response, integrating the original prompt's context.
420
+
421
+
## Security Considerations
422
+
423
+
### `trust_remote_code`
424
+
425
+
By default, LLMLingua sets `trust_remote_code=False` when loading models from the Hugging Face Hub. This prevents the automatic execution of arbitrary Python code shipped within a model repository, which could be exploited in a supply-chain attack.
426
+
427
+
If you are using a model that requires custom code (e.g., certain Jina embedding models), you can explicitly opt in by passing `trust_remote_code=True` in `model_config`:
428
+
429
+
```python
430
+
llm_lingua = PromptCompressor(
431
+
model_name="your-model-name",
432
+
model_config={"trust_remote_code": True},
433
+
)
434
+
```
435
+
436
+
> **⚠️ Warning:** Only enable `trust_remote_code` for models you trust. A compromised or malicious model repository could execute arbitrary code on your machine when this option is enabled.
437
+
438
+
### `torch.load` and `weights_only`
439
+
440
+
The experiment scripts under `experiments/llmlingua2/` use `torch.load` with `weights_only=True` to prevent arbitrary code execution via Python pickle deserialization. If you are loading your own `.pt` files in custom training or data pipelines, ensure you also use `weights_only=True` unless you fully trust the source of the file:
> **🔒 Security Note:**`trust_remote_code` now defaults to `False`. If your model requires custom remote code, opt in explicitly via `model_config={"trust_remote_code": True}`. See [Security Considerations](./DOCUMENT.md#security-considerations) for details.
186
+
185
187
To try **LongLLMLingua** in your scenarios, you can use
0 commit comments