1from peft import PeftModel
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4# Load the base model and tokenizer
5base_model_name = "ethicalabs/Echo-DSRN-114M-v0.1.2"
6base_model = AutoModelForCausalLM.from_pretrained(base_model_name, trust_remote_code=True)
7tokenizer = AutoTokenizer.from_pretrained(base_model_name, trust_remote_code=True)
8
9# Load the NSFW adapter
10peft_model_name = "ethicalabs/Echo-SmolTools-114M-NSFW-CLF-PEFT"
11model = PeftModel.from_pretrained(base_model, peft_model_name, trust_remote_code=True)
12
13# Inference
14utt = "only one scene of nudity where two women are briefly topless"
15messages = [
16 {"role": "system", "content": "You are a helpful NSFW classification assistant."},
17 {"role": "user", "content": f"Classify the following text (0 for Safe, 1 for NSFW): {utt}"}
18]
19prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
20inputs = tokenizer(prompt, return_tensors="pt")
21
22# Deterministic Routing
23outputs = model.generate(**inputs, max_new_tokens=15, do_sample=False)
24response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True).strip()
25
26print(f"Classification (1=NSFW, 0=Safe): {response}")
1>>> print(f"Classification (1=NSFW, 0=Safe): {response}")
2Classification (1=NSFW, 0=Safe): 1
1python echo_nsfw/testing.py /home/ethicalabs/.ethicalabs/flwr/results/2026-04-24_10-16-18/peft_30/
2🚀 Loading base model: ethicalabs/Echo-DSRN-114M-v0.1.2
3`torch_dtype` is deprecated! Use `dtype` instead!
4Loading weights: 100%|█| 139/139 [00:00<00:00, 3345.89it/s, Materializing param=
5🔗 Loading LoRA adapter: /home/ethicalabs/.ethicalabs/flwr/results/2026-04-24_10-16-18/peft_30/
6📥 Loading validation set...
7--- 🧠 Deterministic NSFW Validation ---
8
9🌍 Evaluation for 40241 samples...
10Testing NSFW: 100%|███████████████████████| 40241/40241 [25:07<00:00, 26.70it/s]
11========================================
12📊 DETERMINISTIC NSFW VALIDATION REPORT
13========================================
14Overall Accuracy | 96.72% | (38921/40241)
15========================================
This LoRA adapter has been fine-tuned (SFT) on a single
AMD Radeon™ AI PRO R9700 (32 GB RAM) by using the
Flower Framework and
TRL, in a simulated federated learning scenario.