Hybrid Legal Precedent Retrieval via LLM-Based Document Expansion and Dense-Sparse Fusion
Resumo
Precedent retrieval in the Brazilian legal domain faces severe vocabulary mismatch between narrative queries and technical court decisions. This work investigates the Hypothetical Document Embeddings (HyDE) framework, a zero-shot semantic expansion approach, on legal search. We built a benchmark comprising structured appellate decisions from the State Court of Mato Grosso do Sul (TJMS), modeling narrative syllabi sections as queries and legal theses as targets. We evaluate HyDE, its hybridization with BM25 via Reciprocal Rank Fusion (RRF), and query granularity using the google/ gemma-3-12b-it model. Experiments demonstrate that HyDE outperforms dense retrieval, quadrupling Recall@1 (from 0.086 to 0.345) and boosting MRR from 0.131 to 0.427 (p < 0.001). Furthermore, hybrid fusion (HyDE + BM25) reaches an MRR of 0.571, achieving statistical equivalence to pure lexical search (MRR = 0.574). Query granularity analysis indicates that medium-length queries (combining facts and legal controversy) represent the optimal operational point, maximizing precision without redundant overhead. Ultimately, the hybrid architecture emerges as a robust real-world solution, proving the viability of Large Language Models (LLMs) in modernizing specialized legal research.
Palavras-chave:
Legal Precedent Retrieval, Large Language Models, Generative Document Expansion, Dense-Sparse Fusion, HyDE
Referências
Ariai, F., Mackenzie, J., and Demartini, G. (2025). Natural language processing for the legal domain: A survey of tasks, datasets, models, and challenges. ACM Computing Surveys, 58(6):1–37.
Bueno, T. C. D., von Wangenheim, C. G., de Silva Mattos, E., Hoeschl, H. C., and Barcia, R. M. (1999). Juris Consulto: Retrieval in jurisprudencial text bases using juridical terminology. In Proceedings of the 7th International Conference on Artificial Intelligence and Law (ICAIL 1999), pages 147–155, Oslo, Norway. ACM.
Carpineto, C. and Romano, G. (2012). A survey of automatic query expansion in information retrieval. ACM Computing Surveys, 44(1):1–50.
Chalkidis, I., Fergadiotis, M., Malakasiotis, P., Aletras, N., and Androutsopoulos, I. (2020). LEGAL-BERT: The muppets straight out of law school. In Findings of the Association for Computational Linguistics: EMNLP 2020, pages 2898–2904. Association for Computational Linguistics.
Chalkidis, I., Jana, A., Hartung, D., Bommarito, M., Androutsopoulos, I., Katz, D. M., and Aletras, N. (2022). LexGLUE: A benchmark dataset for legal language understanding in English. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 4310–4330. Association for Computational Linguistics.
Conselho Nacional de Justiça (2024). Justiça em números 2024: ano-base 2023. Technical report, Conselho Nacional de Justiça (CNJ), Brasília, DF.
Cormack, G. V., Clarke, C. L. A., and Buettcher, S. (2009). Reciprocal rank fusion outperforms Condorcet and individual rank learning methods. In Proceedings of the 32nd International ACM SIGIR Conference on Research and Development in Information Retrieval, pages 758–759, Boston, Massachusetts, USA. ACM.
Fernandes, L. C., Ribeiro, L. d. S., de Castro, M. V. B., Pacheco, L. A. d. S., and Sandes, E. F. d. O. (2026). JurisTCU: A Brazilian Portuguese information retrieval dataset with query relevance judgments. Language Resources and Evaluation, 60(1):23.
Gao, L., Ma, X., Lin, J., and Callan, J. (2023). Precise zero-shot dense retrieval without relevance labels. In Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1762–1777. Association for Computational Linguistics.
Gemma Team, Mesnard, T., Hardin, C., Dadashi, R., Bhupatiraju, S., Pathak, S., Sifre, L., Rivière, M., Kale, M. S., Love, J., et al. (2024). Gemma: Open models based on Gemini research and technology. arXiv preprint arXiv:2403.08295.
Izacard, G., Caron, M., Hosseini, L., Riedel, S., Bojanowski, P., Joulin, A., and Grave, E. (2022). Unsupervised dense information retrieval with contrastive learning. Transactions on Machine Learning Research.
Johnson, J., Douze, M., and Jégou, H. (2019). Billion-scale similarity search with GPUs. IEEE Transactions on Big Data, 7(3):535–547.
Karpukhin, V., Oguz, B., Min, S., Lewis, P., Wu, L., Edunov, S., Chen, D., and Yih, W.-t. (2020). Dense passage retrieval for open-domain question answering. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 6769–6781. Association for Computational Linguistics.
Lai, J., Gan, W., Wu, J., Qi, Z., and Yu, P. S. (2024). Large language models in law: A survey. AI Open, 5:181–196.
Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., Küttler, H., Lewis, M., Yih, W.-t., Rocktäschel, T., Riedel, S., and Kiela, D. (2020). Retrieval-augmented generation for knowledge-intensive NLP tasks. In Advances in Neural Information Processing Systems (NeurIPS 2020), volume 33, pages 9459–9474, Vancouver, Canada.
Lin, J., Nogueira, R., and Yates, A. (2022). Pretrained transformers for text ranking: BERT and beyond. Springer Nature.
Luz de Araujo, P. H., de Campos, T. E., Braz, F. A., and da Silva, N. C. (2020). VICTOR: A dataset for Brazilian legal documents classification. In Proceedings of the 12th Language Resources and Evaluation Conference (LREC 2020), pages 1449–1458, Marseille, France. European Language Resources Association (ELRA).
Oliveira, L. S., de Castro, F. F., and Rocha, E. S. S. (2024). Recuperação da informação jurídica: um mapeamento sistemático. In Anais do XXIV Encontro Nacional de Pesquisa e Pós-Graduação em Ciência da Informação (ENANCIB), pages 1–19, Vitória, ES. ANCIB.
Rabelo, J., Goebel, R., Kim, M.-Y., Kano, Y., Yoshioka, M., and Satoh, K. (2022). Overview and discussion of the competition on legal information extraction/entailment (COLIEE) 2021. The Review of Socionetwork Strategies, 16(1):111–133.
Reimers, N. and Gurevych, I. (2019). Sentence-BERT: Sentence embeddings using Siamese BERT-networks. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pages 3982–3992, Hong Kong, China. Association for Computational Linguistics.
Robertson, S. and Zaragoza, H. (2009). The probabilistic relevance framework: BM25 and beyond. Foundations and Trends in Information Retrieval, 3(4):333–389.
Wang, L., Yang, N., Huang, X., Jiao, B., Yang, L., Jiang, D., Majumder, R., and Wei, F. (2022). Text embeddings by weakly-supervised contrastive pre-training. arXiv preprint arXiv:2212.03533.
Bueno, T. C. D., von Wangenheim, C. G., de Silva Mattos, E., Hoeschl, H. C., and Barcia, R. M. (1999). Juris Consulto: Retrieval in jurisprudencial text bases using juridical terminology. In Proceedings of the 7th International Conference on Artificial Intelligence and Law (ICAIL 1999), pages 147–155, Oslo, Norway. ACM.
Carpineto, C. and Romano, G. (2012). A survey of automatic query expansion in information retrieval. ACM Computing Surveys, 44(1):1–50.
Chalkidis, I., Fergadiotis, M., Malakasiotis, P., Aletras, N., and Androutsopoulos, I. (2020). LEGAL-BERT: The muppets straight out of law school. In Findings of the Association for Computational Linguistics: EMNLP 2020, pages 2898–2904. Association for Computational Linguistics.
Chalkidis, I., Jana, A., Hartung, D., Bommarito, M., Androutsopoulos, I., Katz, D. M., and Aletras, N. (2022). LexGLUE: A benchmark dataset for legal language understanding in English. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 4310–4330. Association for Computational Linguistics.
Conselho Nacional de Justiça (2024). Justiça em números 2024: ano-base 2023. Technical report, Conselho Nacional de Justiça (CNJ), Brasília, DF.
Cormack, G. V., Clarke, C. L. A., and Buettcher, S. (2009). Reciprocal rank fusion outperforms Condorcet and individual rank learning methods. In Proceedings of the 32nd International ACM SIGIR Conference on Research and Development in Information Retrieval, pages 758–759, Boston, Massachusetts, USA. ACM.
Fernandes, L. C., Ribeiro, L. d. S., de Castro, M. V. B., Pacheco, L. A. d. S., and Sandes, E. F. d. O. (2026). JurisTCU: A Brazilian Portuguese information retrieval dataset with query relevance judgments. Language Resources and Evaluation, 60(1):23.
Gao, L., Ma, X., Lin, J., and Callan, J. (2023). Precise zero-shot dense retrieval without relevance labels. In Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1762–1777. Association for Computational Linguistics.
Gemma Team, Mesnard, T., Hardin, C., Dadashi, R., Bhupatiraju, S., Pathak, S., Sifre, L., Rivière, M., Kale, M. S., Love, J., et al. (2024). Gemma: Open models based on Gemini research and technology. arXiv preprint arXiv:2403.08295.
Izacard, G., Caron, M., Hosseini, L., Riedel, S., Bojanowski, P., Joulin, A., and Grave, E. (2022). Unsupervised dense information retrieval with contrastive learning. Transactions on Machine Learning Research.
Johnson, J., Douze, M., and Jégou, H. (2019). Billion-scale similarity search with GPUs. IEEE Transactions on Big Data, 7(3):535–547.
Karpukhin, V., Oguz, B., Min, S., Lewis, P., Wu, L., Edunov, S., Chen, D., and Yih, W.-t. (2020). Dense passage retrieval for open-domain question answering. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 6769–6781. Association for Computational Linguistics.
Lai, J., Gan, W., Wu, J., Qi, Z., and Yu, P. S. (2024). Large language models in law: A survey. AI Open, 5:181–196.
Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., Küttler, H., Lewis, M., Yih, W.-t., Rocktäschel, T., Riedel, S., and Kiela, D. (2020). Retrieval-augmented generation for knowledge-intensive NLP tasks. In Advances in Neural Information Processing Systems (NeurIPS 2020), volume 33, pages 9459–9474, Vancouver, Canada.
Lin, J., Nogueira, R., and Yates, A. (2022). Pretrained transformers for text ranking: BERT and beyond. Springer Nature.
Luz de Araujo, P. H., de Campos, T. E., Braz, F. A., and da Silva, N. C. (2020). VICTOR: A dataset for Brazilian legal documents classification. In Proceedings of the 12th Language Resources and Evaluation Conference (LREC 2020), pages 1449–1458, Marseille, France. European Language Resources Association (ELRA).
Oliveira, L. S., de Castro, F. F., and Rocha, E. S. S. (2024). Recuperação da informação jurídica: um mapeamento sistemático. In Anais do XXIV Encontro Nacional de Pesquisa e Pós-Graduação em Ciência da Informação (ENANCIB), pages 1–19, Vitória, ES. ANCIB.
Rabelo, J., Goebel, R., Kim, M.-Y., Kano, Y., Yoshioka, M., and Satoh, K. (2022). Overview and discussion of the competition on legal information extraction/entailment (COLIEE) 2021. The Review of Socionetwork Strategies, 16(1):111–133.
Reimers, N. and Gurevych, I. (2019). Sentence-BERT: Sentence embeddings using Siamese BERT-networks. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pages 3982–3992, Hong Kong, China. Association for Computational Linguistics.
Robertson, S. and Zaragoza, H. (2009). The probabilistic relevance framework: BM25 and beyond. Foundations and Trends in Information Retrieval, 3(4):333–389.
Wang, L., Yang, N., Huang, X., Jiao, B., Yang, L., Jiang, D., Majumder, R., and Wei, F. (2022). Text embeddings by weakly-supervised contrastive pre-training. arXiv preprint arXiv:2212.03533.
Publicado
19/10/2026
Como Citar
SANTANA, Otávio Gabriel de Oliveira; COSTA, Anderson Bessa da; MATSUBARA, Edson Takashi.
Hybrid Legal Precedent Retrieval via LLM-Based Document Expansion and Dense-Sparse Fusion. In: ENCONTRO NACIONAL DE INTELIGÊNCIA ARTIFICIAL E COMPUTACIONAL (ENIAC), 23. , 2026, Cuiabá/MT.
Anais [...].
Porto Alegre: Sociedade Brasileira de Computação,
2026
.
p. 2895-2906.
ISSN 2763-9061.
DOI: https://doi.org/10.5753/eniac.2026.30860.
