Duże modele językowe (LLM) napotykają na ograniczenia związane z halucynacjami i brakiem dostępu do aktualnej wiedzy dziedzinowej. Architektura Retrieval-Augmented Generation (RAG) łączy wyszukiwanie informacji z generowaniem tekstu, umożliwiając dostęp do zewnętrznych baz wiedzy bez kosztownego ponownego trenowania. W niniejszej pracy został zademonstrowany wpływ architektury RAG na jakość odpowiedzi generowanych na podstawie polskich orzeczeń sądowych za pomocą metryk correctness oraz relevance (LLM as a Judge). Zbudowano system oparty na 150 tysiącach orzeczeń z bazy SAOS, przetworzonych do około 600 tysięcy chunków, z wykorzystaniem modelu text-embedding-3-small oraz GPT-5-mini. System zwalidowano na zbiorze 10 pytań testowych przy użyciu biblioteki RAGAS oraz techniki LLM-as-a-Judge z odpowiedziami referencyjnymi.
Wyniki wykazały dramatyczną poprawę jakości odpowiedzi dzięki RAG. Model bazowy bez RAG osiągnął średnią correctness 0.14 oraz relevance 0.18, podczas gdy system z RAG przy optymalnej konfiguracji uzyskał odpowiednio 0.89 i 0.85 — poprawa ponad sześciokrotna. Dla większości pytań faktograficznych model bez RAG zwracał wartości zerowe, podczas gdy system RAG konsekwentnie dostarczał precyzyjnych odpowiedzi z wysoką wiernością źródłom (faithfulness >0.8). Analiza ujawniła kluczowy wpływ liczby dokumentów, trafiających do modelu (k) na jakość odpowiedzi oraz konieczność stosowania dwóch komplementarnych metod ewaluacji.
Praca potwierdza, że architektura RAG stanowi wartościowe narzędzie do pracy z polskimi orzeczeniami sądowymi, a w szczególności wyraźnie poprawia jakość generowanych odpowiedzi w porównaniu z modelem bazowym pozbawionym dostępu do kontekstu. Podsumowanie wyników i możliwe kierunki rozwoju znajdują się na końcu pracy.
Large Language Models (LLMs) face inherent limitations related to hallucinations and the lack of access to up-to-date domain knowledge. The Retrieval-Augmented Generation (RAG) architecture mitigates these issues by combining information retrieval with text generation, enabling access to external knowledge bases without requiring costly retraining. This thesis demonstrates the impact of the RAG architecture on the quality of answers generated from Polish court rulings, evaluated using the correctness and relevance metrics within the LLM-as-a-Judge framework. The system was built on a corpus of 150,000 rulings from the SAOS database, processed into approximately 600,000 chunks using the text-embedding-3-small model and the GPT-5-mini generative model. The system was validated on a set of ten test questions using the RAGAS library and the LLM-as-a-Judge technique with reference answers.
The results showed a substantial improvement in answer quality due to the application of RAG. The baseline model without RAG achieved an average correctness score of 0.14 and a relevance score of 0.18, whereas the RAG-enabled system in its optimal configuration achieved scores of 0.89 and 0.85—representing more than a sixfold improvement. For most fact-based questions, the baseline model returned zero values, while the RAG system consistently provided precise answers with high faithfulness to the source documents (faithfulness > 0.8). The analysis revealed the critical influence of the number of retrieved documents passed to the model (parameter k) on answer quality, as well as the necessity of using two complementary evaluation methods.
This study confirms that the RAG architecture is a valuable tool for working with Polish court rulings and significantly improves the quality of generated answers compared to a baseline model without contextual retrieval. A summary of findings and potential directions for further development is presented at the end of the thesis.




