GIGGeorg commited on
Commit
64e93f4
·
verified ·
1 Parent(s): eaa31e7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline, logging
2
+
3
+ # Ignore warnings
4
+ logging.set_verbosity(logging.CRITICAL)
5
+
6
+ # Load the model and tokenizer with authentication token
7
+ model_name = "King-Harry/NinjaMasker-PII-Redaction"
8
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
9
+ model = AutoModelForCausalLM.from_pretrained(model_name)
10
+ pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer, max_length=100)
11
+ prompt = "My name is Harry and I live in Winnipeg. My phone number is ummm 204 no 203, ahh 4344, no 4355"
12
+ result = pipe(f"<s>[INST] {prompt} [/INST]")
13
+
14
+ # Print the generated text
15
+ print(result[0]['generated_text'])