Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suffix Activation Storing #5

Open
chuyishang opened this issue Jan 3, 2025 · 1 comment
Open

Suffix Activation Storing #5

chuyishang opened this issue Jan 3, 2025 · 1 comment

Comments

@chuyishang
Copy link

When taking the suffix activations, in steering_vector.py, I noticed that the length of the tokenized suffix is calculated using suffixes[0][0], but the different suffixes in the list may be of different lengths. Wondering if this is intended behavior?

elif accumulate_last_x_tokens == "suffix-only":
    if suffixes:
        # Tokenize the suffix
        suffix_tokens = tokenizer.encode(suffixes[0][0], add_special_tokens=False)
        # Get the hidden states for the suffix tokens
        suffix_hidden = batch_hidden[-len(suffix_tokens):, :]
        accumulated_hidden_state = torch.mean(suffix_hidden, dim=0)

Thanks in advance!

@brucewlee
Copy link
Collaborator

Thanks for finding this! The code was implemented this way mostly because having a fixed length seemed more stable, and suffixes mostly had similar lengths for our setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants