Instructions to use PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1") model = AutoModelForMultimodalLM.from_pretrained("PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - PEFT
How to use PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1 with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1
- SGLang
How to use PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1 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 "PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1" \ --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": "PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1", "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 "PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1" \ --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": "PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1 with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1 to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1 to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1", max_seq_length=2048, ) - Docker Model Runner
How to use PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1 with Docker Model Runner:
docker model run hf.co/PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1
- Gemma 4 E2B IT – Regulatory Obligation Extraction v1
- Features
- Supported Tasks
- Intended Applications
- Not Intended For
- Base Model
- Training Configuration
- Training Environment
- Training Dataset
- Output Format
- Example Usage
- Evaluation
- Limitations
- Ethical Considerations
- Version History
- Citation
- License
- Acknowledgements
Gemma 4 E2B IT – Regulatory Obligation Extraction v1
Overview
Gemma 4 E2B IT – Regulatory Obligation Extraction v1 is a domain-adapted Small Language Model (SLM) fine-tuned for extracting regulatory obligations from legal and compliance documents.
The model identifies regulatory obligations and converts unstructured regulatory text into structured JSON suitable for downstream Governance, Risk, and Compliance (GRC) applications.
Unlike a general-purpose language model, this model has been optimized specifically for compliance automation workflows and legal NLP tasks involving regulatory documents.
Features
- Fine-tuned using QLoRA (4-bit NF4)
- Built on Google Gemma 4 E2B IT
- Instruction tuned for Legal NLP
- Structured JSON generation
- Regulatory obligation extraction
- Modality classification
- Span-level obligation extraction
- Optimized for low-memory inference
- MLflow experiment tracking
- PEFT compatible
Supported Tasks
The model classifies regulatory text into one of three categories:
- Obligation
- Non-Obligation
- Neutral Statement
For obligation statements, the model extracts structured information including:
- Subject
- Action Required
- Modality
- Conditions
- Deadlines
- Reference metadata
Intended Applications
This model is designed for:
- Regulatory obligation extraction
- Compliance monitoring
- Legal document parsing
- Governance Risk & Compliance (GRC)
- Regulatory change management
- Knowledge Graph construction
- Retrieval-Augmented Generation (RAG)
- Regulatory intelligence
- Legal NLP research
- Compliance automation pipelines
Not Intended For
This model should not be used as a substitute for legal professionals.
It should not be used for:
- Legal advice
- Contract drafting
- Legal interpretation
- Court proceedings
- Regulatory opinions
- High-risk compliance decisions without human review
Base Model
| Property | Value |
|---|---|
| Base Model | google/gemma-4-E2B-it |
| Architecture | Gemma 4 |
| Fine-tuning Method | QLoRA |
| Quantization | 4-bit NF4 |
| Framework | Unsloth |
| Library | Hugging Face Transformers |
| Adapter Framework | PEFT |
Training Configuration
| Parameter | Value |
|---|---|
| Context Length | 1024 |
| LoRA Rank (r) | 16 |
| LoRA Alpha | 16 |
| LoRA Dropout | 0.05 |
| Learning Rate | 1e-4 |
| Epochs | 5 |
| Batch Size | 1 |
| Gradient Accumulation | 4 |
| Weight Decay | 0.01 |
| Scheduler | Cosine |
| Optimizer | AdamW 8-bit |
| Gradient Checkpointing | Unsloth |
| Mixed Precision | FP16 |
Training Environment
- Google Colab
- NVIDIA T4 GPU (16 GB VRAM)
- Unsloth
- Transformers
- PEFT
- TRL
- Accelerate
- BitsAndBytes
- MLflow
Training Dataset
The model was instruction-tuned using a custom dataset containing regulatory and compliance text collected from publicly available standards and regulations.
Regulatory source: few documents from RBI Guidelines
The training dataset contains examples of:
- Positive obligations
- Negative (non-obligation) statements
- Neutral informational statements
Output Format
The model generates structured JSON.
Example Input
Every financial institution shall maintain customer records for five years.
Example Output
{
"output": [
{
"subject": "Financial institution",
"action": "Maintain customer records",
"modality": "MUST",
"conditions": "",
"deadline": "Five years"
}
]
}
Example Usage
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map="auto"
)
prompt = """
Every financial institution shall maintain customer records for five years.
"""
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(
**inputs,
max_new_tokens=256,
temperature=0.1
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Evaluation
The model was evaluated using multiple task-specific metrics.
Metrics tracked during evaluation include:
- Span Precision
- Span Recall
- Span F1 Score
- Modality Accuracy
- JSON Parse Success Rate
Benchmarking pipeline includes:
- Custom Golden Test Dataset
- MLflow experiment tracking
- Span-level evaluation
- Modality classification evaluation
Limitations
The model may:
- Miss implicit obligations
- Misclassify ambiguous regulatory language
- Produce incomplete JSON for unusually long documents
- Require prompt engineering for complex regulations
- Require human validation before production deployment
Ethical Considerations
This model is intended to assist compliance professionals and researchers.
Outputs should always be reviewed by qualified legal or compliance experts before making regulatory or business decisions.
Version History
v1
Initial public release.
Features:
- Gemma 4 E2B IT base model
- QLoRA fine-tuning
- Regulatory obligation extraction
- Structured JSON generation
- MLflow integration
- PEFT compatible adapters
- Span-level extraction
- Modality classification
Citation
If you use this model in your research, please cite:
@misc{PrinceRansom2026,
title={Gemma 4 E2B IT – Regulatory Obligation Extraction v1},
author={Prince Ransom},
year={2026},
publisher={Hugging Face},
url={https://huggingface.co/PrinceRansom7/gemma4-e2b-it-regulatory-obligation-v1}
}
License
This project is released under the Apache 2.0 License.
Acknowledgements
This work was built using:
- Google Gemma
- Hugging Face Transformers
- Unsloth
- PEFT
- TRL
- BitsAndBytes
- Accelerate
- MLflow
Special thanks to the open-source community for providing the tools and frameworks that made this work possible.
- Downloads last month
- 227