Repository navigation
fix(jailbreak): load the Snowflake embedding model without remote code - #2441
Open
ninadphalak wants to merge 1 commit into
Open
ninadphalak wants to merge 1 commit into
ninadphalak wants to merge 1 commit into
Conversation
The Snowflake repository's remote code looks for pytorch_model.bin (the repository ships only safetensors) and its forward pass relies on helpers removed in transformers 5, so with the pinned transformers>=5.3 the in-process jailbreak detection model rail could not load its embedding model and every request through it ended in an internal error. The architecture is native to transformers (NomicBert); loading without remote code uses the same weights and gives the same embedding. Closes NVIDIA-NeMo#2439 Signed-off-by: Ninad Phalak <ninadphalak@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #2439.
SnowflakeEmbedloadedSnowflake/snowflake-arctic-embed-m-longwithtrust_remote_code=True. The repository's remote code looks forpytorch_model.bin(the repository ships onlymodel.safetensors; theuse_safetensors=Truewe pass is not the kwarg it reads), and when the weights are made available its forward pass fails on transformers 5 ('NomicBertModel' object has no attribute 'get_extended_attention_mask').library/jailbreak_detection/requirements.txtpinstransformers>=5.3.0, so the documented in-process setup for thejailbreak detection modelrail could not load the embedding model and every request through the rail ended in an internal error.The architecture is native to transformers (
NomicBert), so the tokenizer and model are now loaded without remote code. Everything else is unchanged (add_pooling_layer=False,use_safetensors=True, the CLS embedding).Verified in a clean
python:3.12-slimcontainer with torch 2.14.1 (CPU) and transformers 5.19.0:trust_remote_code=True(before)OSError: Model name Snowflake/snowflake-arctic-embed-m-long was not found.use_safetensors=TrueNomicBertModel, embedding shape (1, 768), 29 s including downloadadd_pooling_layer=False, use_safetensors=True(this PR)A side effect operators will notice: no
trust_remote_codeprompt or remote code execution when the rail starts.Test plan
tests/test_jailbreak_model_based.py::test_snowflake_embed_loads_without_remote_code: asserts neitherAutoTokenizer.from_pretrainednorAutoModel.from_pretrainedis asked for remote code and thatuse_safetensors=Trueis kept. Fails on the previous loader, passes now.pytest tests/test_jailbreak_model_based.py: 18 passed.ruff checkandruff format --checkclean on both files.