Downloads · 30 days
10
26% of all-time downloads
LorenzoMascia/tinyllama-lora-anonymizer
tinyllama-lora-anonymizer is a text generation model from LorenzoMascia. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
LoRA adapters that turn TinyLlama-1.1B into a local privacy filter: it removes personally identifiable information from text and returns a structured JSON object containing both the anonymized text and a full mapping…
Downloads · 30 days
10
26% of all-time downloads
All-time downloads
39
Public
Repo size
25.3 MB
Likes
0
Public
Click a slice to open those files.
.safetensors25.3 MB · 100%
From the Hugging Face model README
LoRA adapters that turn TinyLlama-1.1B into a local privacy filter: it removes personally identifiable information from text and returns a structured JSON object containing both the anonymized text and a full mapping of every replaced token.
Because the mapping is returned, the process is reversible. Sanitized text can be sent to an external LLM API; when the response comes back, the original values are restored locally. Raw PII never leaves your infrastructure.
Live demo: https://huggingface.co/spaces/LorenzoMascia/tinyllama-lora-anonymizer Training pipeline: https://github.com/LorenzoMascia/llm-distillery Write-up: https://www.howai.cloud/fine-tuning-knowledge-distillation-llm.html
Input:
Mario Rossi lives at Via Roma 1, Milano. Email: [email protected]
Output:
{
"anonymized_text": "[NAME_1] lives at [ADDRESS_1]. Email: [EMAIL_1]",
"replaced_tokens": [
{"replaced_value": "[NAME_1]", "original_value": "Mario Rossi"},
{"replaced_value": "[ADDRESS_1]", "original_value": "Via Roma 1, Milano"},
{"replaced_value": "[EMAIL_1]", "original_value": "[email protected]"}
]
}
These are LoRA adapters — the base model weights are not included.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
BASE = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
tokenizer = AutoTokenizer.from_pretrained(BASE)
model = AutoModelForCausalLM.from_pretrained(BASE, torch_dtype=torch.float16, device_map="auto")
model = PeftModel.from_pretrained(model, "LorenzoMascia/tinyllama-lora-anonymizer")
The adapters were trained on the Alpaca template. Using a different format will degrade output quality significantly.
### Instruction:
Analyze the following text and anonymize all personally identifiable information (PII). Return a JSON object with the anonymized text and all replaced tokens.
### Input:
{your text here}
### Response:
Generate with a low temperature (~0.1) — the output is a data structure, not prose.
q_proj, v_projTraining an anonymizer would normally require a corpus of real PII — precisely the data the model is meant to protect. Synthetic generation resolves that: the teacher produces realistic input/output pairs, and the student learns from those alone.
Apache 2.0