KBchat: An approach to intelligent knowledge base querying
DOI:
https://doi.org/10.5753/reic.2026.6742Keywords:
RAG, LLM, Embeddings, Chatbot, Knowledge BaseAbstract
With the advancement of natural language processing technologies, this work proposes the development of a chat system based on the Retrieval-Augmented Generation (RAG) approach, designed for querying knowledge bases created from PDF documents. The system operates with two main workflows. The first workflow is responsible for ingesting documents into the knowledge base: PDF files are processed using the Markitdown library, converted to markdown, segmented into passages, and transformed into embeddings using the all-mpnet-base-v2 model. These vectors are then stored in a PostgreSQL vector database with the pgvector extension. The second workflow represents the chat interaction, where the user queries the knowledge base: upon receiving a question, the system generates its embedding, applies preprocessing, performs a vector search for the most relevant passages, and constructs a contextualized prompt, which is sent to the Gemini-2.0-Flash-001 model to generate the response. The application was developed using Python and Flask for the backend, and React for the frontend, integrating contemporary techniques in NLP and generative AI. The results demonstrate the feasibility of the system for efficient and contextualized queries on large volumes of text, with potential applications in corporate, educational, legal, and other domains.
Downloads
References
Aquino, I. V. d., dos Santos, M. M., Dorneles, C. F., and Carvalho, J. T. (2024). Extracting information from brazilian legal documents with retrieval augmented generation. In Proceedings of the 39th Workshop on Data Science Against Corruption in the Public Sector (DS-COPS) - Simpósio Brasileiro de Banco de Dados (SBBD), pages 280–287, Florianópolis, SC, Brazil. Sociedade Brasileira de Computação. DOI: 10.5753/sbbd_estendido.2024.244241.
Brown, T., Mann, B., Ryder, N., Subbiah, M., Kaplan, J. D., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., et al. (2020). Language models are few-shot learners. In Advances in neural information processing systems, volume 33, pages 1877–1901. Disponível em: [link]. Acesso em: 22 jul. 2026.
Chan, C., Xu, C., Yuan, R., Luo, H., Xue, W., Guo, Y., and Fu, J. (2024). RQ-RAG: Learning to refine queries for retrieval-augmented generation. In Conference on Language Modeling (COLM 2024). Disponível em: [link]. Acesso em: 22 jul. 2026.
Datalab-to (2025). Marker: Convert pdf to markdown json quickly with high accuracy. Disponível em: [link]. Acesso em: 22 jul. 2026.
Es, S., James, J., Anke, L. E., and Schockaert, S. (2024). Ragas: Automated evaluation of retrieval augmented generation. In Proceedings of the 18th Conference of the European Chapter of the Association for Computational Linguistics: System Demonstrations (EACL), pages 150–158. DOI: 10.18653/v1/2024.eacl-demo.16.
Evans, M. (2025). Vite: A next generation frontend tooling. Disponível em: [link]. Acesso em: 22 jul. 2026.
Flask Project (2025). Flask. Disponível em: [link]. Acesso em: 22 jul. 2026.
Google (2025). Gemini 2.0 flash. Disponível em: [link]. Acesso em: 22 jul. 2026.
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 Webber, B., Cohn, T., He, Y., and Liu, Y., editors, Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 6769–6781, Online. Association for Computational Linguistics. DOI: 10.18653/v1/2020.emnlp-main.550.
Khattab, O. and Zaharia, M. (2020). Colbert: Efficient and effective passage search via contextualized late interaction over bert. In Proceedings of the 43rd International ACM SIGIR Conference on Research and Development in Information Retrieval, SIGIR ’20, page 39–48, New York, NY, USA. Association for Computing Machinery. DOI: 10.1145/3397271.3401075.
Kuratomi, G., Pirozelli, P., Cozman, F. G., and Peres, S. M. (2024). A rag-based institutional assistant. In Proceedings of the 21st Encontro Nacional de Inteligência Artificial e Computacional (ENIAC), pages 755–766, Belém, PA, Brazil. Sociedade Brasileira de Computação. DOI: 10.5753/eniac.2024.245243.
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 Proceedings of the 34th International Conference on Neural Information Processing Systems, NIPS ’20, Red Hook, NY, USA. Curran Associates Inc. Disponível em: [link]. Acesso em: 22 jul. 2026.
Martins, A. (2025). Tailwindcss: Estilos utilitários para um design eficiente. Disponível em: [link]. Acesso em: 22 jul. 2026.
Microsoft (2025). Markitdown. Disponível em: [link]. Acesso em: 22 jul. 2026.
pgvector (2025). pgvector. Disponível em: [link]. Acesso em: 22 jul. 2026.
React (2025). Aprenda react. Disponível em: [link]. Acesso em: 22 jul. 2026.
Robertson, S. E. and Zaragoza, H. (2009). The Probabilistic Relevance Framework: BM25 and Beyond, volume 3, pages 333–389. Now Publishers. DOI: 10.1561/1500000019.
Song, K., Tan, X., Qin, T., Lu, J., and Liu, T.-Y. (2020). Mpnet: Masked and permuted pre-training for language understanding. Advances in neural information processing systems, 33:16857–16867. Disponível em: [link]. Acesso em: 22 jul. 2026.
Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L., and Polosukhin, I. (2017). Attention is all you need. In Proceedings of the 31st International Conference on Neural Information Processing Systems, NIPS’17, page 6000–6010, Red Hook, NY, USA. Curran Associates Inc. Disponível em: [link]. Acesso em: 22 jul. 2026.
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2026 The authors

This work is licensed under a Creative Commons Attribution 4.0 International License.
