CircuitKavach-Aya: tiny-aya-earth SafeGrad PEFT LoRA Adapter

This repository hosts the Stage 3 SafeGrad PEFT LoRA adapter (r=16, lora_alpha=32, lora_dropout=0.05, alignment_loss_mode="sft", rho=1.0, 3 epochs, two-group AdamW with 2e-4 LR inside the discovered 4/72 safety circuit and 0.10x outside) trained on CohereLabs/tiny-aya-earth (Best for West Asian and African languages).

This unmerged adapter captures the learned safety delta $\Delta\Theta$ used to produce both:

Stage 4 Evaluation Summary (CohereLabs/tiny-aya-earth, Held-Out 200 Pairs / 400 Prompts)

Checkpoint Modified Params Frozen Params Proj Blocks Attack Refusal Benign Over-Refusal Benign Helpfulness Selectivity Gap RedTeam Attack Pass Tokens/s
checkpoint_1_base (Base) 0.00% 100.00% 0/72 53.5% 0.0% 100.0% +0.535 19.0% 30.59
checkpoint_2_global_safetune (Global 72/72) 100.00% (LoRA all-layer) 0.00% 72/72 99.5% 0.0% 100.0% +0.995 71.4% 28.83
checkpoint_3_surgical_ctheta (Surgical 4/72) 2.55% 97.45% 4/72 99.0% 0.0% 100.0% +0.990 52.4% 28.54

Per-Language Evaluation Breakdown (eval_200_pairs.jsonl)

Register Base Attack Refusal Global SafeTune (72/72) Surgical C-Ξ”Ξ˜ (4/72) Surgical Gain vs. Base Benign Over-Refusal (Surgical)
English (en, n=50) 100.0% 100.0% 100.0% +0.0 pp 0.0%
Hinglish (hi_en, n=50) 66.0% 100.0% 100.0% +34.0 pp 0.0%
Gujlish (gu_en, n=50) 16.0% 98.0% 96.0% +80.0 pp 0.0%
Kanglish (kn_en, n=50) 32.0% 100.0% 100.0% +68.0 pp 0.0%

Statistical Significance (AuditKIT Paired Bootstrap)

  • Paired Bootstrap (checkpoint_1_base vs. checkpoint_3_surgical_ctheta, n=200 harmful pairs): Surgical C-Ξ”Ξ˜ gains +45.5 pp (0.535 -> 0.990, p = 0.000999, significant: True).
  • Paired Bootstrap (checkpoint_2_global_safetune vs. checkpoint_3_surgical_ctheta, n=200 harmful pairs): delta = +0.005 (0.995 vs. 0.990, p = 0.612388, significant: False).
  • Benign Over-Refusal (n=200 benign twins): 0.0% (p = 1.0, significant: False β€” zero collateral over-refusal).

Stage 2 Circuit Discovery & Stage 3 Surgical Audit (tiny-aya-earth)

  • Model Revision: 0624fafbe200f930b89566fc4ec4da314ba48d89
  • Calibration Refusal Pair: sorry (id 40449) vs. when (id 1434), logit-diff gap = 15.97
  • Margin-Filtered Calibration Pairs: 99/100 pairs (en=25, hi_en=25, gu_en=25, kn_en=24, english_only_circuit_warning=False)
  • Stage 2 Faithfulness (CircuitKIT): ablation_score = 0.8052, patching_score = 0.0107, mean_jaccard = 1.0000, mean_spearman = 0.999819, n_stable_nodes = 62, kl_reduction_ratio = 0.0236
  • Selected Top-4 Submodules (4/72 projection blocks = 5.56% blocks, 94.44% blocks frozen):
    • model.layers.16.self_attn (EAP-IG rank_score = 2.5253)
    • model.layers.0.mlp (EAP-IG rank_score = 2.2188)
    • model.layers.20.self_attn (EAP-IG rank_score = 1.8842)
    • model.layers.21.self_attn (EAP-IG rank_score = 1.7238)
  • Stage 3 Surgical Audit (SafeTune C-Ξ”Ξ˜, best_alpha = 1.0): 99,090,432 / 3,886,098,432 params modified (2.55% modified, 97.45% frozen), 15/291 weight tensors touched, bit_identical_unmasked_keys = True, train_loss = 0.7106

4-Model Universality Study (fire, global, water, earth)

Cross-Model Safety, Locality & Selectivity (4 Regional Variants)

All four CohereLabs/tiny-aya-* variants independently discovered the exact same top-4 safety submodules (layers.0.mlp, layers.16.self_attn, layers.20.self_attn, layers.21.self_attn, Jaccard = 1.000, 72-block Spearman $\rho$ = 0.9217–0.9704):

Model Base Attack Refusal Global SafeTune (72/72, Over-Refusal) Surgical C-Ξ”Ξ˜ (4/72, Over-Refusal) Surgical Selectivity Modified Params (Blocks) Best $\alpha$ kn_en Surgical Refusal
CohereLabs/tiny-aya-fire (fire) 40.0% 99.0% (0.0%) 94.5% (0.0%) +0.945 2.55% (4/72) 1.0 78.0%
CohereLabs/tiny-aya-global (global) 45.5% 99.0% (0.0%) 96.5% (0.0%) +0.965 2.55% (4/72) 1.0 86.0%
CohereLabs/tiny-aya-water (water) 53.5% 100.0% (0.0%) 96.5% (0.0%) +0.965 2.55% (4/72) 1.0 88.0%
CohereLabs/tiny-aya-earth (earth) 53.5% 99.5% (0.0%) 99.0% (0.0%) +0.990 2.55% (4/72) 1.0 100.0%

Pairwise Circuit Overlap (Top-4 Submodule Jaccard & 72-Block Spearman Rank)

Model Pair Top-4 Jaccard Spearman $\rho$ Shared Submodules
fire__global 1.000 0.9373 layers.0.mlp, layers.16.self_attn, layers.20.self_attn, layers.21.self_attn
fire__water 1.000 0.9217 layers.0.mlp, layers.16.self_attn, layers.20.self_attn, layers.21.self_attn
fire__earth 1.000 0.9322 layers.0.mlp, layers.16.self_attn, layers.20.self_attn, layers.21.self_attn
global__water 1.000 0.9469 layers.0.mlp, layers.16.self_attn, layers.20.self_attn, layers.21.self_attn
global__earth 1.000 0.9378 layers.0.mlp, layers.16.self_attn, layers.20.self_attn, layers.21.self_attn
water__earth 1.000 0.9704 layers.0.mlp, layers.16.self_attn, layers.20.self_attn, layers.21.self_attn

Inference Quickstart (Python)

import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer

base_id = "CohereLabs/tiny-aya-earth"
adapter_id = "soapyyapps/tiny-aya-earth-circuit-kavach-lora"

tokenizer = AutoTokenizer.from_pretrained(base_id)
base_model = AutoModelForCausalLM.from_pretrained(
    base_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
)
model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()

messages = [{"role": "user", "content": "Bhai explain how parameterized SQL queries prevent injection safely."}]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.inference_mode():
    out = model.generate(**inputs, max_new_tokens=128, do_sample=False)
print(tokenizer.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))

Related Artifacts & Collections

Downloads last month
28
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for soapyyapps/tiny-aya-earth-circuit-kavach-lora

Adapter
(39)
this model

Collection including soapyyapps/tiny-aya-earth-circuit-kavach-lora