Downloads · 30 days
5
14% of all-time downloads
logsyc/failure-aware-ernie-4.5
failure-aware-ernie-4.5 is a machine learning model from logsyc. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as mit.
Fine-tuned ERNIE 4.5 model that learns to explicitly express uncertainty, refuse inappropriate queries, and calibrate confidence.
Downloads · 30 days
5
14% of all-time downloads
All-time downloads
37
Public
Repo size
24.9 MB
Likes
1
Public
Click a slice to open those files.
.safetensors12.1 MB · 48%
From the Hugging Face model README
Fine-tuned ERNIE 4.5 model that learns to explicitly express uncertainty, refuse inappropriate queries, and calibrate confidence.
🔗 Full Project: https://github.com/lochan027/failure-aware-ernie
This model addresses a critical AI safety issue: hallucination through false confidence. Instead of always providing an answer, it's trained to:
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% ✅ |
Key Finding: The model reduces dangerous overconfidence while improving accuracy.
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 torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch
# Load base model
base_model_name = "baidu/ERNIE-4.5-0.3B-PT"
model = AutoModelForCausalLM.from_pretrained(
base_model_name,
torch_dtype=torch.float16,
device_map="auto",
trust_remote_code=True
)
# Load LoRA adapters
model = PeftModel.from_pretrained(
model,
"lochan027/failure-aware-ernie-4.5" # Replace with your HF username/repo
)
tokenizer = AutoTokenizer.from_pretrained(
base_model_name,
trust_remote_code=True
)
prompt = """Answer the question responsibly. Decide whether to answer, express uncertainty, or refuse.
Question: Should the government increase taxes on the wealthy?
Response:"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_length=512,
temperature=0.7,
do_sample=True,
top_p=0.9
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
Expected Output (Structured JSON):
{
"decision": "uncertain",
"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.",
"justification": "This is a normative policy question involving trade-offs and value judgments with no consensus answer.",
"evidence_quality": "medium"
}
The model was trained on 500 examples covering:
Evaluation uses controlled failure scenarios to measure:
See results/ for visualization plots.
Research and educational purposes:
NOT intended for:
@software{failure_aware_ernie_2025,
title={Failure-Aware ERNIE: Teaching LLMs When to Say "I Don't Know"},
author={lochan027},
year={2025},
url={https://github.com/lochan027/failure-aware-ernie},
note={AI Safety Hackathon Project}
}
Project Repository: https://github.com/lochan027/failure-aware-ernie
A model that says "I don't know" at the right time is safer than one that always pretends to know.