broadfield-dev commited on
Commit
911426b
·
verified ·
1 Parent(s): 72bd10f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +16 -11
README.md CHANGED
@@ -33,24 +33,29 @@ pip install onnxruntime transformers
33
 
34
  ### Python Example
35
  ```python
36
-
37
- from transformers import AutoTokenizer
38
  import onnxruntime as ort
39
  import numpy as np
40
 
41
- # 1. Load Tokenizer
42
- tokenizer = AutoTokenizer.from_pretrained("broadfield-dev/bert-small-ner-pii-tuned-12261022-onnx")
43
 
44
- # 2. Load Model
45
  session = ort.InferenceSession("model.onnx")
46
 
47
- # 3. Preprocess
48
- text = "This is a test sentence."
49
- inputs = tokenizer(text, return_tensors="np")
 
 
 
 
 
 
50
 
51
- # 4. Inference
52
- outputs = session.run(None, dict(inputs))
53
- print(outputs[0])
54
 
55
  ```
56
 
 
33
 
34
  ### Python Example
35
  ```python
36
+ from tokenizers import Tokenizer
 
37
  import onnxruntime as ort
38
  import numpy as np
39
 
40
+ # 1. Load the lightweight tokenizer (No Transformers dependency needed)
41
+ tokenizer = Tokenizer.from_pretrained("broadfield-dev/bert-small-ner-pii-tuned-12261022-onnx")
42
 
43
+ # 2. Load the ONNX model
44
  session = ort.InferenceSession("model.onnx")
45
 
46
+ # 3. Preprocess (Simple text encoding)
47
+ text = "Run inference on mobile!"
48
+ encoding = tokenizer.encode(text)
49
+
50
+ # Prepare inputs (Exact names vary by model, usually input_ids + attention_mask)
51
+ inputs = {{
52
+ "input_ids": np.array([encoding.ids], dtype=np.int64),
53
+ "attention_mask": np.array([encoding.attention_mask], dtype=np.int64)
54
+ }}
55
 
56
+ # 4. Run Inference
57
+ outputs = session.run(None, inputs)
58
+ print("Output logits shape:", outputs[0].shape)
59
 
60
  ```
61