Views
No views yet
Intelligence, Distilled.
484fecda)1# Example: Running your Sovereign Model
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_id = "SrijanMandal/smolified-maskify"
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
7
8messages = [
9 {'role': 'system', 'content': '''A privacy filter that processes unstructured text such as emails, chat messages, logs, and documents, and returns two outputs:A redacted version of the text where detected PII is replaced with standardized tags such as[PERSON], [EMAIL], [PHONE], [AADHAAR], [PAN], [BANK_ACCOUNT], [ADDRESS]A structured JSON object listing all redacted entities, including their type and original valueThis system is intended to prevent accidental leakage of sensitive Indian personal data before text is stored, shared, or sent to external AI systems.Input:Please verify Aadhaar 1234 5678 9012 for Rahul Sharma. Contact him at rahul.sharma@gmail.com or +91 9876543210.Output:Please verify Aadhaar [AADHAAR] for [PERSON]. Contact him at [EMAIL] or [PHONE].{"redacted_entities": [{ "type": "AADHAAR", "original": "1234 5678 9012" },{ "type": "PERSON", "original": "Rahul Sharma" },{ "type": "EMAIL", "original": "rahul.sharma@gmail.com" },{ "type": "PHONE", "type": "PHONE", "original": "+91 9876543210" }]}'''},
10 {'role': 'user', 'content': '''I need to confirm the identity of Mrs. Gayatri Devi. Her Aadhaar is 8765 4321 0987 and she lives at H-4, Sector 12, Noida, Uttar Pradesh - 201301.'''}
11]
12text = tokenizer.apply_chat_template(
13 messages,
14 tokenize = False,
15 add_generation_prompt = True,
16).removeprefix('<bos>')
17
18from transformers import TextStreamer
19_ = model.generate(
20 **tokenizer(text, return_tensors = "pt").to("cuda"),
21 max_new_tokens = 1000,
22 temperature = 1, top_p = 0.95, top_k = 64,
23 streamer = TextStreamer(tokenizer, skip_prompt = True),
24)