Instructions to use MrBenL/controlsense with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use MrBenL/controlsense with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2") model = PeftModel.from_pretrained(base_model, "MrBenL/controlsense") - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,56 +1,124 @@
|
|
| 1 |
---
|
| 2 |
base_model: mistralai/Mistral-7B-Instruct-v0.2
|
| 3 |
library_name: peft
|
| 4 |
-
|
| 5 |
tags:
|
| 6 |
-
- base_model:adapter:mistralai/Mistral-7B-Instruct-v0.2
|
| 7 |
- lora
|
| 8 |
-
-
|
| 9 |
-
-
|
| 10 |
-
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
---
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
-
This model is a fine-tuned version of [mistralai/Mistral-7B-Instruct-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2).
|
| 18 |
-
It has been trained using [TRL](https://github.com/huggingface/trl).
|
| 19 |
-
|
| 20 |
-
## Quick start
|
| 21 |
-
|
| 22 |
-
```python
|
| 23 |
-
from transformers import pipeline
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
| 30 |
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
|
|
|
|
| 34 |
|
|
|
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
|
| 42 |
-
- TRL: 1.4.0
|
| 43 |
-
- Transformers: 5.8.1
|
| 44 |
-
- Pytorch: 2.5.1+cu121
|
| 45 |
-
- Datasets: 4.8.5
|
| 46 |
-
- Tokenizers: 0.22.2
|
| 47 |
|
| 48 |
-
|
|
|
|
|
|
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
Cite TRL as:
|
| 53 |
-
|
| 54 |
```bibtex
|
| 55 |
@software{vonwerra2020trl,
|
| 56 |
title = {{TRL: Transformers Reinforcement Learning}},
|
|
@@ -59,4 +127,4 @@ Cite TRL as:
|
|
| 59 |
url = {https://github.com/huggingface/trl},
|
| 60 |
year = {2020}
|
| 61 |
}
|
| 62 |
-
```
|
|
|
|
| 1 |
---
|
| 2 |
base_model: mistralai/Mistral-7B-Instruct-v0.2
|
| 3 |
library_name: peft
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
tags:
|
|
|
|
| 6 |
- lora
|
| 7 |
+
- peft
|
| 8 |
+
- grc
|
| 9 |
+
- compliance
|
| 10 |
+
- security
|
| 11 |
+
- nist-csf
|
| 12 |
+
- cis-controls
|
| 13 |
+
license: other
|
| 14 |
+
license_name: polyform-noncommercial-1.0.0
|
| 15 |
+
license_link: https://polyformproject.org/licenses/noncommercial/1.0.0
|
| 16 |
---
|
| 17 |
|
| 18 |
+
# ControlSense Adapter
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
A LoRA adapter that fine-tunes
|
| 21 |
+
[mistralai/Mistral-7B-Instruct-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2)
|
| 22 |
+
to analyze security and governance control statements: it maps a control to
|
| 23 |
+
recognized frameworks (NIST CSF 2.0, CIS Controls v8, NIST AI RMF 1.0),
|
| 24 |
+
identifies coverage gaps, and emits a structured result suitable for a gap
|
| 25 |
+
register.
|
| 26 |
|
| 27 |
+
This adapter is the trained component of **ControlSense**, a locally-running
|
| 28 |
+
GRC policy analysis tool. The adapter on its own is roughly 84 MB; it is meant
|
| 29 |
+
to be applied to the Mistral base model. For the full application, including
|
| 30 |
+
the document ingestion pipeline, UI, and Docker setup, see the project
|
| 31 |
+
repository.
|
| 32 |
|
| 33 |
+
- Project: ControlSense (https://benluthy.com)
|
| 34 |
+
- Base model: mistralai/Mistral-7B-Instruct-v0.2 (Apache-2.0)
|
| 35 |
|
| 36 |
+
## Intended use
|
| 37 |
|
| 38 |
+
ControlSense is a **decision-support tool**. It is intended to help security
|
| 39 |
+
governance practitioners triage and draft control-to-framework mappings and
|
| 40 |
+
surface candidate gaps for review. It is not a source of authoritative
|
| 41 |
+
compliance determinations, and its output should be reviewed by a qualified
|
| 42 |
+
practitioner before being used in any audit, attestation, or compliance
|
| 43 |
+
decision.
|
| 44 |
|
| 45 |
+
## How to use
|
| 46 |
|
| 47 |
+
The adapter is designed to be run inside the ControlSense application, which
|
| 48 |
+
constructs the prompt format the model was trained on and handles framework
|
| 49 |
+
validation of the output. Using the adapter outside that prompt structure will
|
| 50 |
+
not reliably produce well-formed results.
|
| 51 |
|
| 52 |
+
To load the adapter directly with PEFT:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
+
```python
|
| 55 |
+
from peft import PeftModel
|
| 56 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 57 |
|
| 58 |
+
base = "mistralai/Mistral-7B-Instruct-v0.2"
|
| 59 |
+
model = AutoModelForCausalLM.from_pretrained(base, device_map="auto")
|
| 60 |
+
model = PeftModel.from_pretrained(model, "MrBenL/controlsense")
|
| 61 |
+
tokenizer = AutoTokenizer.from_pretrained("MrBenL/controlsense")
|
| 62 |
+
```
|
| 63 |
|
| 64 |
+
## Training
|
| 65 |
+
|
| 66 |
+
- Method: QLoRA (4-bit) supervised fine-tuning of Mistral-7B-Instruct-v0.2
|
| 67 |
+
- Data: a small set of expert-authored GRC examples (approximately 168)
|
| 68 |
+
spanning 12 domains, including access management, data protection, incident
|
| 69 |
+
response, vulnerability management, third-party risk, change management, AI
|
| 70 |
+
governance, LLM security, risk management, security awareness, policies and
|
| 71 |
+
standards, and business continuity
|
| 72 |
+
- The training examples are original, authored for this project. They do not
|
| 73 |
+
contain any proprietary, employer, or client material.
|
| 74 |
+
- Output is constrained to a structured schema and validated and
|
| 75 |
+
confidence-filtered by the application before display.
|
| 76 |
+
|
| 77 |
+
## Evaluation
|
| 78 |
+
|
| 79 |
+
The adapter is evaluated against a held-out set of 100 hand-curated control
|
| 80 |
+
examples, each specifying the framework mappings the model should produce and
|
| 81 |
+
keywords for the gaps it should surface. On the measured baseline, required-
|
| 82 |
+
mapping accuracy is 53.1% (scoped to NIST CSF 2.0, the framework with the
|
| 83 |
+
densest training coverage, with each miss expert-adjudicated as a genuine miss
|
| 84 |
+
rather than a key error). NIST AI RMF and OWASP LLM mappings are produced and
|
| 85 |
+
measured but reported as emerging coverage pending expanded training data. The
|
| 86 |
+
product-level fabricated-ID rate is 0.0%: the application's output sanitizer
|
| 87 |
+
validates every category against the official framework enumerations and rejects
|
| 88 |
+
fabricated or retired IDs before display (the pre-sanitizer model-level rate was
|
| 89 |
+
5.2%, almost entirely retired NIST CSF 1.1 numbers). All outputs are intended for
|
| 90 |
+
human verification rather than unattended use.
|
| 91 |
+
|
| 92 |
+
## Limitations
|
| 93 |
+
|
| 94 |
+
- Coverage is limited to the frameworks and control domains represented in the
|
| 95 |
+
training data; controls outside that scope may be mapped poorly or not at all.
|
| 96 |
+
- Like any LLM, the model can produce plausible but incorrect framework
|
| 97 |
+
citations. Confidence scores and source citations are provided to support
|
| 98 |
+
human verification, not to replace it.
|
| 99 |
+
- The model is non-deterministic; identical inputs may produce slightly
|
| 100 |
+
different outputs.
|
| 101 |
+
- The model can occasionally assign a confident but fabricated code (for example
|
| 102 |
+
a non-existent framework version or an invented subcategory). The output
|
| 103 |
+
sanitizer rejects these structurally, so the affected control is surfaced as
|
| 104 |
+
"No confident mapping" rather than a false mapping, and should be reviewed and
|
| 105 |
+
mapped manually.
|
| 106 |
+
|
| 107 |
+
## License
|
| 108 |
+
|
| 109 |
+
This adapter is released under the
|
| 110 |
+
[PolyForm Noncommercial License 1.0.0](https://polyformproject.org/licenses/noncommercial/1.0.0).
|
| 111 |
+
Use for any noncommercial purpose is free. Commercial use by or on behalf of a
|
| 112 |
+
for-profit organization requires a separate commercial license; contact
|
| 113 |
+
support@benluthy.com.
|
| 114 |
+
|
| 115 |
+
The base model, Mistral-7B-Instruct-v0.2, is licensed separately by Mistral AI
|
| 116 |
+
under Apache-2.0.
|
| 117 |
+
|
| 118 |
+
## Citation
|
| 119 |
+
|
| 120 |
+
This adapter was trained using [TRL](https://github.com/huggingface/trl):
|
| 121 |
|
|
|
|
|
|
|
| 122 |
```bibtex
|
| 123 |
@software{vonwerra2020trl,
|
| 124 |
title = {{TRL: Transformers Reinforcement Learning}},
|
|
|
|
| 127 |
url = {https://github.com/huggingface/trl},
|
| 128 |
year = {2020}
|
| 129 |
}
|
| 130 |
+
```
|