CoolFace
Modelpublic

vineeth453/qwen3-4b-guardrails-embedding-v1

sourceHugging Faceapache-2.0updated 7mo agoView on Hugging Face
0likes92downloads
Model Card

Qwen3-4B Guardrails Embedding v1

Fine-tuned from Qwen/Qwen3-Embedding-4B for regulatory document retrieval as part of a Multi-Agent Debate (MAD) Guardrails system developed at SJSU.

This model serves as the retrieval backbone in a RAG pipeline that provides ground truth for agent debates on AI governance and regulatory compliance.


Model Description

PropertyValue
Base modelQwen/Qwen3-Embedding-4B
ArchitectureDecoder-only (Qwen3), last-token pooling
Embedding dimension2560
Max sequence length512
Fine-tuning methodLoRA (r=16, alpha=32) merged into base
PoolingLast token + L2 normalization

Training Details

ParameterValue
Training records13,572 synthetic query-chunk pairs
Data domainAI regulatory documents
Documents coveredEU AI Act, NIST AI RMF GenAI Profile, NIS2, Cyber Resilience Act, DORA, NIST CSF 2.0, NIST SP 1270
Query typesbenign_sensitive, ambiguous, adversarial
LossMultipleNegativesRankingLoss
Hard negatives1 per example (mined from rank 6-50 via MiniLM)
Epochs3
Batch size4 (effective 16 with grad accum=4)
Learning rate1e-4 with cosine decay
Warmup ratio0.1
LoRA rank16
LoRA alpha32
LoRA dropout0.05
LoRA targetsqproj, kproj, vproj, oproj, gateproj, upproj, down_proj
HardwareNVIDIA A100 SXM4 40GB
Training time~2.5 hours

Evaluation Results

Evaluated on a 4-candidate reranking task (1 positive + 3 hard negatives) with 864 val / 864 test samples.

Overall

Splitrecall@1recall@3MRR
Validation0.94791.00000.9732
Test0.97451.00000.9869

Per Query Type — Validation

Query Typerecall@1recall@3MRR
benign_sensitive0.94791.00000.9734
ambiguous0.95831.00000.9792
adversarial0.93751.00000.9670

Per Query Type — Test

Query Typerecall@1recall@3MRR
benign_sensitive0.98261.00000.9913
ambiguous0.98261.00000.9902
adversarial0.95831.00000.9792

Usage

python
from sentence_transformers import SentenceTransformer

model = SentenceTransformer(
    "vineeth453/qwen3-4b-guardrails-embedding-v1",
    trust_remote_code=True
)
model.max_seq_length = 512

# Queries require the instruction prefix
QUERY_INSTRUCTION = (
    "Instruct: Retrieve relevant regulatory passage to answer the query\n"
    "Query: "
)

# Passages are encoded without any prefix
query   = QUERY_INSTRUCTION + "What are the documentation requirements for high-risk AI systems?"
chunks  = [
    "EU AI Act Article 11 requires providers of high-risk AI systems to draw up technical documentation...",
    "NIST AI RMF suggests organizations establish governance structures for AI risk management..."
]

query_emb  = model.encode([query],  normalize_embeddings=True)
chunk_emb  = model.encode(chunks,   normalize_embeddings=True)
scores     = query_emb @ chunk_emb.T
print(scores)
Important: Always apply the instruction prefix to queries. Chunks/passages are encoded without any prefix. Consistency between fine-tuning and inference is critical for performance.

Intended Use

  • —Retrieval in RAG pipelines for AI governance and regulatory compliance
  • —Ground truth retrieval for multi-agent debate (MAD) systems
  • —Semantic search over regulatory documents (EU AI Act, NIST frameworks, cybersecurity regulations)

Out-of-Scope Use

  • —General-purpose semantic similarity (not optimized for non-regulatory domains)
  • —Generation tasks
  • —Classification without a retrieval head

Roadmap

  • —[ ] Round 2 fine-tuning — r=32, all 3 hard negatives, MNR scale=15, LR=5e-5, 4 epochs
  • —[ ] Hard negative re-mining using this model as the miner
  • —[ ] Quantization (GGUF / AWQ) for faster inference
  • —[ ] Larger eval pool (10-20 candidates for production-realistic metrics)

Project Context

This model is part of the SJSU Guardrails Project — a system for evaluating AI agent outputs against regulatory ground truth using Multi-Agent Debate (MAD) orchestration.

Pipeline: User query → RAG retrieval (this model) → Ground truth chunks → Agent debate → Guardrail verdict


License

Apache 2.0 — same as base model.