Downloads · 30 days
98
10% of all-time downloads
drwlf/medgemma-4b-it-abliterated
medgemma-4b-it-abliterated is a text generation model from drwlf. Use it when you need the model to write or continue text. The card lists the license as apache-2.0.
This model is a fine-tuned version of google/medgemma-4b-it that has undergone an "abliteration" process to reduce its propensity to generate harmful or undesirable content, followed by instruction fine-tuning on a cu…
Downloads · 30 days
98
10% of all-time downloads
All-time downloads
983
Public
Parameters
5B
24.1 GB on disk
Likes
6
Public
Click a slice to open those files.
.safetensors6.3 GB · 99%
How the weights are stored.
I83.6B · 73%
From the Hugging Face model README
This model is a fine-tuned version of google/medgemma-4b-it that has undergone an "abliteration" process to reduce its propensity to generate harmful or undesirable content, followed by instruction fine-tuning on a custom dataset using Axolotl.
The abliteration process aimed to instill a specific behavior (e.g., refusal of harmful requests) by identifying and orthogonalizing a "refusal direction" in the model's weights. This was followed by LoRA (Low-Rank Adaptation) fine-tuning to adapt the model to a new dataset while preserving the benefits of abliteration and the base model's capabilities.
Base Model: google/medgemma-4b-it
Abliteration Target Dataset: mlabonne/harmful_behaviours **Abliteration Baseline Dataset:** mlabonne/harmless_alpaca`
Fine-tuning Framework: Axolotl
This model is intended for true uncensored medical use
The model is designed to follow instructions and provide informative responses within its trained domain, with an increased resistance to generating outputs related to the abliterated behaviors.
This model can be used with the Hugging Face transformers library. If LoRA adapters were trained, they need to be loaded on top of the abliterated base model.
from transformers import AutoModelForCausalLM, AutoTokenizer
# from peft import PeftModel # If using LoRA adapters
import torch
base_model_path = "[Path to your abliterated MedGemma 4B model, e.g., 'your_username/medgemma-4b-abliterated']"
# If you merged LoRA adapters into the base model and saved it as a new model:
# finetuned_model_path = "[Path to your final merged and fine-tuned model, e.g., 'your_username/medgemma-4b-abliterated-finetuned']"
# model = AutoModelForCausalLM.from_pretrained(finetuned_model_path, trust_remote_code=True, torch_dtype=torch.bfloat16, device_map="auto")
# tokenizer = AutoTokenizer.from_pretrained(finetuned_model_path, trust_remote_code=True)
# If you are loading LoRA adapters separately:
# model = AutoModelForCausalLM.from_pretrained(base_model_path, trust_remote_code=True, torch_dtype=torch.bfloat16, device_map="auto")
# adapter_path = "[Path to your trained LoRA adapters, e.g., '/content/drive/MyDrive/AI Work/axolotl_finetune_4b_output_run1/final_checkpoint_or_adapter_folder']"
# model = PeftModel.from_pretrained(model, adapter_path)
# model = model.merge_and_unload() # Optional: merge for faster inference
# tokenizer = AutoTokenizer.from_pretrained(base_model_path, trust_remote_code=True)
# Example usage:
prompt_template = """USER: {instruction}
ASSISTANT:"""
instruction = "What are the common symptoms of influenza?"
full_prompt = prompt_template.format(instruction=instruction)
inputs = tokenizer(full_prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=200, do_sample=True, temperature=0.7, top_p=0.9)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))