Uma Arquitetura de RAG com Busca Semântica e Filtros Estruturados para Perguntas e Respostas no Domínio Jurídico
Resumo
Sistemas de busca jurídica enfrentam desafios com dados heterogêneos e consultas complexas que mesclam texto e metadados. Apresentamos um framework de RAG híbrido composto por um pipeline de indexação otimizado e um orquestrador de recuperação. A indexação emprega saneamento textual, segmentação ancorada e enriquecimento com pré-contexto, enquanto a recuperação utiliza expansão multi-consulta e uma busca que combina filtros de metadados com busca vetorial, incluindo um fallback para garantir a cobertura. Nossos experimentos mostram que a otimização dos chunks reduziu o custo de tokens em 66,8% e, simultaneamente, aumentou o Recall@10 em 181,1%. Adicionalmente, a busca híbrida com filtros melhorou o MRR@10 em 27,5% e reduziu a latência em 24,1%, demonstrando ganhos sinérgicos em custo, acurácia e velocidade.
Palavras-chave:
RAG, Domínio Jurídico, Busca Híbrida, Filtros Estruturados, Perguntas e Respostas
Referências
Carpineto, C. and Romano, G. (2012). A survey of automatic query expansion in information retrieval. ACM Computing Surveys, 44(1).
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 (ACL).
Chalkidis, I., Kamateri, E., Lazaridou, K., Aletras, N., Katakalou, M., and Krithara, A. (2020). LEGAL-BERT: The Muppets straight out of Law School. In Findings of the Association for Computational Linguistics: EMNLP 2020, pages 2898–2904.
Gao, Y., Xiong, Y., Gao, X., Jia, K., Pan, J., Bi, Y., Dai, Y., Sun, J., Wang, M., and Wang, H. (2024). Retrieval-augmented generation for large language models: A survey. arXiv preprint arXiv:2312.10997.
Gururangan, S., Marasović, A., Swayamdipta, S., Lo, K., Beltagy, I., Downey, D., and Smith, N. A. (2020). Don’t stop pretraining: Adapt language models to domains and tasks. In Proceedings of ACL.
Hearst, M. A. (2009). Search User Interfaces. Cambridge University Press.
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 (TMLR).
Karpukhin, V., Oguz, B., Min, S., Lewis, P., Wu, L., Edunov, S., Chen, D., and Yih, W. (2020). Dense passage retrieval for open-domain question answering. In Proceedings of EMNLP.
Khattab, O. and Zaharia, M. (2020). ColBERT: Efficient and effective passage search via contextualized late interaction over BERT. In Proceedings of SIGIR.
Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., Küttler, H., Ott, M., tau Chen, W., Conneau, A., and others (2020). Retrieval-augmented generation for knowledge-intensive NLP. In Advances in Neural Information Processing Systems (NeurIPS).
Li, Z., Wang, J., Jiang, Z., Mao, H., Chen, Z., Du, J., Zhang, Y., Zhang, F., Zhang, D., and Liu, Y. (2024). Dmqr-rag: Diverse multi-query rewriting for retrieval-augmented generation. arXiv preprint arXiv:2411.13154.
Liu, N. F., Lin, K., Hewitt, J., Paranjape, A., Bevilacqua, M., Petroni, F., and Liang, P. (2024). Lost in the middle: How language models use long contexts. Transactions of the Association for Computational Linguistics, 12:157–173.
Manning, C. D., Raghavan, P., and Schütze, H. (2008). Introduction to Information Retrieval. Cambridge University Press.
Reimers, N. and Gurevych, I. (2019). Sentence-BERT: Sentence embeddings using siamese BERT-networks. In Proceedings of EMNLP-IJCNLP.
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 (ACL).
Chalkidis, I., Kamateri, E., Lazaridou, K., Aletras, N., Katakalou, M., and Krithara, A. (2020). LEGAL-BERT: The Muppets straight out of Law School. In Findings of the Association for Computational Linguistics: EMNLP 2020, pages 2898–2904.
Gao, Y., Xiong, Y., Gao, X., Jia, K., Pan, J., Bi, Y., Dai, Y., Sun, J., Wang, M., and Wang, H. (2024). Retrieval-augmented generation for large language models: A survey. arXiv preprint arXiv:2312.10997.
Gururangan, S., Marasović, A., Swayamdipta, S., Lo, K., Beltagy, I., Downey, D., and Smith, N. A. (2020). Don’t stop pretraining: Adapt language models to domains and tasks. In Proceedings of ACL.
Hearst, M. A. (2009). Search User Interfaces. Cambridge University Press.
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 (TMLR).
Karpukhin, V., Oguz, B., Min, S., Lewis, P., Wu, L., Edunov, S., Chen, D., and Yih, W. (2020). Dense passage retrieval for open-domain question answering. In Proceedings of EMNLP.
Khattab, O. and Zaharia, M. (2020). ColBERT: Efficient and effective passage search via contextualized late interaction over BERT. In Proceedings of SIGIR.
Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., Küttler, H., Ott, M., tau Chen, W., Conneau, A., and others (2020). Retrieval-augmented generation for knowledge-intensive NLP. In Advances in Neural Information Processing Systems (NeurIPS).
Li, Z., Wang, J., Jiang, Z., Mao, H., Chen, Z., Du, J., Zhang, Y., Zhang, F., Zhang, D., and Liu, Y. (2024). Dmqr-rag: Diverse multi-query rewriting for retrieval-augmented generation. arXiv preprint arXiv:2411.13154.
Liu, N. F., Lin, K., Hewitt, J., Paranjape, A., Bevilacqua, M., Petroni, F., and Liang, P. (2024). Lost in the middle: How language models use long contexts. Transactions of the Association for Computational Linguistics, 12:157–173.
Manning, C. D., Raghavan, P., and Schütze, H. (2008). Introduction to Information Retrieval. Cambridge University Press.
Reimers, N. and Gurevych, I. (2019). Sentence-BERT: Sentence embeddings using siamese BERT-networks. In Proceedings of EMNLP-IJCNLP.
Publicado
04/12/2025
Como Citar
BRAKES, Matheus F. C.; FERREIRA, David O. C.; SILVA, Josiel P. C.; NOVAIS, Artur M. A.; PRESA, João P. C.; OLIVEIRA, Sávio S. T. de.
Uma Arquitetura de RAG com Busca Semântica e Filtros Estruturados para Perguntas e Respostas no Domínio Jurídico. In: ESCOLA REGIONAL DE INFORMÁTICA DE GOIÁS (ERI-GO), 13. , 2025, Luziânia/GO.
Anais [...].
Porto Alegre: Sociedade Brasileira de Computação,
2025
.
p. 292-301.
DOI: https://doi.org/10.5753/erigo.2025.17152.
