| --- |
| library_name: transformers |
| tags: |
| - legal |
| - philippine-law |
| - tagalog |
| - filipino |
| - barangay |
| - qwen2 |
| - lora |
| - fine-tuned |
| language: |
| - en |
| - tl |
| license: apache-2.0 |
| base_model: Qwen/Qwen2.5-3B-Instruct |
| pipeline_tag: text-generation |
| --- |
| |
| # βοΈ Abogado β Open Source Philippine Law AI |
|
|
| **Abogado** (Filipino for "Lawyer") is an open-source AI assistant fine-tuned to help Filipinos understand Philippine law. It is specifically designed for **barangay officials, local councilors, mediators**, and ordinary citizens who need accessible legal information. |
|
|
| > **β οΈ Disclaimer:** Abogado is NOT a lawyer. It provides legal information for educational purposes only. Always consult a licensed Philippine attorney for actual legal advice. For free legal assistance, contact the Public Attorney's Office (PAO) or IBP legal aid. |
|
|
| ## Why Abogado? |
|
|
| - Most AI models are trained on US/UK law and perform poorly on Philippine law |
| - Millions of barangay officials handle legal disputes daily without formal legal training |
| - Access to legal information in the Philippines is expensive and inaccessible for many |
| - Abogado aims to democratize legal knowledge for every Filipino |
|
|
| ## Model Details |
|
|
| - **Base Model:** Qwen/Qwen2.5-3B-Instruct |
| - **Method:** QLoRA fine-tuning (4-bit quantization, LoRA rank 16) |
| - **Training Data:** 106 Q&A pairs from the 1987 Philippine Constitution |
| - **Languages:** English and Filipino/Tagalog |
| - **License:** Apache 2.0 (fully open source) |
| - **Hardware:** Kaggle T4 GPU |
|
|
| ## What It Knows |
|
|
| Currently trained on: |
| - β
1987 Philippine Constitution (all 18 Articles) |
| - β
Bill of Rights practical applications |
| - β
Katarungang Pambarangay (Barangay Justice System) |
| - β
VAWC (RA 9262) basics and Barangay Protection Orders |
| - β
Local government structure and powers |
| - β
Rights of arrested persons |
| - β
Safety behaviors (refuses private data, recommends real lawyers) |
|
|
| ### Planned future training data: |
| - π Local Government Code (RA 7160) |
| - π Revised Penal Code |
| - π Family Code |
| - π Labor Code |
| - π RA 9262 (VAWC) full text |
| - π RA 7610 (Child Protection) |
| - π Supreme Court jurisprudence |
| - π Rules on Summary Procedure |
|
|
| ## How to Use |
|
|
| ### With Transformers (Python) |
| ```python |
| from transformers import AutoModelForCausalLM, AutoTokenizer |
| |
| model = AutoModelForCausalLM.from_pretrained("YOUR_USERNAME/abogado") |
| tokenizer = AutoTokenizer.from_pretrained("YOUR_USERNAME/abogado") |
| |
| messages = [ |
| {"role": "system", "content": "You are Abogado, an open-source Philippine law assistant."}, |
| {"role": "user", "content": "Can a barangay captain issue a warrant of arrest?"}, |
| ] |
| |
| text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) |
| inputs = tokenizer(text, return_tensors="pt") |
| outputs = model.generate(**inputs, max_new_tokens=512) |
| print(tokenizer.decode(outputs[0], skip_special_tokens=True)) |
| ``` |
|
|
| ### With Ollama (Local/Docker) |
| ```bash |
| # Download the GGUF version and create a Modelfile, then: |
| ollama create abogado -f Modelfile |
| ollama run abogado "What is the Katarungang Pambarangay?" |
| ``` |
|
|
| ## Target Users |
|
|
| - ποΈ **Barangay Officials** β Captains, Kagawads, Lupon members handling disputes |
| - ποΈ **Local Councilors** β Municipal/city council members drafting ordinances |
| - π€ **Mediators** β Lupong Tagapamayapa members conducting conciliation |
| - π **Law Students** β For study and bar exam review |
| - π΅π **Filipino Citizens** β Anyone who wants to understand their rights |
|
|
| ## Safety Features |
|
|
| Abogado is trained to: |
| - β **Refuse** to review actual case documents or provide specific legal advice |
| - β οΈ **Warn** users when they share personal or confidential information |
| - β
**Redirect** users to licensed attorneys, PAO, or IBP legal aid |
| - π **Always include** a disclaimer that information is for educational purposes only |
|
|
| ## Limitations |
|
|
| - Currently trained only on the Philippine Constitution (106 Q&A pairs) |
| - May produce inaccurate or incomplete legal information |
| - Cannot replace professional legal advice |
| - Knowledge is limited to training data β does not have access to the latest laws or jurisprudence |
| - Performance will improve significantly as more training data is added |
|
|
| ## Contributing |
|
|
| Abogado is open source! You can help by: |
| 1. **Adding more training data** β Q&A pairs from other Philippine laws |
| 2. **Testing and reporting issues** β File issues on the repo |
| 3. **Translating** β Adding more Filipino/Tagalog Q&A pairs |
| 4. **Sharing** β Tell barangay officials, law students, and communities about Abogado |
|
|
| ## Training Details |
|
|
| - **Epochs:** 5 |
| - **Batch size:** 2 (with gradient accumulation of 4, effective batch size 8) |
| - **Learning rate:** 2e-4 |
| - **Optimizer:** AdamW 8-bit |
| - **Precision:** FP16 |
| - **LoRA rank:** 16 |
| - **LoRA alpha:** 16 |
| - **Target modules:** q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| |
| ## License |
| |
| Apache 2.0 β Use it freely, modify it, share it. Help make law accessible for every Filipino. |
| |
| ## Acknowledgments |
| |
| - Base model by [Qwen Team](https://huggingface.co/Qwen) |
| - Philippine Constitution text from the [Official Gazette](https://www.officialgazette.gov.ph) |
| - Built with [Hugging Face Transformers](https://huggingface.co/docs/transformers), [PEFT](https://huggingface.co/docs/peft), and [TRL](https://huggingface.co/docs/trl) |
| |
| --- |
| |
| *"Kaalaman sa batas, para sa lahat." (Legal knowledge, for everyone.)* |