Views
No views yet
correct): When evidence strongly supports a responseuncertain): When information is ambiguousrefuse): When answering would require speculation| Metric | Base ERNIE 4.5 | Fine-tuned | Improvement |
|---|---|---|---|
| False Confidence | 28.2% | 16.4% | -11.8% ✅ |
| Overall Accuracy | 73.3% | 86.7% | +13.3% ✅ |
| Calibration (ECE) | 0.213 | 0.183 | -14.1% ✅ |
baidu/ERNIE-4.5-0.3B-PT (304M parameters)gate_proj, q_proj, v_proj, k_proj, o_proj, up_proj, down_projpip install transformers peft torch1from transformers import AutoTokenizer, AutoModelForCausalLM
2from peft import PeftModel
3import torch
4
5# Load base model
6base_model_name = "baidu/ERNIE-4.5-0.3B-PT"
7model = AutoModelForCausalLM.from_pretrained(
8 base_model_name,
9 torch_dtype=torch.float16,
10 device_map="auto",
11 trust_remote_code=True
12)
13
14# Load LoRA adapters
15model = PeftModel.from_pretrained(
16 model,
17 "lochan027/failure-aware-ernie-4.5" # Replace with your HF username/repo
18)
19
20tokenizer = AutoTokenizer.from_pretrained(
21 base_model_name,
22 trust_remote_code=True
23)1prompt = """Answer the question responsibly. Decide whether to answer, express uncertainty, or refuse.
2
3Question: Should the government increase taxes on the wealthy?
4
5Response:"""
6
7inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
8
9with torch.no_grad():
10 outputs = model.generate(
11 **inputs,
12 max_length=512,
13 temperature=0.7,
14 do_sample=True,
15 top_p=0.9
16 )
17
18response = tokenizer.decode(outputs[0], skip_special_tokens=True)
19print(response)1{
2 "decision": "uncertain",
3 "answer": "Tax policy on high earners is debated among economists and policymakers. Arguments for higher taxes cite revenue needs and inequality reduction. Arguments against cite potential effects on investment and economic growth. Optimal rates depend on economic conditions and value priorities.",
4 "justification": "This is a normative policy question involving trade-offs and value judgments with no consensus answer.",
5 "evidence_quality": "medium"
6}1@software{failure_aware_ernie_2025,
2 title={Failure-Aware ERNIE: Teaching LLMs When to Say "I Don't Know"},
3 author={lochan027},
4 year={2025},
5 url={https://github.com/lochan027/failure-aware-ernie},
6 note={AI Safety Hackathon Project}
7}