bogdanraduta commited on
Commit
0da1f9c
·
verified ·
1 Parent(s): 0cc3fab

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +53 -2
README.md CHANGED
@@ -36,9 +36,11 @@ language:
36
  - tr
37
  ---
38
 
39
- # flowxai/topic-scope
40
 
41
- The `topic_scope` detector for [flowx-border](https://github.com/flowx-ai/border), an embeddable library that inspects the text going into and coming out of an LLM and returns a structured decision plus an audit-grade evidence record.
 
 
42
 
43
  This card is generated from the evaluation and export artifacts of the training run, so every number on it is reproducible from this repository rather than asserted.
44
 
@@ -54,6 +56,55 @@ This card is generated from the evaluation and export artifacts of the training
54
 
55
  This head is read with argmax and has no threshold.
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  ## Per language
58
 
59
  Per language rather than an aggregate, because an aggregate across 26 languages hides the tail and the tail is the point.
 
36
  - tr
37
  ---
38
 
39
+ # topic_scope[border]
40
 
41
+ The `topic_scope` detector for [border](https://github.com/flowx-ai/border), an embeddable library that inspects the text going into and coming out of an LLM and returns a structured decision plus an audit-grade evidence record.
42
+
43
+ `flowxai/topic-scope` on the hub. It is one detector of 28, and it is not a general purpose topic_scope classifier: it was trained for this library's policy, is read at the operating point below, and reports through the evidence record rather than returning a bare score.
44
 
45
  This card is generated from the evaluation and export artifacts of the training run, so every number on it is reproducible from this repository rather than asserted.
46
 
 
56
 
57
  This head is read with argmax and has no threshold.
58
 
59
+ ## How to use it
60
+
61
+ Through the library, which is what this model is for. It loads the artifact below, applies the operating point above, and returns a decision with an evidence record rather than a bare score.
62
+
63
+ ```sh
64
+ pip install flowx-border
65
+ ```
66
+
67
+ ```yaml
68
+ # policy.yaml
69
+ policy_id: default
70
+ version: 1
71
+
72
+ detectors:
73
+ topic_scope:
74
+ enabled: true
75
+ on_fail: flag
76
+ ```
77
+
78
+ ```python
79
+ from flowx_border import load_policy, scan_input
80
+
81
+ policy = load_policy("policy.yaml")
82
+
83
+ decision = scan_input(user_text, policy)
84
+
85
+ print(decision.verdict) # allow | flag | redact | block
86
+ print([f.label for f in decision.findings if f.detector_id == "topic_scope"])
87
+ print(decision.evidence.record_id)
88
+ ```
89
+
90
+ This detector reads the input side, so `scan_input` is where it fires. It is T3, so it runs only when a lower tier flags, or when the policy sets `always: true`. Its budget is 300 ms at 87 tokens on one CPU thread.
91
+
92
+ The weights are fetched once and cached, and a scan needs no network after that. Nothing here calls out to a hosted model, and the evidence record carries hashes rather than your text.
93
+
94
+ ### Without the library
95
+
96
+ The artifact is plain ONNX, so it will load in `onnxruntime` directly. Two things you then own yourself, and they are the reason the library exists: the operating point above is not in the graph, and neither is the chunking. Inputs longer than the trained window have to be split and recombined, or the scores past it are extrapolation.
97
+
98
+ ```python
99
+ import onnxruntime as ort
100
+ from huggingface_hub import hf_hub_download
101
+ from tokenizers import Tokenizer
102
+
103
+ repo = "flowxai/topic-scope"
104
+ session = ort.InferenceSession(hf_hub_download(repo, "onnx/model.int8.onnx"))
105
+ tokenizer = Tokenizer.from_file(hf_hub_download(repo, "tokenizer.json"))
106
+ ```
107
+
108
  ## Per language
109
 
110
  Per language rather than an aggregate, because an aggregate across 26 languages hides the tail and the tail is the point.