Undi95 / Phi4-abliterated

huggingface.co
Total runs: 68
24-hour runs: 0
7-day runs: 11
30-day runs: 31
Model's Last Updated: January 10 2025

Introduction of Phi4-abliterated

Model Details of Phi4-abliterated

Phi4 Abliteration (WIP)

This is Phi4 abliterated using a new methodology (surprisingly?). The approach is still being refined, with a focus on balancing neutrality, usability, and adaptability for fine-tuning.

Goal

The objective is to create a model that is neutral :

  • Not uncensored , but avoids refusing neutral prompts it would ordinarily reject.
  • Provides a foundation for fine-tuning to achieve reduced censorship while maintaining high usability.
Original Methodology

In the original implementation:

  1. Harmful and harmless prompts were compared on one specific layer of the model.
  2. The computed refusal direction was then applied uniformly to all layers .
Problem:

This resulted in:

  • A model that became less usable and less intelligent than the original.
  • This may be because applying a single refusal direction uniformly across all layers disregards the unique role of each layer in the model.
New Approach

In my fork, available here:
👉 https://github.com/Undi95/abliteration/
(based on the original https://github.com/Orion-zhen/abliteration.git )

I introduced a new approach:

  • Each layer computes its own refusal direction.
  • The refusal direction is applied specifically to four key tensors in each layer.
Four Key Tensors Used (for Phi):

For each layer, if a refusal direction exists ( layer_idx in refusal_dirs ), it is applied as follows:

if layer_idx in refusal_dirs:
    refusal_dir = refusal_dirs[layer_idx]
    lm_model.layers[layer_idx].self_attn.o_proj.weight = modify_tensor(
        lm_model.layers[layer_idx].self_attn.o_proj.weight.data,
        refusal_dir,
        scale_factor,
    )
    lm_model.layers[layer_idx].mlp.down_proj.weight = modify_tensor(
        lm_model.layers[layer_idx].mlp.down_proj.weight.data,
        refusal_dir,
        scale_factor,
    )
    lm_model.layers[layer_idx].post_attention_layernorm.weight = modify_tensor(
        lm_model.layers[layer_idx].post_attention_layernorm.weight.data,
        refusal_dir,
        scale_factor,
    )
    lm_model.layers[layer_idx].input_layernorm.weight = modify_tensor(
        lm_model.layers[layer_idx].input_layernorm.weight.data,
        refusal_dir,
        scale_factor,
    )
Why This Change?

By applying refusal directions individually to each layer's tensors:

  • The model can retain more specificity and functionality .
  • This avoids over-generalizing the refusal direction across all layers, which previously led to reduced usability.
Trade-offs:

The more we force refusal directions onto the model:

  • The more neutral it becomes, but at the risk of becoming dumber .
  • This underscores the importance of fine-tuning after abliterating, to restore functionality and intelligence.
  • So despite the script letting the user choose a scale factor , too high value will break the model.
Next Steps

The abliterated model serves as a neutral starting point . Fine-tuning is essential to:

  • Adjust the model to reduce over-censoring.
  • Maintain a balance between neutrality and usability.

This is a work in progress , Phi 4 is smoll so I can toy with it.

Replicate
  • Install my fork
  • Follow tutorial on github

Launch with enough VRAM : python abliterate.py -m /workspace/microsoft_phi-4 -o ./perfect --deccp --flash-attn --device auto --scan-all --resume --scale-factor 1

If you want to use the tensors available here, just put the refusal_tensors/ folder at the root of the script, you will then be able to use: python chat.py -m /workspace/microsoft_phi-4 then select layer range "1;39", and scale factor to 1.0.

Rename the tensors as needed. My code is shit, please understand, idea is better than code. Do better. kek.

Runs of Undi95 Phi4-abliterated on huggingface.co

68
Total runs
0
24-hour runs
5
3-day runs
11
7-day runs
31
30-day runs

More Information About Phi4-abliterated huggingface.co Model

Phi4-abliterated huggingface.co

Phi4-abliterated huggingface.co is an AI model on huggingface.co that provides Phi4-abliterated's model effect (), which can be used instantly with this Undi95 Phi4-abliterated model. huggingface.co supports a free trial of the Phi4-abliterated model, and also provides paid use of the Phi4-abliterated. Support call Phi4-abliterated model through api, including Node.js, Python, http.

Phi4-abliterated huggingface.co Url

https://huggingface.co/Undi95/Phi4-abliterated

Undi95 Phi4-abliterated online free

Phi4-abliterated huggingface.co is an online trial and call api platform, which integrates Phi4-abliterated's modeling effects, including api services, and provides a free online trial of Phi4-abliterated, you can try Phi4-abliterated online for free by clicking the link below.

Undi95 Phi4-abliterated online free url in huggingface.co:

https://huggingface.co/Undi95/Phi4-abliterated

Phi4-abliterated install

Phi4-abliterated is an open source model from GitHub that offers a free installation service, and any user can find Phi4-abliterated on GitHub to install. At the same time, huggingface.co provides the effect of Phi4-abliterated install, users can directly use Phi4-abliterated installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

Phi4-abliterated install url in huggingface.co:

https://huggingface.co/Undi95/Phi4-abliterated

Url of Phi4-abliterated

Phi4-abliterated huggingface.co Url

Provider of Phi4-abliterated huggingface.co

Undi95
ORGANIZATIONS

Other API from Undi95

huggingface.co

Total runs: 1.0K
Run Growth: 53
Growth Rate: 5.13%
Updated:November 18 2023
huggingface.co

Total runs: 941
Run Growth: 484
Growth Rate: 51.43%
Updated:November 05 2023
huggingface.co

Total runs: 870
Run Growth: 25
Growth Rate: 2.87%
Updated:November 05 2023
huggingface.co

Total runs: 869
Run Growth: 13
Growth Rate: 1.50%
Updated:November 05 2023
huggingface.co

Total runs: 861
Run Growth: -124
Growth Rate: -14.40%
Updated:October 26 2023
huggingface.co

Total runs: 832
Run Growth: -296
Growth Rate: -35.58%
Updated:November 18 2023
huggingface.co

Total runs: 805
Run Growth: 57
Growth Rate: 7.08%
Updated:November 18 2023
huggingface.co

Total runs: 800
Run Growth: -229
Growth Rate: -28.63%
Updated:November 18 2023
huggingface.co

Total runs: 729
Run Growth: -253
Growth Rate: -34.71%
Updated:November 18 2023
huggingface.co

Total runs: 235
Run Growth: 110
Growth Rate: 46.81%
Updated:April 04 2024
huggingface.co

Total runs: 134
Run Growth: -322
Growth Rate: -240.30%
Updated:November 18 2023
huggingface.co

Total runs: 122
Run Growth: -477
Growth Rate: -390.98%
Updated:November 18 2023
huggingface.co

Total runs: 119
Run Growth: -20
Growth Rate: -16.81%
Updated:April 04 2024
huggingface.co

Total runs: 83
Run Growth: -48
Growth Rate: -59.26%
Updated:November 18 2023
huggingface.co

Total runs: 82
Run Growth: -33
Growth Rate: -40.24%
Updated:December 12 2023
huggingface.co

Total runs: 76
Run Growth: -11
Growth Rate: -14.47%
Updated:March 29 2024
huggingface.co

Total runs: 68
Run Growth: -7
Growth Rate: -10.29%
Updated:November 09 2023
huggingface.co

Total runs: 68
Run Growth: -1
Growth Rate: -1.47%
Updated:November 18 2023
huggingface.co

Total runs: 67
Run Growth: -49
Growth Rate: -68.06%
Updated:November 18 2023
huggingface.co

Total runs: 61
Run Growth: -10
Growth Rate: -16.39%
Updated:November 18 2023
huggingface.co

Total runs: 59
Run Growth: -12
Growth Rate: -21.82%
Updated:November 18 2023