Finetuned Models
Collection
4 items โข Updated
How to use mlninad/PII-Shield with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="mlninad/PII-Shield")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("mlninad/PII-Shield")
model = AutoModelForCausalLM.from_pretrained("mlninad/PII-Shield")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use mlninad/PII-Shield with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "mlninad/PII-Shield"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "mlninad/PII-Shield",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/mlninad/PII-Shield
How to use mlninad/PII-Shield with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "mlninad/PII-Shield" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "mlninad/PII-Shield",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "mlninad/PII-Shield" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "mlninad/PII-Shield",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use mlninad/PII-Shield with Docker Model Runner:
docker model run hf.co/mlninad/PII-Shield
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="mlninad/PII-Shield")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages)# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("mlninad/PII-Shield")
model = AutoModelForCausalLM.from_pretrained("mlninad/PII-Shield")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))Your Intelligent Guardian for Personal Data Protection
PII-Shield is your cutting-edge solution for protecting sensitive information in text data. Powered by advanced transformer architecture, it's your first line of defense against unintended PII exposure.
"Regular text with sarah.smith@email.com" โ "Regular text with [EMAIL_1]"
"Call John at (555) 123-4567" โ "Call [PERSON_1] at [PHONE_1]"
Original โ Masked โ JSON Mapping
| Category | Icon | Example |
|---|---|---|
| Names | ๐ค | John Smith |
| Emails | ๐ง | user@domain.com |
| Phones | ๐ฑ | (555) 123-4567 |
| Addresses | ๐ | 123 Privacy St |
| SSN | ๐ข | XXX-XX-XXXX |
| Credit Cards | ๐ณ | XXXX-XXXX-XXXX |
| DOB | ๐ | MM/DD/YYYY |
| IPs | ๐ | 192.168.1.1 |
def detect_pii(text: str) -> List[Entity]:
"""
๐ Intelligent PII detection
Returns list of identified entities
"""
pass
def mask_pii(text: str, entities: List[Entity]) -> Dict:
"""
๐ก๏ธ Smart PII masking
Returns masked text and mapping
"""
pass
{
"text": "Your sensitive text here",
"options": {
"mask_format": "[TYPE_INDEX]",
"return_mapping": true
}
}
{
"masked_text": "Your [TYPE_1] text here",
"pii_mapping": [
{
"label": "TYPE",
"value": "sensitive",
"index": 1
}
]
}
| Metric | Score | Trend |
|---|---|---|
| Precision | 98.5% | โฌ๏ธ |
| Recall | 97.8% | โฌ๏ธ |
| Speed | 2ms/req | โฌ๏ธ |
| Accuracy | 99.1% | โก๏ธ |
Apache License 2.0 โข Made with โค๏ธ for Privacy
Base model
meta-llama/Llama-3.2-3B-Instruct
# Gated model: Login with a HF token with gated access permission hf auth login