text
How to alter the behavior of a Language Model without fine-tuning or prompting? Say hello to 🎤 yo-Llama 🦙! 
How to alter the behavior of a Language Model without fine-tuning or prompting? Say hello to 🎤 yo-Llama 🦙! 
new_line
new_line
text
Model 
Model 
resource
https://huggingface.co/anakin87/yo-Llama-3-8B-Instruct
model
anakin87/yo-Llama-3-8B-Instruct
https://huggingface.co/anakin87/yo-Llama-3-8B-Instruct
new_line
new_line
text
This experiment steers Llama-3-8B-Instruct to respond in a rap style.
This experiment steers Llama-3-8B-Instruct to respond in a rap style.
new_line
text
How? Amplifying the rap direction in the activation space. 😎
How? Amplifying the rap direction in the activation space. 😎
new_line
new_line
new_line
text
𝐖𝐡𝐚𝐭 𝐬𝐩𝐚𝐫𝐤𝐞𝐝 𝐭𝐡𝐢𝐬 𝐢𝐝𝐞𝐚?
𝐖𝐡𝐚𝐭 𝐬𝐩𝐚𝐫𝐤𝐞𝐝 𝐭𝐡𝐢𝐬 𝐢𝐝𝐞𝐚?
new_line
new_line
text
Lately, I got interested in mechanistic interpretability of LLMs.
Lately, I got interested in mechanistic interpretability of LLMs.
new_line
new_line
text
💡 A recent paper, "Refusal in Language Models Is Mediated by a Single Direction," showed how to find the refusal direction in the activation space of Chat Language Models and either erase or amplify it.
💡 A recent paper, "Refusal in Language Models Is Mediated by a Single Direction," showed how to find the refusal direction in the activation space of Chat Language Models and either erase or amplify it.
new_line
text
A clever jailbreak method for open weights models.
A clever jailbreak method for open weights models.
new_line
new_line
text
Then, 
Then, 
mention
@failspy
failspy
text
 took it a step further by modifying the models to amplify different traits, such as making a model seem grumpy or irritable.
 took it a step further by modifying the models to amplify different traits, such as making a model seem grumpy or irritable.
