Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,60 +1,149 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
|
|
|
| 5 |
tags:
|
| 6 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
- lora
|
| 8 |
-
|
|
|
|
| 9 |
pipeline_tag: text-generation
|
| 10 |
-
|
| 11 |
-
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
---
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
|
|
|
| 25 |
|
| 26 |
-
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
- lr_scheduler_type: linear
|
| 47 |
-
- lr_scheduler_warmup_steps: 100
|
| 48 |
-
- num_epochs: 3
|
| 49 |
|
| 50 |
-
|
|
|
|
|
|
|
| 51 |
|
|
|
|
| 52 |
|
|
|
|
| 53 |
|
| 54 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
-
- Transformers 4.57.3
|
| 58 |
-
- Pytorch 2.9.0+cu126
|
| 59 |
-
- Datasets 4.0.0
|
| 60 |
-
- Tokenizers 0.22.2
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
library_name: transformers
|
| 6 |
tags:
|
| 7 |
+
- legal
|
| 8 |
+
- immigration
|
| 9 |
+
- assistant
|
| 10 |
+
- qwen2
|
| 11 |
+
- qwen2.5
|
| 12 |
+
- fine-tuned
|
| 13 |
- lora
|
| 14 |
+
base_model: Qwen/Qwen2.5-3B-Instruct
|
| 15 |
+
model_type: qwen2
|
| 16 |
pipeline_tag: text-generation
|
| 17 |
+
widget:
|
| 18 |
+
- text: "What is an H-1B visa?"
|
| 19 |
+
example_title: "H-1B Visa Question"
|
| 20 |
+
- text: "How do I apply for a green card?"
|
| 21 |
+
example_title: "Green Card Process"
|
| 22 |
+
- text: "What documents do I need for an O-1 visa?"
|
| 23 |
+
example_title: "O-1 Visa Requirements"
|
| 24 |
+
datasets:
|
| 25 |
+
- busybisi/dolores-training-data
|
| 26 |
---
|
| 27 |
|
| 28 |
+
# Dolores AI - Immigration Case Manager (Qwen 2.5 LoRA)
|
| 29 |
+
|
| 30 |
+
Dolores is a specialized AI Immigration Case Manager fine-tuned using LoRA (Low-Rank Adaptation) on Qwen 2.5-3B-Instruct. Her mission is to de-mystify the complex immigration journey, breaking it down into manageable, actionable steps with high empathy and precision.
|
| 31 |
+
|
| 32 |
+
## Model Details
|
| 33 |
+
|
| 34 |
+
- **Base Model**: [Qwen/Qwen2.5-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-3B-Instruct)
|
| 35 |
+
- **Fine-tuning Method**: LoRA (Low-Rank Adaptation)
|
| 36 |
+
- **LoRA Rank**: 16
|
| 37 |
+
- **LoRA Alpha**: 32
|
| 38 |
+
- **Training Data**: Immigration law documents, case examples, and expert guidance
|
| 39 |
+
- **Use Case**: Immigration consultation, visa guidance, document preparation
|
| 40 |
+
- **Model Size**: ~3B parameters (LoRA adapter only)
|
| 41 |
+
|
| 42 |
+
## Training Details
|
| 43 |
+
|
| 44 |
+
### Training Configuration
|
| 45 |
+
- **Epochs**: 3
|
| 46 |
+
- **Batch Size**: 4 (effective: 16 with gradient accumulation)
|
| 47 |
+
- **Learning Rate**: 2e-4
|
| 48 |
+
- **Quantization**: 4-bit (QLoRA) during training
|
| 49 |
+
- **Max Sequence Length**: 2048 tokens
|
| 50 |
+
- **Target Modules**: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
|
| 51 |
+
|
| 52 |
+
### Training Data
|
| 53 |
+
Fine-tuned on curated immigration law datasets including:
|
| 54 |
+
- U.S. immigration policies and procedures
|
| 55 |
+
- Visa types and requirements (H-1B, O-1, EB-1, etc.)
|
| 56 |
+
- Green card processes
|
| 57 |
+
- Case examples and expert guidance
|
| 58 |
+
- Document preparation instructions
|
| 59 |
+
|
| 60 |
+
## Usage
|
| 61 |
+
|
| 62 |
+
This is a **LoRA adapter** that needs to be loaded with the base model. For production use, see the merged version: [JustiGuide/DoloresAI-Qwen25-Merged](https://huggingface.co/JustiGuide/DoloresAI-Qwen25-Merged)
|
| 63 |
+
|
| 64 |
+
### Loading the LoRA Adapter
|
| 65 |
|
| 66 |
+
```python
|
| 67 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 68 |
+
from peft import PeftModel
|
| 69 |
+
import torch
|
| 70 |
|
| 71 |
+
base_model_id = "Qwen/Qwen2.5-3B-Instruct"
|
| 72 |
+
lora_adapter_id = "JustiGuide/DoloresAI-Qwen25"
|
| 73 |
|
| 74 |
+
# Load base model
|
| 75 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 76 |
+
base_model_id,
|
| 77 |
+
torch_dtype=torch.bfloat16,
|
| 78 |
+
device_map="auto"
|
| 79 |
+
)
|
| 80 |
|
| 81 |
+
# Load LoRA adapter
|
| 82 |
+
model = PeftModel.from_pretrained(model, lora_adapter_id)
|
| 83 |
|
| 84 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
|
| 85 |
+
```
|
| 86 |
|
| 87 |
+
### Inference Example
|
| 88 |
|
| 89 |
+
```python
|
| 90 |
+
system_prompt = "You are Dolores, a specialized AI Immigration Case Manager."
|
| 91 |
|
| 92 |
+
question = "What is an H-1B visa and who qualifies for it?"
|
| 93 |
|
| 94 |
+
prompt = f'''<|im_start|>system
|
| 95 |
+
{system_prompt}<|im_end|>
|
| 96 |
+
<|im_start|>user
|
| 97 |
+
{question}<|im_end|>
|
| 98 |
+
<|im_start|>assistant
|
| 99 |
+
'''
|
| 100 |
|
| 101 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 102 |
|
| 103 |
+
outputs = model.generate(
|
| 104 |
+
**inputs,
|
| 105 |
+
max_new_tokens=512,
|
| 106 |
+
temperature=0.7,
|
| 107 |
+
top_p=0.9,
|
| 108 |
+
do_sample=True,
|
| 109 |
+
repetition_penalty=1.1,
|
| 110 |
+
)
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 113 |
+
print(response)
|
| 114 |
+
```
|
| 115 |
|
| 116 |
+
## Deployment
|
| 117 |
|
| 118 |
+
For production deployment, use the merged model: [JustiGuide/DoloresAI-Qwen25-Merged](https://huggingface.co/JustiGuide/DoloresAI-Qwen25-Merged)
|
| 119 |
|
| 120 |
+
### HuggingFace Inference Endpoint
|
| 121 |
+
- GPU: Nvidia L4 (24GB VRAM)
|
| 122 |
+
- Scale to Zero: Enabled
|
| 123 |
+
- Region: us-east-1
|
| 124 |
+
|
| 125 |
+
## Performance
|
| 126 |
+
|
| 127 |
+
- **Inference Speed**: ~10-20 tokens/second (on L4 GPU)
|
| 128 |
+
- **Context Length**: Up to 2048 tokens
|
| 129 |
+
- **Quality**: High accuracy on immigration-specific questions
|
| 130 |
+
|
| 131 |
+
## Limitations
|
| 132 |
+
|
| 133 |
+
- Provides general immigration guidance, **not legal advice**
|
| 134 |
+
- Always consult with a licensed immigration attorney for specific cases
|
| 135 |
+
- Trained primarily on U.S. immigration law
|
| 136 |
+
- May not have information on very recent policy changes
|
| 137 |
+
|
| 138 |
+
## License
|
| 139 |
+
|
| 140 |
+
Apache 2.0 License (following base model's license)
|
| 141 |
+
|
| 142 |
+
## Contact
|
| 143 |
+
|
| 144 |
+
- **Organization**: JustiGuide
|
| 145 |
+
- **Website**: https://justi.guide
|
| 146 |
+
|
| 147 |
+
---
|
| 148 |
|
| 149 |
+
**Built with ❤️ by JustiGuide to make immigration more accessible**
|
|
|
|
|
|
|
|
|
|
|
|