Instructions to use AaronTekle/ClauseQwen with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AaronTekle/ClauseQwen with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AaronTekle/ClauseQwen")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("AaronTekle/ClauseQwen", device_map="auto") - PEFT
How to use AaronTekle/ClauseQwen with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use AaronTekle/ClauseQwen with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AaronTekle/ClauseQwen" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AaronTekle/ClauseQwen", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/AaronTekle/ClauseQwen
- SGLang
How to use AaronTekle/ClauseQwen 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 "AaronTekle/ClauseQwen" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AaronTekle/ClauseQwen", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "AaronTekle/ClauseQwen" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AaronTekle/ClauseQwen", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use AaronTekle/ClauseQwen with Docker Model Runner:
docker model run hf.co/AaronTekle/ClauseQwen
ClauseQwen - Qwen3 Legal Contract Clause Analysis
QLoRA fine-tuning of Qwen3-1.7B for Legal commercial contract-clause analysis using CUAD and LegalBench / ContractNLI.
Legal Commercial contracts contain dense legal language that can make clause review and structured extraction slow when performed manually. ClauseQwen is designed to reduce that effort by identifying clause types, detecting whether contractual concepts are present, extracting relevant language, and returning natural language.
Why QLoRa
QLoRA adds 4-bit base model quantization to reduce memory usage, making it more optimal (on the memory side) than vanilla LoRa.
Model
- Base model:
Qwen/Qwen3-1.7B - Fine-tuning: QLoRA / LoRA
- Quantization: 4-bit NF4
- Training: TRL
SFTTrainer - Adapters: PEFT LoRA
Datasets
CUAD
Used for:
- clause-category classification
- clause-presence detection
- relevant-language extraction
LegalBench / ContractNLI
Adds contract reasoning tasks covering concepts such as confidentiality, limited use, survival of obligations, third-party sharing, compelled disclosure, return of confidential information, and related contractual obligations.
Training Run
| Metric | Result |
|---|---|
| Training examples | 31,395 |
| Validation examples | 2,730 |
| Epochs | 2 |
| Training steps | 1,824 |
| Final training loss | 0.01686 |
| Final evaluation loss | 0.00751 |
| Evaluation mean token accuracy | 99.74% |
| Training runtime | ~16h 57m |
training was completed locally on an NVIDIA GeForce RTX 3050 with 6 GB VRAM using 4-bit QLoRA
Adapter output:
outputs/legal-qwen3-1.7b-qlora
Base vs Fine-Tuned Evaluation
held-out evaluation of 100 examples compared the original Qwen3-1.7B against Qwen3-1.7B with the legal QLoRA adapter.
| Metric | Base Model (qwen3-1.7b) | Fine-Tuned Model (ClauseQwen) | Improvements |
|---|---|---|---|
| JSON validity | 100% | 100% | 0 pp |
| Clause-type accuracy | 15% | 92% | +77 pp |
| Clause-presence accuracy | 76% | 91% | +15 pp |
| Extraction F1 | 0.7275 | 0.9059 | +0.1784 |
largest improvement was in clause-type classification, increasing from 15% to 92%. Extraction F1 increased from 0.7275 to 0.9059 while maintaining 100% valid JSON output.
ContractNLI note: The reported 100-example benchmark contained CUAD extraction and classification examples only. ContractNLI classification accuracy was therefore not evaluated in this benchmark and should be measured separately with a stratified ContractNLI evaluation.
HF Imports
pipeline:
from transformers import pipeline
pipe = pipeline("text-generation", model="AaronTekle/legal-qwen3-1.7b-qlora")
load model directly:
from transformers import AutoModel
model = AutoModel.from_pretrained("AaronTekle/legal-qwen3-1.7b-qlora", device_map="auto")