Downloads · 30 days
5
10% of all-time downloads
Chandrudp29/gpt2-lora-aisafety
gpt2-lora-aisafety is a text generation model from Chandrudp29. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as mit.
GPT-2 fine-tuned with LoRA (Low-Rank Adaptation) on AI safety concepts including alignment, interpretability, corrigibility, and governance.
Downloads · 30 days
5
10% of all-time downloads
All-time downloads
49
Public
Repo size
3.3 MB
Likes
0
Public
Click a slice to open those files.
.json3.6 MB · 52%
From the Hugging Face model README
GPT-2 fine-tuned with LoRA (Low-Rank Adaptation) on AI safety concepts including alignment, interpretability, corrigibility, and governance.
Only 0.65% of parameters were trained (811K of 125M). The adapter is 3.25 MB — load it on top of any GPT-2 in seconds.
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
tokenizer = AutoTokenizer.from_pretrained("Chandrudp29/gpt2-lora-aisafety")
base_model = AutoModelForCausalLM.from_pretrained("gpt2")
model = PeftModel.from_pretrained(base_model, "Chandrudp29/gpt2-lora-aisafety")
model.eval()
prompt = "AI alignment is the challenge of"
inputs = tokenizer(prompt, return_tensors="pt")
with torch.no_grad():
output = model.generate(
**inputs,
max_new_tokens=80,
temperature=0.7,
do_sample=True,
top_k=50,
repetition_penalty=1.2,
pad_token_id=tokenizer.eos_token_id,
)
print(tokenizer.decode(output[0], skip_special_tokens=True))
| Base model | gpt2 (117M params) |
| Adapter type | LoRA |
| LoRA rank | r=8 |
| lora_alpha | 16 |
| target_modules | c_attn, c_proj |
| Trainable params | 811,008 (0.65%) |
| Training examples | 30 AI safety texts |
| Epochs | 20 |
| Learning rate | 2e-4 |
| Hardware | NVIDIA T4 (16GB) |
| Training time | 18 seconds |
| Adapter size | 3.25 MB |
The model was fine-tuned on short texts covering:
AI alignment is the challenge of...
Mechanistic interpretability seeks to...
Constitutional AI is a method for...
Corrigibility refers to an AI system that...
The risks of advanced AI include...
Training code: chandrudp29/lora-finetune
LoRA freezes pre-trained model weights and injects trainable low-rank matrices into each transformer layer. Instead of training all 125M parameters, only the two small adapter matrices (A × B where rank=8) are updated — reducing trainable parameters by 99.35%.