Instructions to use millat/Qwen2.5-7B-BDLAW-LoRA with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use millat/Qwen2.5-7B-BDLAW-LoRA 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, "millat/Qwen2.5-7B-BDLAW-LoRA") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use millat/Qwen2.5-7B-BDLAW-LoRA with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M # Run inference directly in the terminal: llama cli -hf millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M # Run inference directly in the terminal: llama cli -hf millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M
Use Docker
docker model run hf.co/millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use millat/Qwen2.5-7B-BDLAW-LoRA with Ollama:
ollama run hf.co/millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M
- Unsloth Studio
How to use millat/Qwen2.5-7B-BDLAW-LoRA 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 millat/Qwen2.5-7B-BDLAW-LoRA 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 millat/Qwen2.5-7B-BDLAW-LoRA to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for millat/Qwen2.5-7B-BDLAW-LoRA to start chatting
- Pi
How to use millat/Qwen2.5-7B-BDLAW-LoRA with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- OpenClaw new
How to use millat/Qwen2.5-7B-BDLAW-LoRA with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
- Docker Model Runner
How to use millat/Qwen2.5-7B-BDLAW-LoRA with Docker Model Runner:
docker model run hf.co/millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M
- Lemonade
How to use millat/Qwen2.5-7B-BDLAW-LoRA with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M
Run and chat with the model
lemonade run user.Qwen2.5-7B-BDLAW-LoRA-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use millat/Qwen2.5-7B-BDLAW-LoRA with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default millat/Qwen2.5-7B-BDLAW-LoRA:Q4_K_M
Run Hermes
hermes
- Atomic Chat
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,202 +1,287 @@
|
|
| 1 |
---
|
| 2 |
base_model: Qwen/Qwen2.5-7B-Instruct
|
| 3 |
library_name: peft
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
-
## Model Details
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
<!-- Provide the basic links for the model. -->
|
| 31 |
-
|
| 32 |
-
- **Repository:** [More Information Needed]
|
| 33 |
-
- **Paper [optional]:** [More Information Needed]
|
| 34 |
-
- **Demo [optional]:** [More Information Needed]
|
| 35 |
-
|
| 36 |
-
## Uses
|
| 37 |
-
|
| 38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 39 |
-
|
| 40 |
-
### Direct Use
|
| 41 |
-
|
| 42 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 43 |
-
|
| 44 |
-
[More Information Needed]
|
| 45 |
-
|
| 46 |
-
### Downstream Use [optional]
|
| 47 |
-
|
| 48 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 49 |
-
|
| 50 |
-
[More Information Needed]
|
| 51 |
-
|
| 52 |
-
### Out-of-Scope Use
|
| 53 |
-
|
| 54 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 55 |
-
|
| 56 |
-
[More Information Needed]
|
| 57 |
-
|
| 58 |
-
## Bias, Risks, and Limitations
|
| 59 |
-
|
| 60 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 61 |
-
|
| 62 |
-
[More Information Needed]
|
| 63 |
-
|
| 64 |
-
### Recommendations
|
| 65 |
-
|
| 66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 67 |
-
|
| 68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
-
|
| 70 |
-
## How to Get Started with the Model
|
| 71 |
-
|
| 72 |
-
Use the code below to get started with the model.
|
| 73 |
-
|
| 74 |
-
[More Information Needed]
|
| 75 |
-
|
| 76 |
-
## Training Details
|
| 77 |
-
|
| 78 |
-
### Training Data
|
| 79 |
-
|
| 80 |
-
<!-- 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. -->
|
| 81 |
-
|
| 82 |
-
[More Information Needed]
|
| 83 |
-
|
| 84 |
-
### Training Procedure
|
| 85 |
-
|
| 86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
-
|
| 88 |
-
#### Preprocessing [optional]
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
#### Training Hyperparameters
|
| 94 |
-
|
| 95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
-
|
| 103 |
-
## Evaluation
|
| 104 |
-
|
| 105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
|
| 115 |
-
|
| 116 |
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
-
|
| 120 |
|
| 121 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
-
|
| 124 |
|
| 125 |
-
|
| 126 |
|
| 127 |
-
|
| 128 |
|
| 129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
-
|
| 132 |
|
|
|
|
| 133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
-
|
| 136 |
|
| 137 |
-
|
| 138 |
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
-
|
| 142 |
|
| 143 |
-
|
| 144 |
|
| 145 |
-
|
| 146 |
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
|
| 153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
-
|
|
|
|
| 158 |
|
| 159 |
-
|
| 160 |
|
| 161 |
-
|
| 162 |
|
| 163 |
-
|
| 164 |
|
| 165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
|
| 167 |
-
|
| 168 |
|
| 169 |
-
|
| 170 |
|
| 171 |
-
|
| 172 |
|
| 173 |
-
|
| 174 |
|
| 175 |
-
|
| 176 |
|
| 177 |
-
|
| 178 |
|
| 179 |
-
**
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
-
|
| 182 |
|
| 183 |
-
##
|
| 184 |
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
-
|
| 188 |
|
| 189 |
-
##
|
| 190 |
|
| 191 |
-
|
| 192 |
|
| 193 |
-
|
| 194 |
|
| 195 |
-
|
| 196 |
|
| 197 |
-
|
|
|
|
|
|
|
| 198 |
|
| 199 |
-
|
| 200 |
-
### Framework versions
|
| 201 |
|
| 202 |
-
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
base_model: Qwen/Qwen2.5-7B-Instruct
|
| 3 |
library_name: peft
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
datasets:
|
| 6 |
+
- millat/BDLawCorpus-Dataset-V1
|
| 7 |
+
language:
|
| 8 |
+
- en
|
| 9 |
+
- bn
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Qwen 2.5 7B Instruct - Bangladesh Legal LoRA Adapter
|
| 13 |
|
| 14 |
+

