Domain-Adaptive Dense Retrieval for Brazilian Legal Search
Legal-only vs. mixed fine-tuning: trade-offs in Brazilian legal retrieval
Jayr Pereira, Roberto Lotufo, and Luiz Bonifacio explored how to train dense retrievers for heterogeneous Brazilian legal search, which spans case law, legislation, and question-based queries. Using Qwen3-Embedding-4B as the base model, they tested three setups: no fine-tuning, legal-only fine-tuning, and a mixed setup combining legal data with the SQuAD-pt Portuguese supervised dataset. Evaluation on five datasets from the JUÁ leaderboard and the Quati Portuguese retrieval benchmark revealed clear trade-offs.
The legal-only model aces specialized legal tasks, but the mixed setup delivers the best overall balance. It improved average NDCG@10 from 0.414 to 0.447, MRR@10 from 0.586 to 0.595, and MAP@10 from 0.270 to 0.308 across all six datasets. The biggest gains came on Quati (out-of-domain question answering), where the mixed model clearly outperforms the legal-only version. The authors conclude legal-only specializes, while mixed training is more robust—especially for question-based queries. Both adapted models are available on Hugging Face.
- Based on Qwen3-Embedding-4B with three training regimes: base, legal-only, mixed (legal + SQuAD-pt).
- Mixed setup boosts average NDCG@10 from 0.414 to 0.447, MRR@10 from 0.586 to 0.595, MAP@10 from 0.270 to 0.308.
- Legal-only excels at specialized legal tasks; mixed is better for general robustness and question-based search.
Why It Matters
Better legal search in Brazil means faster case law and legislation retrieval for professionals, with open-source models.