bogdanraduta commited on
Commit
7e045e0
·
verified ·
1 Parent(s): d057442

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +54 -2
README.md CHANGED
@@ -36,9 +36,11 @@ language:
36
  - tr
37
  ---
38
 
39
- # flowxai/regulated-advice
40
 
41
- The `regulated_advice` 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
 
@@ -61,6 +63,56 @@ This number is not decoration. Read at the 0.5 default that looked reasonable, s
61
 
62
  **Pair accuracy: 0.797.** Both halves of a minimal pair correct. This is the headline number for this detector, because the easy examples outnumber the ones that decide whether it is usable.
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  ## Per language
65
 
66
  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
+ # regulated_advice[border]
40
 
41
+ The `regulated_advice` 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/regulated-advice` on the hub. It is one detector of 28, and it is not a general purpose regulated_advice 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
 
 
63
 
64
  **Pair accuracy: 0.797.** Both halves of a minimal pair correct. This is the headline number for this detector, because the easy examples outnumber the ones that decide whether it is usable.
65
 
66
+ ## How to use it
67
+
68
+ 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.
69
+
70
+ ```sh
71
+ pip install flowx-border
72
+ ```
73
+
74
+ ```yaml
75
+ # policy.yaml
76
+ policy_id: default
77
+ version: 1
78
+
79
+ detectors:
80
+ regulated_advice:
81
+ enabled: true
82
+ on_fail: flag
83
+ threshold: 0.72
84
+ ```
85
+
86
+ ```python
87
+ from flowx_border import load_policy, scan_output
88
+
89
+ policy = load_policy("policy.yaml")
90
+
91
+ decision = scan_output(model_answer, policy)
92
+
93
+ print(decision.verdict) # allow | flag | redact | block
94
+ print([f.label for f in decision.findings if f.detector_id == "regulated_advice"])
95
+ print(decision.evidence.record_id)
96
+ ```
97
+
98
+ This detector reads the output side, so `scan_output` is where it fires. It is T2, so it runs on the standard path and can be disabled per policy. Its budget is 225 ms at 87 tokens on one CPU thread.
99
+
100
+ 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.
101
+
102
+ ### Without the library
103
+
104
+ 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.
105
+
106
+ ```python
107
+ import onnxruntime as ort
108
+ from huggingface_hub import hf_hub_download
109
+ from tokenizers import Tokenizer
110
+
111
+ repo = "flowxai/regulated-advice"
112
+ session = ort.InferenceSession(hf_hub_download(repo, "onnx/model.int8.onnx"))
113
+ tokenizer = Tokenizer.from_file(hf_hub_download(repo, "tokenizer.json"))
114
+ ```
115
+
116
  ## Per language
117
 
118
  Per language rather than an aggregate, because an aggregate across 26 languages hides the tail and the tail is the point.