|
| 15 |
+

|
| 16 |
+

|
| 17 |
+

|
| 18 |
|
| 19 |
+
A fine-tuned LoRA adapter for **Qwen 2.5 7B Instruct** specialized in **Bangladesh legal reasoning** and **legal document analysis**.
|
| 20 |
|
| 21 |
+
---
|
| 22 |
|
| 23 |
+
## 📋 Model Details
|
| 24 |
+
|
| 25 |
+
| Property | Value |
|
| 26 |
+
|----------|-------|
|
| 27 |
+
| **Base Model** | [Qwen/Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) |
|
| 28 |
+
| **Adapter Type** | LoRA (Low-Rank Adaptation) |
|
| 29 |
+
| **LoRA Rank (r)** | 64 |
|
| 30 |
+
| **LoRA Alpha (α)** | 128 |
|
| 31 |
+
| **Target Modules** | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
|
| 32 |
+
| **Training Dataset** | [BDLawCorpus Dataset V1](https://huggingface.co/datasets/millat/BDLawCorpus-Dataset-V1) |
|
| 33 |
+
| **Training Examples** | 4,710 Bangla legal documents |
|
| 34 |
+
| **Training Epochs** | 3 |
|
| 35 |
+
| **Training Hours** | ~6.5 hours on 2x T4 GPU |
|
| 36 |
+
| **Precision** | FP16 mixed precision + 4-bit quantization |
|
| 37 |
+
| **Batch Size** | 8 (per device) |
|
| 38 |
+
| **Learning Rate** | 2e-4 |
|
| 39 |
+
| **Quantization** | 4-bit NF4 (train) / Optional for inference |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
---
|
| 42 |
|
| 43 |
+
## 🚀 Quick Start
|
| 44 |
+
|
| 45 |
+
### Installation
|
| 46 |
+
|
| 47 |
+
```bash
|
| 48 |
+
pip install transformers peft torch accelerate
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
### Loading the Model
|
| 52 |
+
|
| 53 |
+
```python
|
| 54 |
+
import torch
|
| 55 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
| 56 |
+
from peft import PeftModel
|
| 57 |
+
|
| 58 |
+
# Base model
|
| 59 |
+
model_id = "Qwen/Qwen2.5-7B-Instruct"
|
| 60 |
+
adapter_id = "millat/qwen-2.5-7b-instruct-bdlaw-lora"
|
| 61 |
+
|
| 62 |
+
# Load base model (with optional 4-bit quantization)
|
| 63 |
+
bnb_config = BitsAndBytesConfig(
|
| 64 |
+
load_in_4bit=True,
|
| 65 |
+
bnb_4bit_use_double_quant=True,
|
| 66 |
+
bnb_4bit_quant_type="nf4",
|
| 67 |
+
bnb_4bit_compute_dtype=torch.float16
|
| 68 |
+
)
|
| 69 |
+
|
| 70 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 71 |
+
model_id,
|
| 72 |
+
device_map="auto",
|
| 73 |
+
quantization_config=bnb_config,
|
| 74 |
+
torch_dtype=torch.float16,
|
| 75 |
+
trust_remote_code=True,
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 79 |
+
|
| 80 |
+
# Attach LoRA adapter
|
| 81 |
+
model = PeftModel.from_pretrained(model, adapter_id)
|
| 82 |
+
model.eval()
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
### Inference Example
|
| 86 |
+
|
| 87 |
+
```python
|
| 88 |
+
# Bangla legal query
|
| 89 |
+
prompt = "বাংলাদেশে চুক্তি আইন কী এবং এর প্রধান বৈশিষ্ট্য কি?"
|
| 90 |
+
|
| 91 |
+
# Format with chat template
|
| 92 |
+
messages = [{"role": "user", "content": prompt}]
|
| 93 |
+
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 94 |
+
|
| 95 |
+
# Generate response
|
| 96 |
+
inputs = tokenizer(text, return_tensors="pt").to("cuda")
|
| 97 |
+
outputs = model.generate(
|
| 98 |
+
**inputs,
|
| 99 |
+
max_new_tokens=512,
|
| 100 |
+
temperature=0.7,
|
| 101 |
+
do_sample=True,
|
| 102 |
+
top_p=0.95,
|
| 103 |
+
pad_token_id=tokenizer.eos_token_id,
|
| 104 |
+
)
|
| 105 |
+
|
| 106 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 107 |
+
print(response)
|
| 108 |
+
```
|
| 109 |
|
| 110 |
+
---
|
| 111 |
|
| 112 |
+
## 📊 Training Details
|
| 113 |
+
|
| 114 |
+
### Dataset
|
| 115 |
+
|
| 116 |
+
**BDLawCorpus Dataset V1** contains:
|
| 117 |
+
- **4,710** Bangla legal documents and case studies
|
| 118 |
+
- Multi-format: Chat templates with conversation pairs
|
| 119 |
+
- Topics: Contract Law, Criminal Law, Constitutional Law, Property Law, Labor Law
|
| 120 |
+
- Quality: Manually validated and cleaned
|
| 121 |
+
|
| 122 |
+
### Training Configuration
|
| 123 |
+
|
| 124 |
+
```python
|
| 125 |
+
# Quantization (4-bit)
|
| 126 |
+
load_in_4bit=True
|
| 127 |
+
bnb_4bit_use_double_quant=True
|
| 128 |
+
bnb_4bit_quant_type="nf4"
|
| 129 |
+
bnb_4bit_compute_dtype=torch.float16
|
| 130 |
+
|
| 131 |
+
# LoRA Configuration
|
| 132 |
+
r=64 # Rank
|
| 133 |
+
lora_alpha=128 # Scaling factor
|
| 134 |
+
lora_dropout=0.05
|
| 135 |
+
bias="none"
|
| 136 |
+
task_type="CAUSAL_LM"
|
| 137 |
+
|
| 138 |
+
# Training Arguments
|
| 139 |
+
num_train_epochs=3
|
| 140 |
+
per_device_train_batch_size=8
|
| 141 |
+
gradient_accumulation_steps=2
|
| 142 |
+
learning_rate=2e-4
|
| 143 |
+
weight_decay=0.01
|
| 144 |
+
warmup_steps=100
|
| 145 |
+
save_steps=200
|
| 146 |
+
save_total_limit=3
|
| 147 |
+
logging_steps=10
|
| 148 |
+
fp16=True
|
| 149 |
+
gradient_checkpointing=True
|
| 150 |
+
ddp_find_unused_parameters=False
|
| 151 |
+
```
|
| 152 |
+
|
| 153 |
+
### Training Environment
|
| 154 |
+
|
| 155 |
+
- **Hardware**: Kaggle 2x T4 GPU (15GB each)
|
| 156 |
+
- **Framework**: Hugging Face Transformers + PEFT + Accelerate
|
| 157 |
+
- **Parallelism**: Distributed Data Parallel (DDP)
|
| 158 |
+
- **Total Training Time**: ~6.5 hours
|
| 159 |
+
- **Final Loss**: 0.112
|
| 160 |
|
| 161 |
+
---
|
| 162 |
|
| 163 |
+
## 💡 Use Cases
|
| 164 |
|
| 165 |
+
This model is optimized for:
|
| 166 |
|
| 167 |
+
1. **Legal Document Summarization** - Summarize Bangla legal texts and acts
|
| 168 |
+
2. **Legal Question Answering** - Answer questions about Bangladesh law
|
| 169 |
+
3. **Contract Analysis** - Analyze and explain contract clauses
|
| 170 |
+
4. **Case Law Explanation** - Provide insights into court decisions
|
| 171 |
+
5. **Regulatory Compliance** - Advise on Bangladesh legal compliance
|
| 172 |
+
6. **Document Classification** - Categorize legal documents
|
| 173 |
+
7. **Legal Research** - Retrieve relevant case law and precedents
|
| 174 |
|
| 175 |
+
---
|
| 176 |
|
| 177 |
+
## 📈 Performance Metrics
|
| 178 |
|
| 179 |
+
| Metric | Value |
|
| 180 |
+
|--------|-------|
|
| 181 |
+
| Training Loss | 0.112 |
|
| 182 |
+
| Samples/Second | 0.608 |
|
| 183 |
+
| Steps/Second | 0.076 |
|
| 184 |
+
| Total Training Steps | 1,764 |
|
| 185 |
+
| Memory Used (per GPU) | ~14.4 GB |
|
| 186 |
+
| Model Size (Adapter only) | ~131 MB |
|
| 187 |
|
| 188 |
+
---
|
| 189 |
|
| 190 |
+
## ⚖️ Limitations
|
| 191 |
|
| 192 |
+
- **Language-specific**: Optimized for Bangla legal documents; English queries may have lower accuracy
|
| 193 |
+
- **Domain-specific**: Trained on Bangladesh legal corpus; may not generalize to other domains
|
| 194 |
+
- **Knowledge cutoff**: Based on training data; may not reflect recent legal changes
|
| 195 |
+
- **LLM limitations**: Can hallucinate; always verify outputs with official sources
|
| 196 |
+
- **No real-time updates**: Requires retraining for new laws or amendments
|
| 197 |
|
| 198 |
+
---
|
| 199 |
|
| 200 |
+
## 🔧 Fine-tuning & Adaptation
|
| 201 |
|
| 202 |
+
To further fine-tune this adapter on your own data:
|
| 203 |
|
| 204 |
+
```python
|
| 205 |
+
from transformers import TrainingArguments, Trainer
|
|
|
|
|
|
|
|
|
|
| 206 |
|
| 207 |
+
training_args = TrainingArguments(
|
| 208 |
+
output_dir="./my_adapter",
|
| 209 |
+
num_train_epochs=2,
|
| 210 |
+
per_device_train_batch_size=8,
|
| 211 |
+
learning_rate=1e-4,
|
| 212 |
+
save_steps=100,
|
| 213 |
+
logging_steps=10,
|
| 214 |
+
fp16=True,
|
| 215 |
+
)
|
| 216 |
|
| 217 |
+
trainer = Trainer(
|
| 218 |
+
model=model,
|
| 219 |
+
args=training_args,
|
| 220 |
+
train_dataset=your_dataset,
|
| 221 |
+
data_collator=data_collator,
|
| 222 |
+
)
|
| 223 |
|
| 224 |
+
trainer.train()
|
| 225 |
+
```
|
| 226 |
|
| 227 |
+
---
|
| 228 |
|
| 229 |
+
## 📝 Citation
|
| 230 |
|
| 231 |
+
If you use this model, please cite:
|
| 232 |
|
| 233 |
+
```bibtex
|
| 234 |
+
@model{qwen_bdlaw_lora_2025,
|
| 235 |
+
title={Qwen 2.5 7B Instruct - Bangladesh Legal LoRA Adapter},
|
| 236 |
+
author={MD Millat Hosen},
|
| 237 |
+
organization={BDLaw Corpus Project},
|
| 238 |
+
year={2025},
|
| 239 |
+
howpublished={\url{https://huggingface.co/millat/qwen-2.5-7b-instruct-bdlaw-lora}},
|
| 240 |
+
}
|
| 241 |
+
```
|
| 242 |
|
| 243 |
+
---
|
| 244 |
|
| 245 |
+
## 📄 License
|
| 246 |
|
| 247 |
+
This adapter is provided under the **Creative Commons Attribution 4.0 International (CC-BY-4.0)** license.
|
| 248 |
|
| 249 |
+
The base model (Qwen 2.5 7B) is licensed under the **Qwen License Agreement**. Please refer to the [original model card](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) for details.
|
| 250 |
|
| 251 |
+
---
|
| 252 |
|
| 253 |
+
## 👥 Contact & Support
|
| 254 |
|
| 255 |
+
- **Model Developer**: MD Millat Hosen
|
| 256 |
+
- **Project**: [BDLawCorpus](https://github.com/millathosen/BDLawCorpus)
|
| 257 |
+
- **Email**: Contact via GitHub issues
|
| 258 |
+
- **Repository**: [BDLawCorpus GitHub](https://huggingface.co/millat)
|
| 259 |
|
| 260 |
+
---
|
| 261 |
|
| 262 |
+
## 🙏 Acknowledgments
|
| 263 |
|
| 264 |
+
- **Qwen Team** for the excellent base model architecture
|
| 265 |
+
- **Hugging Face** for the transformers library and model hosting
|
| 266 |
+
- **Kaggle** for providing free GPU compute
|
| 267 |
+
- **Bangladesh Legal Community** for data and domain expertise
|
| 268 |
|
| 269 |
+
---
|
| 270 |
|
| 271 |
+
## ⚠️ Disclaimer
|
| 272 |
|
| 273 |
+
This model is provided for educational and research purposes. While we strive for accuracy, legal advice should always be verified with qualified legal professionals. The model authors assume no responsibility for any consequences arising from the use of this model for legal decision-making.
|
| 274 |
|
| 275 |
+
---
|
| 276 |
|
| 277 |
+
## 🔄 Model Updates
|
| 278 |
|
| 279 |
+
| Version | Date | Notes |
|
| 280 |
+
|---------|------|-------|
|
| 281 |
+
| v1.0 | May 2025 | Initial release - 4,710 training examples |
|
| 282 |
|
| 283 |
+
---
|
|
|
|
| 284 |
|
| 285 |
+
**Last Updated**: May 9, 2025
|
| 286 |
+
**Model Version**: 1.0
|
| 287 |
+
**Status**: ✅ Production Ready
|