Views
No views yet
1from huggingface_hub import hf_hub_download
2import torch
3import json
4
5# Download
6config_path = hf_hub_download("bitlabsdb/bad-classifier-tinyllama", "config.json")
7model_path = hf_hub_download("bitlabsdb/bad-classifier-tinyllama", "pytorch_model.bin")
8
9# Load config
10with open(config_path) as f:
11 config = json.load(f)
12
13# Define classifier
14class BADClassifier(torch.nn.Module):
15 def __init__(self, input_dim):
16 super().__init__()
17 self.linear = torch.nn.Linear(input_dim, 2)
18 def forward(self, x):
19 return self.linear(x)
20
21# Load
22classifier = BADClassifier(config['input_dim'])
23classifier.load_state_dict(torch.load(model_path))1@article{fairsteer2025,
2 title={FairSteer: Inference Time Debiasing for LLMs},
3 author={Li, Yichen et al.},
4 year={2025}
5}