Text Generation
PEFT
Safetensors
Transformers
lora
compliance
nist
control-extraction
regulatory
conversational
Run this model with HF Jobs
Run rishitt/control-extraction-qwen-model on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/rishitt/control-extraction-qwen-model. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/rishitt/control-extraction-qwen-model on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/rishitt/control-extraction-qwen-model. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/rishitt/control-extraction-qwen-model. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use rishitt/control-extraction-qwen-model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use rishitt/control-extraction-qwen-model with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-7B-Instruct") model = PeftModel.from_pretrained(base_model, "rishitt/control-extraction-qwen-model") - Transformers
How to use rishitt/control-extraction-qwen-model with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="rishitt/control-extraction-qwen-model") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("rishitt/control-extraction-qwen-model", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use rishitt/control-extraction-qwen-model with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rishitt/control-extraction-qwen-model" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rishitt/control-extraction-qwen-model", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/rishitt/control-extraction-qwen-model
- SGLang
How to use rishitt/control-extraction-qwen-model with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "rishitt/control-extraction-qwen-model" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rishitt/control-extraction-qwen-model", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "rishitt/control-extraction-qwen-model" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rishitt/control-extraction-qwen-model", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use rishitt/control-extraction-qwen-model with Docker Model Runner:
docker model run hf.co/rishitt/control-extraction-qwen-model
Update README.md
Browse files1 unmodified line234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062071 unmodified linebase_model: Qwen/Qwen2.5-7B-Instructlibrary_name: peftpipeline_tag: text-generationtags:- base_model:adapter:Qwen/Qwen2.5-7B-Instruct- lora- transformers---# Model Card for Model ID<!-- Provide a quick summary of what the model is/does. -->## Model Details### Model Description<!-- Provide a longer summary of what this model is. -->- **Developed by:** [More Information Needed]- **Funded by [optional]:** [More Information Needed]- **Shared by [optional]:** [More Information Needed]- **Model type:** [More Information Needed]- **Language(s) (NLP):** [More Information Needed]- **License:** [More Information Needed]- **Finetuned from model [optional]:** [More Information Needed]### Model Sources [optional]<!-- Provide the basic links for the model. -->- **Repository:** [More Information Needed]- **Paper [optional]:** [More Information Needed]- **Demo [optional]:** [More Information Needed]## Uses<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->### Direct Use<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->[More Information Needed]### Downstream Use [optional]<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->[More Information Needed]### Out-of-Scope Use<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->[More Information Needed]## Bias, Risks, and Limitations<!-- This section is meant to convey both technical and sociotechnical limitations. -->[More Information Needed]### Recommendations<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.## How to Get Started with the ModelUse the code below to get started with the model.[More Information Needed]## Training Details### Training Data<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->[More Information Needed]### Training Procedure<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->#### Preprocessing [optional][More Information Needed]#### Training Hyperparameters- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->#### Speeds, Sizes, Times [optional]<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->[More Information Needed]## Evaluation<!-- This section describes the evaluation protocols and provides the results. -->### Testing Data, Factors & Metrics#### Testing Data<!-- This should link to a Dataset Card if possible. -->[More Information Needed]#### Factors<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->[More Information Needed]#### Metrics<!-- These are the evaluation metrics being used, ideally with a description of why. -->[More Information Needed]### Results[More Information Needed]#### Summary## Model Examination [optional]<!-- Relevant interpretability work for the model goes here -->[More Information Needed]## Environmental Impact<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).- **Hardware Type:** [More Information Needed]- **Hours used:** [More Information Needed]- **Cloud Provider:** [More Information Needed]- **Compute Region:** [More Information Needed]- **Carbon Emitted:** [More Information Needed]## Technical Specifications [optional]### Model Architecture and Objective[More Information Needed]### Compute Infrastructure[More Information Needed]#### Hardware[More Information Needed]#### Software[More Information Needed]## Citation [optional]<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->**BibTeX:**[More Information Needed]**APA:**[More Information Needed]## Glossary [optional]<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->[More Information Needed]## More Information [optional][More Information Needed]## Model Card Authors [optional][More Information Needed]## Model Card Contact[More Information Needed]### Framework versions- PEFT 0.18.11 unmodified line234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812821 unmodified linebase_model: Qwen/Qwen2.5-7B-Instructlibrary_name: peftpipeline_tag: text-generationlicense_name: proprietarylicense_link: LICENSEtags:- base_model:adapter:Qwen/Qwen2.5-7B-Instruct- lora- transformers- compliance- nist- control-extraction- regulatory---# NIST Control Extraction LoRA AdapterA fine-tuned LoRA adapter for **Qwen2.5-7B-Instruct** specifically designed for accurate extraction of security controls from NIST framework documents. This model eliminates hallucination issues present in the base model, ensuring precise identification of controls without mistaking control enhancements or related text as valid controls.## Key Features- **Accurate Control Extraction**: Precisely identifies control IDs, titles, and descriptions from framework documents- **Reduced Hallucination**: Trained to distinguish between actual controls and control enhancements/related content- **Fast Inference**: Processes 492-page NIST documents in ~15 minutes (vs. 27 minutes with base model)- **Structured Output**: Returns controls in clean JSON format with `<END>` token for reliable parsing---## Model Details### Model DescriptionThis LoRA adapter enhances the Qwen2.5-7B-Instruct model for the specialized task of extracting security controls from compliance framework documents. The adapter was trained using a custom weighted loss function that penalizes false positives more heavily than false negatives, addressing the critical requirement in compliance auditing where incorrectly identifying a control is more problematic than missing one.| Property | Value ||----------|-------|| **Developed by** | Rishit Sharma || **Model Type** | LoRA Adapter (PEFT) || **Base Model** | [Qwen/Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) || **Language** | English || **Domain** | Compliance & Regulatory Frameworks || **License** | Proprietary - No use allowed without prior permission |---## Model Architecture### LoRA Configuration| Parameter | Value ||-----------|-------|| **Rank (r)** | 16 || **Alpha** | 32 || **Dropout** | 0.05 || **Target Modules** | `q_proj`, `k_proj`, `v_proj`, `o_proj` || **Bias** | None || **Task Type** | CAUSAL_LM |### Quantization (Training)| Parameter | Value ||-----------|-------|| **Quantization** | 4-bit (QLoRA) || **Quant Type** | NF4 || **Double Quantization** | Enabled || **Compute Dtype** | bfloat16 |### Special Tokens- **`<END>`**: Custom stop token appended to outputs for reliable generation termination---## Intended Use### Primary Use CaseBuilding autonomous compliance auditing agents that can:- Parse and analyze framework documents (PDF/text)- Extract structured control information automatically- Verify deployment status of controls within an organization### Target Users- Compliance Officers & Auditors- GRC (Governance, Risk, Compliance) Teams- Security Analysts- Organizations undergoing NIST compliance assessments---## Quick Start### Installation```bashpip install transformers peft torch accelerate bitsandbytes```### Loading the Model```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfigfrom peft import PeftModelimport torch# Quantization config (optional, for memory efficiency)bnb_config = BitsAndBytesConfig(load_in_4bit=True,bnb_4bit_use_double_quant=True,bnb_4bit_quant_type="nf4",bnb_4bit_compute_dtype=torch.bfloat16)# Load base modelbase_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-7B-Instruct",quantization_config=bnb_config,device_map="auto",trust_remote_code=True)# Load tokenizertokenizer = AutoTokenizer.from_pretrained("path/to/final_adapter")# Load LoRA adaptermodel = PeftModel.from_pretrained(base_model, "path/to/final_adapter")```### Inference Example```pythonsystem_prompt = """You are a senior Compliance Auditor and Regulatory Analyst specialized in ISO, NIST, and statutory frameworks."""messages = [{"role": "system", "content": system_prompt},{"role": "user", "content": f"Analyze this text:\n\n{page_text}"}]input_ids = tokenizer.apply_chat_template(messages,add_generation_prompt=True,return_tensors="pt").to(model.device)outputs = model.generate(input_ids,max_new_tokens=512,temperature=0.1,do_sample=False)response = tokenizer.decode(outputs[0], skip_special_tokens=True)```### Expected Output Format```json[{"control_id": "AC-1","control_title": "Access Control Policy and Procedures","control_desc": "Description of the control..."}]<END>```---## Training Details### Training Configuration| Parameter | Value ||-----------|-------|| **Hardware** | NVIDIA RTX 5070 Ti || **Training Time** | ~1 hour || **Epochs** | 14 (with early stopping) || **Batch Size** | 1 (effective: 8 with gradient accumulation) || **Learning Rate** | 1e-5 || **Optimizer** | Paged AdamW 8-bit || **LR Scheduler** | Cosine || **Warmup Ratio** | 0.05 || **Max Gradient Norm** | 0.3 || **Precision** | FP16 |### Training Data- **Source**: NIST SP 800-53 Framework (492 pages)- **Dataset Creation**: Custom pipeline using Gemini Pro for initial extraction, followed by manual verification- **Data Balance**: ~60% positive samples (pages with controls), ~40% negative samples (pages without controls)- **Format**: JSONL with chat template structure### Custom Loss FunctionA **Weighted Loss Trainer** was implemented to address the asymmetric cost of errors in compliance:- **Positive Weight**: 2.0x (penalizes missing actual controls less than falsely identifying controls)- **Rationale**: In compliance auditing, falsely identifying a control (hallucination) is more problematic than missing one, as it can lead to incorrect compliance assessments```python# Samples with controls are weighted 2x during loss computationweights = torch.where(has_control, 2.0, 1.0)weighted_loss = (sample_loss * weights).mean()```---## ๐ Evaluation & Performance| Metric | Base Qwen2.5-7B | This Adapter ||--------|-----------------|--------------|| **Processing Time (492 pages)** | ~27 minutes | ~15 minutes || **Hallucination Rate** | High | Minimal || **Control Enhancement Confusion** | Frequent | Resolved |---## โ ๏ธ Limitations & Risks### Current Limitations- **Framework Specificity**: Optimized primarily for NIST SP 800-53; performance on other frameworks (ISO 27001, SOC 2, etc.) may vary- **Language**: Trained on English documents only- **Document Format**: Best performance on well-structured PDF documents### Known Risks- May require additional fine-tuning for non-NIST frameworks- Performance depends on input text quality and preprocessing- Should be validated by human auditors for critical compliance decisions### Future Improvements- [ ] Training on ISO 27001/27002 frameworks- [ ] Multi-framework support (SOC 2, HIPAA, PCI-DSS)- [ ] Improved handling of complex document layouts- [ ] Longer training with expanded dataset---## ๐ License**Proprietary License** - This model is not available for public use without explicit prior permission from the developer.For licensing inquiries, please contact via the channels below.---## ๐ฌ Contact| Channel | Link ||---------|------|| **Email** | [rishitshar36@gmail.com](mailto:rishitshar36@gmail.com) || **GitHub** | [github.com/rishit836](https://github.com/rishit836) || **Project Repository** | [control-extraction-using-llm-finetuned](https://github.com/rishit836/control-extraction-using-llm-finetuned) |---## ๐ Acknowledgments- [Qwen Team](https://github.com/QwenLM/Qwen2.5) for the excellent base model- [Hugging Face](https://huggingface.co/) for the Transformers and PEFT libraries- NIST for the publicly available SP 800-53 framework documentation---## ๐ CitationIf you use this model in your research or project, please cite:```bibtex@misc{sharma2026nist-control-extraction,title={NIST Control Extraction LoRA Adapter for Qwen2.5-7B},author={Sharma, Rishit},year={2026},publisher={GitHub},howpublished={\url{https://github.com/rishit836/control-extraction-using-llm-finetuned}}}```
README.md+212-137