new_line
new_line
new_line
text
𝐇𝐨𝐰 𝐝𝐢𝐝 𝐈 𝐜𝐫𝐞𝐚𝐭𝐞 𝐲𝐨-𝐋𝐥𝐚𝐦𝐚?
𝐇𝐨𝐰 𝐝𝐢𝐝 𝐈 𝐜𝐫𝐞𝐚𝐭𝐞 𝐲𝐨-𝐋𝐥𝐚𝐦𝐚?
new_line
text
(📓 notebook in the HF repository, heavily inspired by Failspy's work)
(📓 notebook in the HF repository, heavily inspired by Failspy's work)
new_line
new_line
text
1️⃣ Load the Llama-3-8B-Instruct model.
1️⃣ Load the Llama-3-8B-Instruct model.
new_line
text
2️⃣ Load 1024 examples from Alpaca (instruction dataset).
2️⃣ Load 1024 examples from Alpaca (instruction dataset).
new_line
text
3️⃣ Prepare a system prompt to make the original model act like a rapper.
3️⃣ Prepare a system prompt to make the original model act like a rapper.
new_line
text
4️⃣ Run inference on the examples, with and without the system prompt, and cache the activations.
4️⃣ Run inference on the examples, with and without the system prompt, and cache the activations.
new_line
text
5️⃣ Compute the rap feature directions (one for each layer) from the activations.
5️⃣ Compute the rap feature directions (one for each layer) from the activations.
new_line
text
6️⃣ Apply the feature directions one by one, checking the results on some examples.
6️⃣ Apply the feature directions one by one, checking the results on some examples.
new_line
text
7️⃣ Pick the best-performing feature direction.
7️⃣ Pick the best-performing feature direction.
new_line
text
8️⃣ Apply this feature direction and voilà!
8️⃣ Apply this feature direction and voilà!
new_line
text
yo-Llama-3-8B-Instruct is born! 🥳🎶
yo-Llama-3-8B-Instruct is born! 🥳🎶
new_line
new_line
text
This was a fun experiment. 
This was a fun experiment. 
new_line
new_line
new_line
text
📚 Resources
📚 Resources
new_line
new_line
text
Refusal in Language Models Is Mediated by a Single Direction - 
Refusal in Language Models Is Mediated by a Single Direction - 
link
https://arxiv.org/abs/2406.11717
https://arxiv.org/abs/2406.11717
new_line
new_line
text
Uncensor any LLM with abliteration: great practical blog post by 
Uncensor any LLM with abliteration: great practical blog post by 
mention
@mlabonne
mlabonne
text
link
https://huggingface.co/blog/mlabonne/abliteration
https://huggingface.co/blog/mlabonne/abliteration
new_line
new_line
text
Practical materials by 
Practical materials by 
mention
@failspy
failspy
text
new_line
text
- abliterator library 
- abliterator library 
link
https://github.com/FailSpy/abliterator
https://github.com/FailSpy/abliterator
new_line
text
- Llama-MopeyMule-3-8B-Instruct model (+ notebook) 
- Llama-MopeyMule-3-8B-Instruct model (+ notebook) 
resource
https://huggingface.co/failspy/Llama-3-8B-Instruct-MopeyMule
model
failspy/Llama-3-8B-Instruct-MopeyMule
https://huggingface.co/failspy/Llama-3-8B-Instruct-MopeyMule
How to alter the behavior of a Language Model without fine-tuning or prompting? Say hello to 🎤 yo-Llama 🦙! 

Model https://huggingface.co/anakin87/yo-Llama-3-8B-Instruct

This experiment steers Llama-3-8B-Instruct to respond in a rap style.
How? Amplifying the rap direction in the activation space. 😎


𝐖𝐡𝐚𝐭 𝐬𝐩𝐚𝐫𝐤𝐞𝐝 𝐭𝐡𝐢𝐬 𝐢𝐝𝐞𝐚?

Lately, I got interested in mechanistic interpretability of LLMs.

💡 A recent paper, "Refusal in Language Models Is Mediated by a Single Direction," showed how to find the refusal direction in the activation space of Chat Language Models and either erase or amplify it.
A clever jailbreak method for open weights models.

Then, @failspy took it a step further by modifying the models to amplify different traits, such as making a model seem grumpy or irritable.


𝐇𝐨𝐰 𝐝𝐢𝐝 𝐈 𝐜𝐫𝐞𝐚𝐭𝐞 𝐲𝐨-𝐋𝐥𝐚𝐦𝐚?
(📓 notebook in the HF repository, heavily inspired by Failspy's work)

1️⃣ Load the Llama-3-8B-Instruct model.
2️⃣ Load 1024 examples from Alpaca (instruction dataset).
3️⃣ Prepare a system prompt to make the original model act like a rapper.
4️⃣ Run inference on the examples, with and without the system prompt, and cache the activations.
5️⃣ Compute the rap feature directions (one for each layer) from the activations.
6️⃣ Apply the feature directions one by one, checking the results on some examples.
7️⃣ Pick the best-performing feature direction.
8️⃣ Apply this feature direction and voilà!
yo-Llama-3-8B-Instruct is born! 🥳🎶

This was a fun experiment. 


📚 Resources

Refusal in Language Models Is Mediated by a Single Direction - https://arxiv.org/abs/2406.11717

Uncensor any LLM with abliteration: great practical blog post by @mlabonne  https://huggingface.co/blog/mlabonne/abliteration

Practical materials by @failspy 
- abliterator library https://github.com/FailSpy/abliterator
- Llama-MopeyMule-3-8B-Instruct model (+ notebook) https://huggingface.co/failspy/Llama-3-8B-Instruct-MopeyMule
❤️
mlabonne diwank YaTharThShaRma999 Korakoe