Instructions to use imabedalghafer/maqsm_model_pii_removal_gemma34b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use imabedalghafer/maqsm_model_pii_removal_gemma34b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="imabedalghafer/maqsm_model_pii_removal_gemma34b") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("imabedalghafer/maqsm_model_pii_removal_gemma34b") model = AutoModelForMultimodalLM.from_pretrained("imabedalghafer/maqsm_model_pii_removal_gemma34b", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use imabedalghafer/maqsm_model_pii_removal_gemma34b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "imabedalghafer/maqsm_model_pii_removal_gemma34b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "imabedalghafer/maqsm_model_pii_removal_gemma34b", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/imabedalghafer/maqsm_model_pii_removal_gemma34b
- SGLang
How to use imabedalghafer/maqsm_model_pii_removal_gemma34b with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "imabedalghafer/maqsm_model_pii_removal_gemma34b" \ --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": "imabedalghafer/maqsm_model_pii_removal_gemma34b", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
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 "imabedalghafer/maqsm_model_pii_removal_gemma34b" \ --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": "imabedalghafer/maqsm_model_pii_removal_gemma34b", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use imabedalghafer/maqsm_model_pii_removal_gemma34b with Docker Model Runner:
docker model run hf.co/imabedalghafer/maqsm_model_pii_removal_gemma34b
MAQSM PII Detection Model
Model Description
This model is a fine-tuned version of gemma3 specifically designed for Personally Identifiable Information (PII) detection and masking in Arabic and English text. The model identifies and replaces PII with [MASKED] tokens while preserving the original text structure and meaning.
Model Details
- Base Model: google/gemma-3
- Model Type: Causal Language Model
- Fine-tuning Method: LoRA (Low-Rank Adaptation)
- Languages: Arabic, English (Mixed-language support)
- Task: PII Detection and Masking
- License: Same as base model
Training Details
Training Data
- Custom dataset for PII detection and masking
- Mixed Arabic-English text samples
- Various PII types including names, emails, phone numbers, addresses, IP addresses, national IDs, and financial information
Supported PII Types
The model is trained to detect and mask the following types of PII:
- Personal Names: First, middle, and family names
- Contact Information: Phone numbers, email addresses
- Addresses: Physical addresses and locations
- Identification Numbers: National IDs, SSNs, account numbers
- Financial Information: Bank account details, credit card numbers
- Technical Identifiers: IP addresses, MAC addresses
- Dates: Birth dates and other personal dates
- Cryptocurrency: Wallet addresses and transaction IDs
Usage
Quick Start
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
# Load model and tokenizer
model_name = "imabedalghafer/maqsm_model_pii_removal_gemma34b"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.auto,
device_map="auto",
trust_remote_code=True
)
# Create pipeline
pipe = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
device_map="auto"
)
# System message
system_msg = """
**Role Definition**
You are a specialized language model trained to identify and mask Personally Identifiable Information (PII) within textual data.
"""
# Example usage
def mask_pii(text):
prompt = [
{"role": "system", "content": system_msg},
{"role": "user", "content": f"{text}"}
]
generation = pipe(prompt, do_sample=True, temperature=0.7, top_p=0.8, top_k=20)
output = generation[0]['generated_text'][-1]['content'].strip()
return output
# Test the model
test_text = "ุงุณู
ู ุฃุญู
ุฏ ู
ุญู
ุฏ ูุฑูู
ูุงุชูู 123-456-7890"
masked_text = mask_pii(test_text)
print(f"Original: {test_text}")
print(f"Masked: {masked_text}")
Expected Output Format
Input:
"ุงุณู
ู ุฃุญู
ุฏ ู
ุญู
ุฏ ูุฑูู
ูุงุชูู 123-456-7890"
Output:
"ุงุณู
ู [MASKED] ูุฑูู
ูุงุชูู [MASKED]"
Limitations
- The model is primarily trained on Arabic and English text
- Performance may vary with domain-specific PII types not covered in training
- May occasionally over-mask or under-mask certain edge cases
- Requires careful prompt engineering for optimal results
Ethical Considerations
This model is designed to protect individual privacy by identifying and masking PII. However:
- Users should verify masked output for completeness
- The model should not be the sole method for PII protection in critical applications
- Consider human review for sensitive documents
- Be aware of potential false positives/negatives
Citation
If you use this model in your research, please cite:
@misc{maqsm_pii_model_2025,
title={MAQSM PII Detection Model: Fine-tuned Gemma-3-4B for Arabic-English PII Masking},
author={TheConsultants Team},
year={2025},
publisher={Hugging Face},
url={https://huggingface.co/imabedalghafer/maqsm_model_pii_removal_gemma34b}
}
License
This model inherits the license from the base model (google/gemma-3-4b-it). Please refer to the base model's license for terms and conditions.
Contact
For questions, issues, or collaboration opportunities, please reach out through the Hugging Face model repository or create an issue in the discussions section.
Disclaimer: This model is provided as-is for research and development purposes. Users are responsible for ensuring compliance with applicable privacy laws and regulations when using this model in production environments.
- Downloads last month
- -