--- 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.)*