Skip to Content
ComputersComputers
  • Article
  • Open Access

25 August 2026

27 Pages

Building a Multilingual AI Legal Assistant Using Retrieval-Augmented Generation: A Case Study on the Legal System of Kazakhstan

,
,
,
,
and
1
School of Digital Technologies, Narxoz University, Almaty 050035, Kazakhstan
2
Institute of Automation and Information Technologies, Satbayev University, Almaty 050013, Kazakhstan
3
Department for Support of Scientific Projects and Postgraduate Education, Satbayev University, Almaty 050013, Kazakhstan
*
Author to whom correspondence should be addressed.

Abstract

This study presents the development of an Artificial Intelligence (AI)-based legal assistant using the Retrieval-Augmented Generation (RAG) architecture to provide legal assistance to citizens of the Republic of Kazakhstan. The proposed solution is designed to generate accurate, evidence-based responses to user queries using the regulatory legal acts of the Republic of Kazakhstan as the primary source of information. A legal corpus comprising 101,000 legislative documents and court decisions, with approximately 77 million tokens in Kazakh and Russian, was constructed to support the retrieval component of the system. To identify the most effective semantic retrieval method, three multilingual embedding models—Multilingual-E5-Large, BGE-M3, and KazEmbed-V5—were evaluated for vector search. The experimental results showed retrieval accuracies of 87.6%, 76.8%, and 83.3%, respectively. The GPT-5.4 and Llama-4-Scout-17B-16E-Instruct large language models were used to generate legal reasoning and responses based on documents retrieved through semantic search. The quality of the generated responses was evaluated using two complementary approaches. First, legal experts assessed the factual correctness and legal validity of the answers. Second, automatic evaluation was performed using word-level F1, BLEU, ROUGE, and BERTScore-F1 metrics. Among all evaluated configurations, GPT-5.4 combined with Multilingual-E5-Large achieved the highest overall accuracy (88.5%), whereas Llama-4-Scout-17B-16E-Instruct combined with KazEmbed-V5 achieved an accuracy of 83.6%. Based on the proposed architecture and the selected semantic retrieval and language models, an AI legal assistant was developed and integrated into the “Adal Azamat” legal services platform providing users in Kazakhstan with practical access to AI-assisted legal consultation.

1. Introduction

The widespread use of digital technologies in the legal domain has led to a rapid increase in the volume of legal data. The overwhelming amount of digitized legal information means that, in many jurisdictions, citizens face significant challenges in understanding and navigating complex legislative and regulatory documents because of their length, hierarchical structure, and frequent amendment. As a result, both legal professionals and the general public increasingly rely on automated tools to access, interpret, and use legal information efficiently. However, traditional keyword-based legal information retrieval systems often fail to capture semantic meaning, resulting in incomplete or inaccurate retrieval, particularly when processing complex legal queries formulated in natural language. Consequently, there is growing demand for intelligent tools that facilitate access to relevant legal information for both legal professionals and citizens. Addressing this challenge requires intelligent legal information systems capable of retrieving comprehensive and up-to-date information from legislation and regulatory documents, organizing it in a structured and user-friendly form, analytically processing large volumes of legal data, and understanding natural-language queries.
Legal information system solutions developed to date include legal search engines, specialized applications, legal AI assistants, and other intelligent systems [1]. The capabilities and underlying technologies of these solutions vary considerably. Because the vast majority of legal information is available in textual form, research and development in this field have focused primarily on natural language processing (NLP). Widely used NLP techniques include semantic search, machine learning, Transformer-based models, and large language models (LLMs) [2]. The emergence of LLMs has significantly accelerated the development of intelligent legal applications, including legal question-answering systems and AI legal assistants [3,4]. Recent advances in NLP and LLMs have enabled the development of intelligent legal question-answering systems capable of generating coherent, context-aware answers. However, purely generative approaches have significant limitations in the legal domain, including hallucinated content, lack of explicit grounding in legal sources, and insufficient transparency of reasoning [5]. These limitations create substantial risks of inconsistency and distortion in legal applications, where accuracy, controllability, and consistency with primary sources are essential.
To address these challenges, RAG has emerged as a promising paradigm that integrates information retrieval mechanisms with generative language models. By combining document retrieval with text generation, RAG-based systems improve factual grounding, response consistency, and controllability, all of which are essential requirements for legal applications. Although RAG has demonstrated considerable potential in legal information retrieval and question answering, most existing systems have been developed for high-resource languages and general-purpose corpora, limiting their applicability to low-resource languages and jurisdiction-specific legal domains. This limitation is particularly evident in the Republic of Kazakhstan, where legal documents are primarily published in Kazakh and Russian. The Kazakh language, in particular, remains underrepresented in large-scale NLP resources and pre-trained language models, making the development of reliable AI-based legal systems significantly more challenging. Furthermore, legal information systems in Kazakhstan must process heterogeneous legal sources, including legislative and regulatory documents as well as court decisions, each characterized by distinct structures, terminology, and legal semantics.
The aim of this study is to investigate and develop the intelligent core of a multilingual AI assistant based on the RAG architecture and a jurisdiction-specific legal knowledge base. The proposed solution is implemented as an integrated pipeline that combines multilingual document preprocessing, vector database indexing, semantic retrieval, and response generation using large language models. Particular attention is paid to ensuring legal grounding by explicitly linking the generated responses to the relevant statutory provisions and legislative articles. Unlike existing approaches, which primarily focus on either retrieval accuracy or response generation quality, the proposed methodology adopts a system-level perspective that balances retrieval accuracy, semantic relevance, legal grounding, and practical usability.
The main scientific and experimental contributions of this study are as follows:
  • Development of a domain-specific legal corpus based on the regulatory legal acts and court decisions of the Republic of Kazakhstan;
  • Evaluation of multilingual embedding models for semantic retrieval of legal texts in Kazakh and Russian;
  • Development of a domain-adapted RAG architecture that integrates semantic retrieval and LLM-based response generation for legal question answering;
  • Comprehensive experimental evaluation of the proposed approach using both automatic evaluation metrics and expert assessment;
  • Development and implementation of an AI legal assistant based on the proposed architecture and the results of the experimental evaluation.
The remainder of this article is organized as follows: introduction; related work; research methodology and models; experimental results and evaluation; discussion and limitations; and conclusion.

3. Methods

Our research methodology is aimed at creating the intellectual core of a multilingual legal assistant powered by artificial intelligence, as stated in the objective of our work. We employ methods of comparative analysis, design, data storage and processing, software development, and testing. The study examines the legal assistant’s architecture and its internal structures, which are designed to answer questions based on legal documents. Specifically, we create a legal dataset, perform primary data processing, create a vector database, conduct semantic searches across vector databases, reconstruct user queries using an LLM on top of a semantic search system, and justify and explain search results. Priority is given to factual accuracy, control, and legal correctness, beginning with the initial processing of a large volume of legal documents and passing them through several stages of semantic processing, ensuring that the answers obtained are based on legal acts.

3.1. System Architecture

The architecture of the AI assistant consists of several components: a user-interaction Telegram bot, auxiliary utilities, a reasoning and generation layer, a semantic retrieval layer, a vector database, and the initial dataset. The architecture and workflow of the AI assistant are shown in Figure 1.
Figure 1. AI assistant architecture and workflow.
The user interacts with the AI assistant via a Telegram bot. Its task is to send user questions to the assistant utilities and present the received answers.
Auxiliary utilities. After receiving a user request, the auxiliary utilities begin processing it and notify the user of the processing status. The system determines whether the request is text or audio. A text request is passed to the language-detection module. An audio request is passed to the speech-recognition module, where it is converted into text using speech-to-text (STT). The resulting text is then passed to the language-detection module. To identify the user’s language and process the request, the system uses the redis (redis.py) and bot_request (bot_request.py) modules. Redis is used as a fast cache for temporarily storing user data, such as language, the latest message, and session state. Its main functions include writing and retrieving values, storing hash values, working with lists, and clearing the database. It follows the singleton pattern, meaning that only one Redis client instance is used within the bot. The request text is then corrected and cleaned before being passed to the RAG layer.
The reasoning-and-generation layer uses an LLM for contextual reasoning, inference, and natural-language interpretation. Most importantly, the model is restricted from incorporating external knowledge beyond the retrieved documents, thereby reducing hallucinations and increasing legal certainty. In this layer, questions that have undergone initial processing in the auxiliary-utilities layer are reformulated by the LLM in accordance with the prompt-engineering instructions. The LLM also reasons over the results of vector search and generates an explanatory response.
The semantic retrieval layer is implemented using the Multilingual-E5-Large, BGE-M3, and KazEmbed-V5 multilingual embedding models. These models retrieve documents from the vector database that are semantically closest to the user’s query. The resulting legal fragments are passed to the LLM together with a structured prompt that restricts the use of information unrelated to the user’s request during generation.
The data corpus in the AI assistant architecture consists of a collection of legal acts and judicial acts of the Republic of Kazakhstan. The documents undergo initial processing; then, they are divided into chunks according to the criteria of semantic search models, converted into embeddings, and stored in a vector database.
In this study, the main focus is on generating correct judgments and answers using semantic search and large language models. The implementation of semantic search consists of several tasks, such as creating a legal dataset and pre-processing text data, and identifying effective models of multilingual semantic search for the Kazakh and Russian languages. In order to generate correct judgments and answers using large language models, the results of semantic search are fed into a large language model and prompt engineering is used. Also, tests are run on several language models and the accuracy of the results is evaluated. Next, the research activities mentioned and their results are presented.

3.2. Creation of the Legal Data Corpus and Text Preprocessing

Regulatory legal acts and judicial acts of the Republic of Kazakhstan were used to form the retrieval corpus. The Kazakh and Russian versions of these documents were used in parallel. The documents were obtained from official open information resources (https://adilet.zan.kz/ and https://zan.gov.kz/) and from government legal databases. A dedicated security certificate was obtained to access the official state legal database of the Republic of Kazakhstan. To incorporate general-domain textual data alongside legal data, the Kazakh OSCAR corpus [42] and a Russian books corpus [43] were added to the original dataset. The resulting corpus contains 39 million tokens in Kazakh and 38 million tokens in Russian.
Data preprocessing. All documents are preprocessed through text extraction, cleaning, normalization, and tokenization, and are then converted into vector representations for subsequent use by the search engine. The preprocessing steps used to create the semantic-search vector database are shown in Figure 2.
Figure 2. Data preprocessing processes.

3.3. Chunking and Overlap

Regulatory legal acts usually use a strict hierarchical structure consisting of sections, chapters, articles and clauses. To preserve legal semantics and ensure accurate search, documents are stored with additional metadata and pre-processed based on the requirements of the semantic search model. Each legal document is divided into semantically coherent parts that correspond to individual articles or logically complete clauses. If the document length exceeds the size of the parts, it is divided into several parts, the relationship between which is ensured by overlap. In the proposed approach, document segmentation is carried out on the basis of a multi-level (hierarchical) strategy. The algorithm works from top to bottom: first, the text is semantically divided into paragraphs (paragraph-level). At this stage, rule-based segmentation is used based on structural markers characteristic of legal texts (for example, “section”, “chapter”, “article”). If the length of a paragraph exceeds the specified token limit, it is divided at the sentence level (sentence-level). This uses a regex-based method that takes into account punctuation marks (period, exclamation mark, question mark) and linguistic features. If the sentence itself is too long, a word-level split is performed at the final level. This multi-level approach provides stability for long texts.
The chunking process uses the sliding window principle, i.e., overlap is introduced between adjacent chunks. This overlap is determined not by words or symbols, but at the level of sentences and tokens, as a result of which the semantic integrity of the context is preserved. In addition, an adaptive packing strategy is used during chunking: each chunk is filled as much as possible up to the token limit, but not exceeding the specified limit. This approach reduces gaps and allows for more efficient use of embedding space.
This study combines token-based chunking, hierarchical segmentation, sliding-window overlap, and domain-aware rule-based preprocessing. In addition to textual content, each chunk is enriched with metadata such as the document title, article number, jurisdiction, language, and date of the latest amendment. This metadata-based approach supports precise citation in generated responses and more comprehensive search. It also enables the system to distinguish between provisions in different legal codes that have the same article number.

3.4. Semantic Search Methods

Because this study uses multilingual text data, multilingual embedding models were considered for semantic search. Multilingual semantic search is an umbrella term for tasks that involve searching for texts with similar or relevant semantics in another language [44]. Multilingual text-embedding models are specifically designed to represent words and phrases with the same meaning in different languages within a shared vector space. Many such models are currently available; the principal models considered are listed in Table 1. For semantic search, each document fragment is transformed into a dense vector representation using a multilingual embedding model.
Table 1. Multilingual text embedding models.
As a result of the literature review, it was decided to consider and experimentally evaluate the Multilingual-E5-Large, BGE-M3, and KazEmbed-V5 models, which can encode legal texts in Kazakh and Russian into a shared semantic space. The selected models are modern multilingual embedding models designed for semantic search and RAG systems. Multilingual-E5-Large provides a solid foundation for general-purpose multilingual semantic search, KazEmbed-V5 is aimed at improving semantic search for Kazakh-language corpora, and BGE-M3 extends retrieval capabilities through hybrid dense-sparse and multi-vector representations.

3.4.1. Multilingual-E5-Large Embedding Model

Multilingual-E5-Large is a modern multilingual embedding model based on the Transformer architecture. It uses contrastive learning to map texts from different languages into a shared semantic space, enabling effective cross-lingual semantic retrieval. The model is widely used in semantic search systems and RAG architectures for multilingual document collections. It is suitable for various natural language processing tasks, including semantic search, information retrieval, RAG, and semantic textual similarity. Multilingual-E5-Large belongs to the E5 family and supports more than 100 languages, including Kazakh and Russian, which are used in our system [44,45].
The following briefly describes the generation of embeddings for documents in the retrieval corpus using Multilingual-E5-Large, the creation of a final embedding vector through a pooling operation, conversion of the user query into an embedding, and retrieval of similar document embeddings from the vector database. Let the retrieval corpus consist of a set of documents R c   = { X 1 , X 2 , X 3 , … X n } , each represented as a sequence of input tokens:
X i   = ( x 1 , x 2 , x 3 , … x m ) ,
where X i denoted as document and { x 1 , x 2 , x 3 , … x m } denoted as tokens included in the document. M is the length of document or number of tokens in the document.
After tokenization, embedding is formed:
E i   = ( e 1 , e 2 , e 3 , … e m ) ,
The Transformer encoder computes contextual representations:
H i   = T r n a s f o r m e r ( E i ) ,
where H i :
H i   = ( h 1 , h 2 , h 3 , … h m ) ,
A pooling operation (usually mean pooling) is used to generate the final embedding vector:
v =   1 m ∑ j = 1 m h j ,
The resulting vector represents the semantic content of the text in a multidimensional space v   ∈ R 1024 . For Multilingual-E5-Large, the embedding vector dimension is 1024.
Semantic space and similarity search. The basic idea is that semantically similar texts are located close to one another in vector space. Cosine similarity is used to estimate the similarity between query q and document d [50]:
s i m ( q , d ) =   q × d | q |   | d | ,
where
  • q—query embedding;
  • d—document embedding;
  • q × d—scalar product;
  • |(|q|)| and ||d|| are the vector norms.
The higher the cosine similarity value, the more relevant the document is considered.
Retrieval-training features. Multilingual-E5-Large was trained using contrastive learning with positive and negative pairs. For each training instance:
  • query q;
  • positive document d+;
  • negative document d−.
  • the model minimizes the contrastive loss [50]:
L =   − l o g   exp s i m q , d + τ ∑ j = 1 M exp s i m q , d j τ ,
where
  • τ—temperature parameter;
  • M—number of documents in the batch.

3.4.2. KazEmbed-V5 Embedding Model

KazEmbed-V5 was developed on the basis of the Multilingual-E5 architecture and further trained on Kazakh corpora to improve retrieval quality for Kazakh-language data. Unlike general-purpose multilingual embedding models, it focuses primarily on semantic retrieval of relevant documents rather than keyword matching. The use of a Transformer encoder, contrastive learning, and cosine similarity enables the model to address multilingual semantic-search and retrieval tasks effectively in RAG systems [48].
Because KazEmbed-V5 is based on the Multilingual-E5 architecture, its token sequence (Formula (1)), embedding formation (Formula (2)), computation of contextual representations by the Transformer encoder (Formula (3)), and pooling operation (Formula (5)) can be described in the same way as for Multilingual-E5-Large. The difference is the dimensionality of the vector representing the semantic content of the text in multidimensional space v =   R 768 .
The semantic-search principle and mathematical basis of model training are also the same as for Multilingual-E5-Large (Formulas (6) and (7)).

3.4.3. BGE-M3 Model

BGE-M3 (BAAI General Embedding—Multilingual, Multi-Functionality, Multi-Granularity) is a modern multilingual embedding model developed by the Beijing Academy of Artificial Intelligence (BAAI). It is designed for semantic search, dense retrieval, hybrid retrieval, multi-vector retrieval, Retrieval-Augmented Generation (RAG), and cross-lingual search [26,51]. A distinctive feature of BGE-M3 is that it combines several retrieval methods within a single architecture: dense embeddings, sparse retrieval, and multi-vector retrieval. The model is characterized by the following three combinations—M3 = Multi-Lingual + Multi-Functionality + Multi-Granularity.
The model is based on an XLM-RoBERTa-type Transformer encoder architecture. The input token sequence is represented as embeddings, the Transformer encoder computes contextual representations, and a pooling operation (Formula (5)) is performed in the same manner as for Multilingual-E5-Large. In BGE-M3, the vector representing the semantic content of the text has 1024 dimensions, v =   R 1024 . Mean pooling is used to represent the text’s semantic content in a dense vector space. Cosine similarity is used to calculate relevance between query q and document d (Formula (6)). One of the principal features of BGE-M3 is its support for multi-vector retrieval.
Multi-vector retrieval. Instead of a single embedding vector, the model can use a set of local vectors.
D = ( d 1 , d 2 , d 3 , … , d k ) ,
where each vector (di) describes a separate fragment of the document.
Similarity is calculated as
s i m q ,   D = max s i m   ( q , d j ) ,
This approach improves the processing of long documents by preserving local context and increasing retrieval accuracy.
Sparse retrieval component. BGE-M3 also supports sparse retrieval, similar to BM25. A weight is calculated for each token:
w j = f ( x j ) ,
where
  • xj—token;
  • wi—importance score.
Sparse representation makes it possible to account for exact term matches and improve retrieval in legal and technical documents.
Hybrid retrieval. The final relevance can be calculated as a combination of dense and sparse similarity:
S c o r e q , d = α × D e n s e q , d + β × S p a r s e ( q , d ) ,
where α and β are component weights. This hybrid retrieval combines semantic similarity with lexical matching. Contrastive learning was used to train the BGE-M3 model.
The application of the models considered in semantic search consists of two stages: indexing and retrieval. The embeddings are indexed by a vector-similarity search engine, enabling efficient nearest-neighbor search across millions of legal-text fragments. When a user submits a query, its embedding is calculated and compared with the indexed vectors to retrieve the most relevant fragments. During indexing, documents are first divided into chunks, an embedding is calculated for each chunk, and the embeddings are stored in a vector database. Retrieval comprises three steps: converting the user query into an embedding; calculating similarity between the query embedding and the indexed embeddings; and returning the most relevant chunks, for example, the five nearest documents.

3.5. Transformer Attention Mechanism for Multilingual Models

The multilingual embedding models considered in this study are based on the Transformer encoder architecture, which relies on the self-attention mechanism for contextual representation learning. Below, we provide a general description of the self-attention mechanism common to all the models considered (detailed information on the self-attention mechanism can be found in the literature [52,53]). Given an input sequence: X i   = ( x 1 , x 2 , x 3 , … x m ) The model computes three vector representations for each token:
  • Query—Q;
  • Key—K;
  • Value—V.
These vectors are obtained through linear transformations:
Q   = X W Q K   = X W K   V   = X W V ,
where WQ, WK, WV—are trainable parameter matrices.
The self-attention mechanism computes attention scores between tokens using scaled dot-product attention [52]:
A t t e n t i o n Q , K , V = s o f t m a x Q K T d k V ,
where
  • dk is the dimensionality of the key vectors;
  • softmax normalizes the attention weights.
The input includes Q-queries and dk-dimension keys, as well as dv—dimension values. The layer itself performs the following important operations, calculates the dot product between the query and the keys, divides the obtained values by d k and applies the softmax() function to the result. In practice, the Q matrix is built from all queries. The keys and values are also assembled into matrices K and V, respectively, and then the output matrix is calculated using Formula (14) [52].
M u l t i H e a d Q , K , V = C o n c a t ( h e a d 1 , … , h e a d h ) W 0 ,
where h e a d i = A t t e n t i o n ( Q W i Q , K W i K , V W i V ) , W i Q ∈ R d m o d e l ∗ d k ,   W i K ∈ R d m o d e l ∗ d k ,   W i V ∈ R d m o d e l ∗ d v , W o ∈ R h d v ∗ d m o d e l —linear transformation matrices, h—number of parallel levels of attention.
Multilingual-E5-Large uses Transformer self-attention to generate dense contextual embeddings optimized for retrieval-oriented semantic search. KazEmbed-V5 inherits the self-attention architecture from multilingual-E5 and further adapts contextual semantic representations for Kazakh-language retrieval tasks. BGE-M3 extends Transformer-based attention mechanisms through dense, sparse, and multi-vector retrieval representations, enabling improved long-document semantic matching.
Semantic search returns the most relevant legal fragments as follows:
R = ( r 1 , r 2 , r 3 , … r l ) ,
where
  • l—number of the most relevant fragments;
  • R—set of fragments retrieved by the search.
The results are then processed at the next stage using large language models.

3.6. Reasoning and Explanation Using LLMs and Semantic-Search Results

Large Language models. The most-relevant legal fragments retrieved from the vector database are supplied to LLMs for reasoning and interpretation. In the proposed architecture, GPT-5.4 and Llama-4-Scout-17B-16E-Instruct are used as generative reasoning models. The role of the LLM layer is not to search for information directly, but to synthesize and interpret legal information contextually on the basis of the retrieved evidence. Unlike traditional generative systems that rely solely on parametric knowledge, the proposed architecture uses regulatory legal texts retrieved by the search system and constrains unsupported generation, thereby improving factual accuracy and reducing hallucinations.
GPT-5.4 and Llama-4-Scout-17B-16E-Instruct are based on autoregressive Transformer architectures that use self-attention mechanisms for contextual reasoning. In general, the input sequence to the LLM in this study can be represented as follows:
X l l m   = { R , Q , S p } ,
The input to the LLM consists of a set of legal fragments (R) obtained as a result of the search, a user query (Q), and system prompt instructions (Sp).
In a large language model, input data are processed through several stages, including the conversion of tokens into embeddings, calculation of contextual representations through self-attention layers, and generation of contextual hidden states that encode semantic dependencies. LLMs also use multi-head self-attention mechanisms [53].
Next, the LLM autoregressively generates an explanation by estimating the conditional probability of each next token on the basis of the preceding tokens and the supplied context. This produces the following output sequence:
Y   = y 1 , y 2 , y 3 , … , y T ,
The model objective is:
P Y X L L M = ∏ t = 1 T P y t y < t ,   X l l m ,
where
  • X l l m —legal fragments from semantic search and prompts;
  • y < t —previously generated token.
The probability distribution over the vocabulary at each generation step is calculated as follows:
P y t = s o f t m a x W o h t + b ,
where
  • h t —is the hidden representation,
  • W o —is the output projection matrix,
  • b—is the bias vector
The token with the highest probability, or a token selected according to the decoding strategy, is chosen as the next generated token.
Retrieval-grounded reasoning. In the proposed architecture, reasoning must be based on the retrieved legal evidence. Above, the user query is denoted by Q and the set of legal fragments retrieved by the search is denoted by R. The generated explanation is therefore modeled as:
P ( Y | Q , R ) ,
where Y—represents the generated legal interpretation. This formulation ensures that the reasoning process is grounded in external legal sources rather than relying exclusively on the parametric memory of the model.
A special prompt template is used to increase the accuracy of the actual data and limit the generation of the final response. The generation process consisting of the user query (Q), the set of legal fragments obtained as a result of the search (R), and the system prompt instructions (Sp) can be expressed as Y = f ( R , Q , S p ) .
One of the main challenges of LLM-based AI assistants is the occurrence of hallucinations. The proposed RAG architecture addresses this problem by providing relevant legal passages and applying prompt constraints. The resulting textual response is generated as an interpreted legal explanation based on the retrieved evidence and is then presented to the user. This retrieval-grounded approach allows for increased transparency in the reasoning process while ensuring the reliability and legal compliance of expert systems with the requirements of legal interpretation. Unlike generative systems that rely solely on the parametric knowledge of large language models, the proposed architecture grounds its responses in normative legal sources, which is essential for legal information systems that require a high level of accuracy and interpretability.

4. Results

In this section, we present the experimental tests and the evaluation results of the selected methods. First, we describe the preparation of the dataset, including the segmentation of legal texts into chunks and the overlap strategy used during chunking. The evaluation focuses primarily on the accuracy of semantic search and the correctness of the answers generated by the large language model. The assessment is conducted using a fixed set of legal queries derived from real user scenarios. All experiments are performed under identical hardware and software conditions.

4.1. Dataset

Preprocessing of the source data ensures consistency and compatibility with the models used. Before indexing, the documents are converted into a unified JSON format and preprocessed using a structure-aware segmentation approach. Each segment corresponds to a semantically coherent legal unit, typically an article or a complete clause, and is stored together with metadata such as the document title, article number, language, and revision date. The semantic-search methods and models are then applied. This process includes text chunking, generation of vector embeddings, indexing, document retrieval, and evaluation of the results. Table 2 presents statistics for the legal-document corpus used in this study.
Table 2. Corpus statistics.

4.1.1. .json Document Structure

Each JSON file is represented as an array of objects, where one object is a record of a regulatory legal act (RLA) or a judicial act. The .json document structure is organized as follows
[
 {
   "_id": { "$oid": "4efa1f930cf26f517f1db1a8" },
   "decompressedText": " Full text of the document in unpacked form…",
   "in": "0400",
   "st": "new",
   "voa": "official name of the document ",
   "zg": "short description/title of the document ",
   "lg": "kaz",
   "ngr": "Z000000123_",
   "processed_timestamp": 1741104477.8270261,
   "source": "npa"
 }
]
Description of keys:
  • _id.$oid—unique record identifier (MongoDB ObjectId).
  • decompressedText—full text of the regulatory legal act or judicial act in uncompressed form (string).
  • in—internal document category code.
  • st—record processing status (new, updated, etc.)
  • voa—full official title of the act.
  • zg—short title or description of the document.
  • lg—document language (kaz—kazakh, rus—russian).
  • ngr—internal registration number (format: prefix + identifier).
  • processed_timestamp—UNIX document processing time (float).
  • source—source type (npa-regulatory legal acts, court-judicial acts).
The representation of the collected data in the data frame is shown in Figure 3.
Figure 3. Representation of legal data in a DataFrame (legal dataset in kazakh language).

4.1.2. Implementation of Chunking and Overlap

In this study, chunk sizes for text segmentation were selected on the basis of the input-size limits of the embedding models. In particular, chunk length was determined using the embedding model’s tokenization mechanism rather than the number of characters or words. The structure of text data divided into chunks is shown in Figure 4.
Figure 4. Text data divided into chunks (the text data given in Kazakh).
To determine an effective chunk length, retrieval accuracy was evaluated for chunk lengths of 128, 256, 512, and 1024 tokens supported by the embedding models. In addition, experiments were conducted with overlap values from 0 to 100 tokens (0, 20, 40, 60, 80, and 100) to determine an effective overlap between chunks. The F1-score of the semantic search results was calculated for each chunk–overlap combination. The results are shown in Table 3.
Table 3. Search. The impact of chunk size and overlap parameters on semantic search quality (F1-score).
The results of the sensitivity analysis showed that the chunk size and overlap parameters significantly affect the quality of semantic search. In general, as the overlap value increases, the F1-score of all three embedding models tends to increase. This phenomenon can be explained by the preservation of contextual information between neighboring chunks, which reduces the probability that important legal information will be separated at chunk boundaries.
The highest result for the multilingual-e5-large model was obtained with a combination of 1024-token chunks and 100-token overlap (F1 = 0.876). Moreover, when increasing the chunk size from 512 to 1024 tokens, the F1-score increased from 0.847 to 0.876. This indicates that the larger chunk size for this model allows a wider context to be stored, improving the quality of semantic search. In contrast, the highest F1-score for the BGE-M3 model was observed with a 512-token chunk and 100-token overlap (F1 = 0.768). In the case of using a 1024-token chunk, the result decreased to 0.765. Therefore, for BGE-M3, excessively increasing the chunk size does not further improve the search quality. The highest performance for the KazEmbed-V5 model was obtained with a 512-token chunk and 100-token overlap (F1 = 0.833). Compared to the 128- and 256-token chunk sizes, moving to 512 tokens led to a significant increase in search quality. This result indicates that the 512-token chunk size is effective for KazEmbed-V5.
The effect of the chunk size and overlap parameters on the F1-score is graphically shown in Figure 5. The results show that with increasing overlap, the F1-score increases in most cases and the optimal chunk size varies depending on the embedding model.
Figure 5. The effect of chunk size and overlap parameters on F1-score (the highest accuracy values are indicated by asterisks).

4.2. Multilingual Search Results

Evaluating the performance of AI assistants in answering legal questions requires assessing both the quality of information retrieval and the accuracy of the generated answers. In this study, performance is evaluated at two complementary levels: (1) semantic retrieval quality and (2) answer generation quality. This two-level evaluation ensures that improvements in answer generation are based on accurate document retrieval rather than solely on the linguistic capabilities of the language model.
The legal-document fragments retrieved by the search system were evaluated against a set of relevant legal articles annotated by domain experts. The primary objective was to measure how effectively the system retrieved legally relevant provisions in response to a user query.
Precision and recall were calculated according to whether the retrieved fragments contained the correct legal articles or clauses. The F1 score, the harmonic mean of precision and recall, was used to provide a balanced assessment of retrieval effectiveness. This metric is particularly important in legal information retrieval because failure to retrieve a relevant article, or retrieval of an incorrect article, may lead to legally invalid conclusions. The five top-ranked results produced by semantic search were evaluated for accuracy. The average results of the multilingual retrieval models are shown in Table 4.
Table 4. Performance of Embedding Models in Semantic Search.
Although the Multilingual-E5-Large, KazEmbed-V5, and BGE-M3 models are all based on Transformer coding architectures and contrastive learning principles, they differ in terms of text chunk length, accuracy, and search strategies.

4.3. LLM Answer-Generation Results

GPT-5.4 and Llama-4-Scout-17B-16E-Instruct were used as the reasoning and interpretation layer for the retrieved search results. Answers were generated from the retrieved context and system instructions defining the model’s role as a legal analytical assistant. The prompt was designed to meet the following requirements:
  • Use only the provided legal fragments;
  • Cite the relevant articles and regulatory provisions;
  • Avoid assumptions and unsupported conclusions;
  • Clearly indicate when the available context is insufficient to support an answer.
Figure 6 presents an answer generated by a large language model using semantic-search results for the question “Meдицинaлық көмeк aлғaн кeздe нayқacтың қaндaй құқықтapы бap?” (“What rights does a patient have when receiving medical care?”).
Figure 6. Semantic search results for a given question (user query and response in Kazakh).
A set of 104 questions was specially prepared by legal experts to evaluate the answers generated by the large language models. The final list of questions was compiled through a multi-stage procedure. The first stage involved analyzing legal inquiries from individuals in Kazakhstan (2024–2026). The second stage systematized questions by legal domain: family, civil, labor, housing, tax, and administrative law. The third stage comprised expert screening to eliminate duplicates, correct inaccuracies, and broaden thematic coverage. The questions were submitted as user queries and the resulting answers were collected. Two methods were used for evaluation: assessment by legal experts and automatic evaluation using word-level F1, BLEU, ROUGE, and BERTScore-F1 metrics.
Legal experts classified the answers into three categories: fully correct; correct but requiring additional information; and incorrect. Expert assessment for responses (results) was conducted in two rounds: individual questionnaires based on relevance, significance, and completeness, followed by an in-person meeting to resolve disagreements and reach consensus. Kendall’s concordance coefficient was 0.82, indicating a high degree of unanimity and reliable results. The coefficient is a non-parametric measure of agreement among experts ranking the same set of objects. Its value ranges from 0 to 1, with interpretation based on the Landis and Koch scale: values below 0.20 indicate slight agreement, 0.20–0.40 fair, 0.40–0.60 moderate, 0.60–0.80 substantial, and 0.80 and above almost perfect agreement [54].
The evaluation results for the configurations combining GPT-5.4 with the retrieval models are presented in Table 5.
Table 5. Accuracy of GPT-5.4 configurations with semantic-search models (the numbers of responses are shown in parentheses).
The evaluation results for the configurations combining Llama-4-Scout-17B-16E-Instruct with the retrieval models are presented in Table 6.
Table 6. Accuracy of Llama-4-Scout-17B-16E-Instruct configurations with semantic-search models (the numbers of responses are shown in parentheses).
Figure 7 presents the collected and verified question-and-answer results.
Figure 7. Dataset compiled from the questions and answers (here are questions and answers in Russian as one of the results).
Several widely used natural language generation metrics, such as F1 (word level), BLEU, ROUGE-1, ROUGE-L, and BERTScore-F1, were used to objectively assess the quality of the responses generated by the RAG system. These metrics allow for comparative analysis and evaluation of the responses generated by the system with the results verified by legal experts.
The word-level F1 metric measures the harmonic mean of precision and recall at the word level and indicates the degree of lexical overlap between generated and reference answers. BLEU evaluates n-gram overlap and is often used to measure the lexical similarity of generated text. ROUGE-1 evaluates unigram overlap, while ROUGE-L evaluates the longest common subsequence and therefore reflects structural similarity between texts. BERTScore-F1 uses contextual embeddings from Transformer-based language models to measure semantic similarity between generated and reference answers. This metric is particularly important for legal question-answering systems because legally correct answers may be expressed using different wording while preserving the same meaning [R48].
The combined use of lexical metrics (word-level F1, BLEU, and ROUGE) and a semantic metric (BERTScore) provides a more comprehensive evaluation of the proposed RAG system. The lexical metrics quantify the extent to which generated answers reproduce key legal terms and concepts, whereas BERTScore evaluates semantic consistency. Together, these metrics provide complementary information on the quality, correctness, and semantic consistency of the generated answers. The results are presented below. Table 7 reports word-level F1, BLEU, ROUGE-1, ROUGE-L, and BERTScore-F1 for GPT-5.4 configurations, and Table 8 reports the same metrics for Llama-4-Scout-17B-16E-Instruct configurations.
Table 7. Results for GPT-5.4 configurations with semantic-search models.
Table 8. Results for Llama-4-Scout-17B-16E-Instruct configurations with semantic-search models.
In the GPT-5.4 model, reasoning is implemented through multi-stage interpretation of retrieved context, which has a high ability to logically identify regulatory rules and generate structured explanations. This model has shown high stability when processing complex legal queries with cross-references to regulatory acts and ambiguous legal statements.
The Llama-4-Scout-17B-16E-Instruct model was used as an open, multilingual reasoning model with a Mixture-of-Experts (MoE) architecture optimized for long-context inference and the interpretation of large volumes of textual data. Owing to its extended context window, the model efficiently processes multiple legal document fragments while maintaining response coherence and contextual consistency. The use of an open model also enables local deployment and greater control over the processing of legally sensitive data.
Ablation experiment results. To compare the results of the RAG system with the capabilities of individual LLMs, separate tests were conducted on the GPT-5.4 and Llama-4-Scout-17B-16E-Instruct models. The 104 questions used above were set as queries to these LLM models, and the results were evaluated using the F1 (Word Level) BLEU, ROUGE-1, ROUGE-L and BERTScore-F1 metrics. The test results are shown in Table 9.
Table 9. Results of standalone LLMs without semantic retrieval.
Comparison of the individual LLM results with the results of the RAG configurations presented in Table 7 and Table 8 shows that the semantic search component has a significant impact on response quality. The most consistent change was observed in the BERTScore-F1 metric: compared to the value of 0.7181 in the standalone configuration for the GPT-5.4 model, it increased to values of 0.887, 0.842, and 0.873 in the RAG configurations based on Multilingual-e5-large, BGE-M3, and KazEmbed-V5, respectively. This represents a relative increase of 23.5%, 17.3%, and 21.6%, respectively. For the Llama-4-Scout-17B-16E-Instruct model, the BERTScore-F1 increased from 0.6732 to 0.836, 0.820, and 0.840, respectively, corresponding to a relative increase of 24.2%, 21.8%, and 24.8%. Thus, the addition of the semantic search component provided a consistent improvement in semantic matching across all three embedding models for both LLMs.
These results quantitatively confirm the contribution of the semantic search component in the proposed RAG architecture. In addition, the non-uniformity of changes in lexical overlap-based metrics such as Word-Level F1, BLEU, and ROUGE can be explained by the fact that generated responses may be lexically different from the reference responses, but semantically close.

5. Discussion

According to the main findings of this study, the proposed AI legal assistant for processing legal texts in Kazakh and Russian demonstrated strong performance. The experimental results indicate that the effectiveness of a legal RAG system depends not only on the retrieval model but also on the interaction between the retrieval and generation components.
Evaluation of the semantic-search models. Multilingual-E5-Large achieved the highest retrieval accuracy (0.876), outperforming BGE-M3 (0.768) and KazEmbed-V5 (0.833). These results indicate that Multilingual-E5-Large is more effective at identifying relevant legal fragments in the bilingual Kazakh–Russian legal corpus. Its strong performance may be attributed to its multilingual training strategy and robust semantic-representation capabilities.
Among the combinations of LLMs and semantic-search models, GPT-5.4 with Multilingual-E5-Large achieved the highest overall performance, with an accuracy of 88.7%. By contrast, the Llama-4-Scout-17B-16E-Instruct with Multilingual-E5-Large configuration achieved 82.6%. The highest accuracy among the Llama-4-Scout-17B-16E-Instruct configurations, 83.6%, was achieved with KazEmbed-V5. Although Multilingual-E5-Large retrieved more relevant documents on average, KazEmbed-V5 appears to provide context better aligned with the linguistic characteristics of Kazakh legal texts, enabling the LLM to produce more accurate answers. The automatic evaluation metrics support this observation: among the LLaMA-based configurations, KazEmbed-V5 achieved the highest BLEU (0.0615), ROUGE-1 (0.206), ROUGE-L (0.135), and BERTScore-F1 (0.840) scores. These results indicate strong lexical and semantic similarity between the generated and reference answers.
The results are consistent with those of Rakhimova et al. [41], who showed that GPT-4o mini outperformed LLaMA-based models in Kazakh legal question-answering tasks. The main difference is that their study fine-tuned several large language models, including GPT-4o mini, LLaMA, KazLLM, Gemma, Phi, Qwen, and Mistral, whereas our solution is based on Retrieval-Augmented Generation. In their study, GPT-4o mini achieved ROUGE-1 = 0.309 and ROUGE-L = 0.263 and received the highest expert-assessment score, indicating strong legal-reasoning capability. A similar trend was observed in our experiments. The GPT-5.4 with Multilingual-E5-Large configuration achieved the best automatic evaluation results, with word-level F1 = 0.248, BLEU = 0.081, ROUGE-L = 0.164, and BERTScore-F1 = 0.887, outperforming all Llama-4-Scout-17B-16E-Instruct configurations. Expert evaluation also indicated that GPT-based models performed better: GPT-5.4 combined with Multilingual-E5-Large achieved an answer accuracy of 88.7%, whereas the best Llama-4-Scout-17B-16E-Instruct configuration achieved 83.6%. These findings are consistent with previous studies indicating that GPT-based models currently generate more accurate and semantically relevant answers in legal question-answering tasks, particularly when combined with a RAG architecture and high-quality semantic retrieval.

6. Conclusions

This study demonstrates that the adoption of modern artificial intelligence technologies in the legal domain is an important means of supporting lawyers’ professional activities, expanding access to legal information, and providing legal services to citizens. AI-powered legal assistants can improve the efficiency of legal services by retrieving legal information, analyzing regulatory documents, and responding promptly to legal questions. Accordingly, the study included a comprehensive review of international research and the experience of various countries in applying artificial intelligence in the legal domain. The review helped refine the aims and objectives of the study and identified the need to investigate and develop the intelligent core of an AI legal assistant based on RAG.
During the study, a bilingual corpus of legal texts in Kazakh and Russian was collected from official legal-information sources (39 million tokens in Kazakh and 38 million tokens in Russian). On the basis of this corpus, a dense-vector semantic-search system was implemented using modern embedding models. The study evaluated Multilingual-E5-Large, KazEmbed-V5, which is adapted for Kazakh, and the multilingual BGE-M3 model. The experimental results showed that Multilingual-E5-Large achieved the highest retrieval accuracy (0.876), outperforming BGE-M3 (0.768) and KazEmbed-V5 (0.833). The most relevant documents identified through semantic search were then supplied to GPT-5.4 and Llama-4-Scout-17B-16E-Instruct, which generated answers to legal questions. The evaluation questions were specially prepared by professional legal experts. The answers generated were assessed both by experienced lawyers and automatically using word-level F1, BLEU, ROUGE-1, ROUGE-L, and BERTScore-F1. These two evaluation approaches produced broadly consistent results. Expert assessment is an important condition for ensuring the reliability and accuracy of legal AI systems. On the basis of this research and development, an AI legal assistant was created and integrated into the “Adal Azamat” legal services platform (https://legal-digital.kz/en (accessed on 12 July 2026)), where it is available on the main page under the name “AI Legal Consultant.”
The RAG-based AI legal assistant proposed in this study demonstrated promising performance in multilingual legal question-answering tasks. The experimental results indicate that combining semantic retrieval with the reasoning capabilities of large language models enables effective legal information retrieval and the generation of high-quality answers to legal questions. However, the practical deployment of such a system requires continuous expert oversight, regular updates of the legal knowledge base, and further improvements to both the retrieval and legal reasoning components. Future research will focus on expanding and continuously updating the legal knowledge base, including the integration of legal knowledge graphs, as well as enhancing the retrieval and answer-generation components to further reduce errors. In addition, comprehensive evaluations involving legal experts and realistic legal scenarios should be conducted to assess the system’s performance in practical applications.

7. Limitations

Despite the promising results obtained in this study, several limitations can be noted.
First, the developed legal AI assistant relies on a static legal corpus collected from official legal information resources. Although the corpus contains more than 101,000 legal documents and 77 million tokens in Kazakh and Russian, it may not fully reflect newly adopted legislation, amendments, or emerging legal practices. Therefore, the corpus needs to be continuously updated to maintain the relevance and accuracy of the system.
Second, the answer-generation component uses general-purpose large language models (GPT-5.4 and Llama-4-Scout-17B-16E-Instruct) that were not developed specifically for the legal domain of Kazakhstan. Consequently, despite the use of Retrieval-Augmented Generation, the generated answers may occasionally contain inaccuracies, omissions, or hallucinations.
Finally, due to the time-consuming nature of legal expert evaluation, the expert review was conducted on a limited set of responses. Future research should include a larger dataset for expert evaluation and an analysis of inter-annotator agreement to further assess the reliability and robustness of the system.
These limitations provide directions for future improvements, including the continuous updating of the legal corpus, the integration of diverse legal knowledge sources, the adaptation of large language models to the legal domain, and a more comprehensive involvement of legal experts in evaluating system performance. Another important consideration is that the proposed AI assistant is not a substitute for professional legal advice and should be deployed with appropriate warnings and control mechanisms.

Author Contributions

Conceptualization, N.M. and A.A.; methodology, Z.A.; software, B.A. and N.Y.; validation, M.K. and N.Y.; formal analysis, N.M. and Z.A.; investigation, M.K.; resources, N.Y.; data curation, B.A.; writing—original draft preparation, N.M.; writing—review and editing, Z.A. and A.A.; visualization, B.A.; supervision, A.A.; project administration, A.A. All authors have read and agreed to the published version of the manuscript.

Funding

This research has been funded by the Committee of science of the Ministry of Science and Higher Education of the Republic of Kazakhstan (Grant No. BR24993166).

Data Availability Statement

The datasets presented in this article are not readily available because the data are part of an ongoing study and the project assignment is being developed by order of the Ministry of Justice of the Republic of Kazakhstan. Requests to access the datasets should be directed to e-mail address nurzhan.mukazhanov@narxoz.kz.

Conflicts of Interest

The authors declare no conflicts of interest.

Abbreviations

The following abbreviations are used in this manuscript:
AIArtificial Intelligence
RAGRetrieval-Augmented Generation
BGE-M3BAAI General Embedding—Multilingual, Multi-Functionality, Multi-Granularity
GPTGenerative Pre-Trained Transformer
GPT-5.4Generative Pre-trained Transformer 5.4
BLEUBilingual Evaluation Understudy
ROUGERecall-Oriented Understudy for Gisting Evaluation
BERTScoreBidirectional Encoder Representations from Transformers Score
KazEmbed-V5Kazakh Embedding Model for RAG
LLaMALarge Language Model Meta AI
NLPNatural Language Processing
LLMLarge Language Model
STTSpeech-To-Text
LaBSELanguage-agnostic BERT Sentence Embeddings
BAAIBeijing Academy of Artificial Intelligence
XLM-RoBERTaCross-lingual Language Model—Robustly Optimized BERT Approach
BM25Best Match 25
JSONJavaScript Object Notation
RLARegulatory Legal Act
MoEMixture-of-Experts
KazLLMKazakh Large Language Model (locally trained)
GemmaGoogle Efficient Multilingual Model Architecture
QwenAlibaba’s Chinese-Centric LLM

References

  1. Zhu, S.; Chen, Y. The Trio of Computational Jurisprudence: History, Present, and Future. In Artificial Intelligence and the Rule of Law; Springer: Cham, Switzerland, 2025; pp. 35–60. [Google Scholar] [CrossRef] [Scilit]
  2. Ariai, F.; Mackenzie, J.; Demartini, G. Natural Language Processing for the Legal Domain: A Survey of Tasks, Datasets, Models, and Challenges. ACM Comput. Surv. 2025, 58, 163. [Google Scholar] [CrossRef] [Scilit]
  3. Płonka, M.; Kocot, K.; Hołda, K.; Daniec, K.; Nawrat, A. A Comparative Evaluation of the Effectiveness of Document Splitters for Large Language Models in Legal Contexts. Expert Syst. Appl. 2025, 272, 126711. [Google Scholar] [CrossRef] [Scilit]
  4. Martinez-Gil, J. A Survey on Legal Question Answering Systems. arXiv 2021, arXiv:2110.07333. Available online: https://arxiv.org/abs/2110.07333 (accessed on 11 May 2026).
  5. Siino, M. Exploring the Use of LLMs in the Italian Legal Domain: A Survey on Recent Applications. Comput. Law Secur. Rev. 2025, 58, 106164. [Google Scholar] [CrossRef] [Scilit]
  6. He, C.; Hu, H.; Li, Y.; Zhang, H.; Zhang, Q. A Survey of Large Language Models for Legal Tasks: Progress, Prospects and Challenges. Comput. Sci. Rev. 2026, 60, 100906. [Google Scholar] [CrossRef] [Scilit]
  7. Rissland, E.L. Artificial Intelligence and Legal Reasoning: A Discussion of the Field & Gardner’s Book. AI Mag. 1988, 9, 45–55. [Google Scholar]
  8. Popple, J. Legal Expert Systems: The Inadequacy of a Rule-Based Approach. Aust. Comput. J. 1991, 23, 11–16. [Google Scholar]
  9. Abdallah, A.; Piryani, B.; Jatowt, A. Exploring the State of the Art in Legal QA Systems. arXiv 2023, arXiv:2304.06623. Available online: https://arxiv.org/abs/2304.06623 (accessed on 11 May 2026).
  10. Nguyen, H.T.; Fungwacharakorn, W.; Zin, M.M.; Goebel, R.; Toni, F.; Stathis, K.; Satoh, K. LLMs for Legal Reasoning: A Unified Framework and Future Perspectives. Comput. Law Secur. Rev. 2025, 58, 106165. [Google Scholar] [CrossRef] [Scilit]
  11. Ren, W.; Shen, L.; Zhu, J.; Li, S.; Hong, Y.; Wang, J.; Cao, D. Automated Data Synthesis and Retrieval-Augmented Generation for Legal Large Language Models. Knowl.-Based Syst. 2026, 347, 116267. [Google Scholar] [CrossRef] [Scilit]
  12. Zhou, S.; Wang, H.; Ng, S.T.; Li, D.; Xie, S.; Chen, K.; Wang, W. Building a Construction Law Knowledge Repository to Enhance General-Purpose Large Language Model Performance on Domain Question-Answering: A Case of China. Eng. Constr. Archit. Manag. 2025, 32, 518–546. [Google Scholar] [CrossRef] [Scilit]
  13. Gupta, J.; Sharma, A.; Singhania, S.; Abidi, A.I. Legal Assist AI: Leveraging Transformer-Based Model for Effective Legal Assistance. arXiv 2025, arXiv:2505.22003. Available online: https://arxiv.org/html/2505.22003v1 (accessed on 17 May 2026).
  14. Veningston, K.; Mishra, A. Dataset for Legal Question Answering System in the Indian Judiciary Context. Data Brief 2025, 60, 111647. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  15. Jiang, H.; Zhang, X.; Mahari, R.; Kessler, D.; Ma, E.; August, T.; Li, I.; Pentland, A.; Kim, Y.; Roy, D.; et al. Leveraging Large Language Models for Learning Complex Legal Concepts through Storytelling. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), Bangkok, Thailand, 11–16 August 2024; Association for Computational Linguistics: Bangkok, Thailand, 2024; pp. 7194–7219. [Google Scholar] [CrossRef] [Scilit]
  16. Herrera-Tapias, B.A.; Hernández Guzmán, D. Legal Hallucinations and the Adoption of Artificial Intelligence in the Judiciary. Procedia Comput. Sci. 2025, 257, 1184–1189. [Google Scholar] [CrossRef] [Scilit]
  17. Jiang, Z.; Chen, G.; Xu, Z. Building Regulation Question-Answering System Using Retrieval-Augmented Generation with Dual-Stage Fine-Tuned Large Language Model. Adv. Eng. Inform. 2026, 69, 104089. [Google Scholar] [CrossRef] [Scilit]
  18. Barron, R.C.; Eren, M.; Serafimova, O.M.; Matuszek, C.; Alexandrov, B.S. Bridging Legal Knowledge and AI: Retrieval-Augmented Generation with Vector Stores, Knowledge Graphs, and Hierarchical Non-negative Matrix Factorization. In Proceedings of the Twentieth International Conference on Artificial Intelligence and Law (ICAIL ‘25), Chicago, IL, USA, 16–20 June 2025; Association for Computing Machinery: New York, NY, USA, 2025; pp. 51–60. [Google Scholar] [CrossRef] [Scilit]
  19. Buffa, M.; Ferrara, A.; Picascia, S.; Riva, D.; Castano, S. Enhancing Legal Document Building with Retrieval-Augmented Generation. Comput. Law Secur. Rev. 2025, 59, 106229. [Google Scholar] [CrossRef] [Scilit]
  20. Ben Khalifa, I.; Ben Messaoud, M.; Mkaouer, M.W. LARK: License Analysis with RAG and Knowledge Graphs. Inf. Softw. Technol. 2026, 197, 108164. [Google Scholar] [CrossRef] [Scilit]
  21. Csányi, G.M.; Lakatos, D.; Üveges, I.; Megyeri, A.; Vadász, J.P.; Nagy, D.; Vági, R. From Fact Drafts to Operational Systems: Semantic Search in Legal Decisions Using Fact Drafts. Big Data Cogn. Comput. 2024, 8, 185. [Google Scholar] [CrossRef] [Scilit]
  22. Meng, C.; Tang, C.; Todo, Y.; Ding, W. Multi-Granular Legal Information Fusion with Adversarial Compensation: A Hierarchical and Logic-Aware Framework for Robust Case Retrieval. Knowl.-Based Syst. 2025, 325, 113964. [Google Scholar] [CrossRef] [Scilit]
  23. Han, W.; Shen, J.; Liu, Y.; Shi, Z.; Xu, J.; Hu, F.; Chen, H.; Gong, Y.; Yu, X.; Wang, H.; et al. LegalAsst: Human-Centered and AI-Empowered Machine to Enhance Court Productivity and Legal Assistance. Inf. Sci. 2024, 679, 121052. [Google Scholar] [CrossRef] [Scilit]
  24. Joseph, P.K.; Odumuyiwa, V. From Word to Sentence Embedding and beyond: Bridging the Gap in Text Representation Survey. Nat. Lang. Process. J. 2026, 14, 100214. [Google Scholar] [CrossRef] [Scilit]
  25. Phung, N.H.; Nguyen, C.T.; Nguyen, M.-T.; Nguyen, T.H.; Le, H.L.; Nguyen, T.-P. A Fine-Tuning Framework Based on Question, Context, and Answer Relationships for Enhancing Legal Information Retrieval. Eng. Appl. Artif. Intell. 2025, 159, 111570. [Google Scholar] [CrossRef] [Scilit]
  26. Omotoso, A.; Shopeju, H.; Joshua, A.; Oni, S. Improving BGE-M3 Multilingual Dense Embeddings for Nigerian Low-Resource Languages. In Proceedings of the 9th Widening NLP Workshop, Suzhou, China, 8 November 2025; Association for Computational Linguistics: Suzhou, China, 2025; pp. 224–229. [Google Scholar] [CrossRef] [Scilit]
  27. Chen, J.; Xiao, S.; Zhang, P.; Luo, K.; Lian, D.; Liu, Z. M3-Embedding: Multi-Linguality, Multi-Functionality, Multi-Granularity Text Embeddings Through Self-Knowledge Distillation. In Proceedings of the 2024 Annual Conference of the North American Chapter of the Association for Computational Linguistics (NAACL 2024); Association for Computational Linguistics: Stroudsburg, PA, USA, 2024. [Google Scholar] [CrossRef] [Scilit]
  28. Singh, L.; Joshi, K.A.; Koranga, R.; Pant, S.C.; Mathur, P. Artificial Intelligence in the Legal Profession: A Review on Its Transformative Potential and Ethical Challenges. In Proceedings of the International Conference on Information Management & Machine Intelligence (ICIMMI 2023), Jaipur, India, 23–25 November 2023; Association for Computing Machinery: New York, NY, USA, 2023. [Google Scholar] [CrossRef] [Scilit]
  29. Singh, M. Review on Role of Artificial Intelligence in the Life of Legal Profession. Int. J. Leg. Sci. Innov. 2024, 6, 1087–1096. Available online: https://ijlsi.com/paper/review-on-role-of-artificial-intelligence-in-the-life-of-legal-profession/ (accessed on 22 May 2026). [CrossRef] [Scilit]
  30. Najafli, A. The Impact of Artificial Intelligence on the Legal System: Benefits, Risks, Legal, and Ethical Challenges. Acta Glob. Humanit. Linguar. 2025, 2, 247–263. [Google Scholar] [CrossRef] [Scilit]
  31. De la Torre Soto, G.L.; Rodriguez-Serpa, F.A. Artificial Intelligence: A New Reasoning Method for Legal Science. Procedia Comput. Sci. 2024, 251, 807–813. [Google Scholar] [CrossRef] [Scilit]
  32. Bagul, P.; Surve, R.; Singh, A.; Sargar, A.; Mohite, S. AI Powered Legal Advisor Assistant. Int. J. Adv. Res. Sci. Commun. Technol. 2025, 5, 242–250. [Google Scholar] [CrossRef] [Scilit]
  33. Imogen, P.V.; Sreenidhi, J.; Nivedha, V. AI-Powered Legal Documentation Assistant. J. Artif. Intell. Capsul. Netw. 2024, 6, 210–226. [Google Scholar] [CrossRef] [Scilit]
  34. Yassine, S.; Esghir, M.; Ibrihich, O. Using Artificial Intelligence Tools in the Judicial Domain and the Evaluation of Their Impact on the Prediction of Judgments. Procedia Comput. Sci. 2023, 220, 1021–1026. [Google Scholar] [CrossRef] [Scilit]
  35. Zhang, H.; Zhang, T.; Cao, F.; Wang, Z.; Zhang, Y.; Sun, Y.; Vicente, M.A. BCA: Bilinear Convolutional Neural Networks and Attention Networks for Legal Question Answering. AI Open 2022, 3, 172–181. [Google Scholar] [CrossRef] [Scilit]
  36. Khang, N.H.G.; Nhat, N.M.; Quoc, T.N.; Hoang, V.T. Vietnamese Legal Text Retrieval Based on Sparse and Dense Retrieval Approaches. Procedia Comput. Sci. 2024, 234, 196–203. [Google Scholar] [CrossRef] [Scilit]
  37. Aboasal, R.; Montasser, S.; Eldin, F.H.; Abdelwahab, A.; Abdelazim, H. Arabic Legal Information Retrieval: The Impact of Morphological Segmentation and Semantic Embeddings. Procedia Comput. Sci. 2026, 275, 275–282. [Google Scholar] [CrossRef] [Scilit]
  38. Meftah, M.C.E.; Soussa, A.; Herzallah, A. An Intelligent Arabic Legal Assistant System (IALAS) Based on Ontology. Transp. Res. Procedia 2025, 84, 440–447. [Google Scholar] [CrossRef] [Scilit]
  39. Riaz, C.H.; Hadi, M.U. Aura: An AI-Powered Legal Assistant for Enhancing Access to Justice in the UK Legal System. TechRxiv 2025. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  40. El Moussaoui, T.; Loqman, C.; Boumhidi, J. Decoding Legal Processes: AI-Driven System to Streamline Processing of the Criminal Records in Moroccan Courts. Intell. Syst. Appl. 2025, 25, 200487. [Google Scholar] [CrossRef] [Scilit]
  41. Rakhimova, D.; Turarbek, A.; Karyukin, V.; Sarsenbayeva, A.; Alieyev, R. Legal AI in Low-Resource Languages: Building and Evaluating QA Systems for the Kazakh Legislation. Computers 2025, 14, 354. [Google Scholar] [CrossRef] [Scilit]
  42. Shaikhygali, Z. Kazakh OSCAR Corpus. Kaggle Dataset. Available online: https://www.kaggle.com/datasets/zhaseke/kazakhoscarcorpus (accessed on 27 May 2026).
  43. itachi666. Dontsova Books. Kaggle Dataset. Available online: https://www.kaggle.com/datasets/itachi666/dontsova-books (accessed on 27 May 2026).
  44. Michail, A.; Clematide, S.; Sennrich, R. Examining Multilingual Embedding Models Cross-Lingually Through LLM-Generated Adversarial Examples. In Findings of the Association for Computational Linguistics: EMNLP 2025, Suzhou, China, 4–9 November 2025; Association for Computational Linguistics: Stroudsburg, PA, USA, 2025; pp. 2161–2170. [Google Scholar] [CrossRef] [Scilit]
  45. Wang, L.; Yang, N.; Huang, X.; Yang, L.; Majumder, R.; Wei, F. Multilingual E5 Text Embeddings: A Technical Report. arXiv 2024, arXiv:2402.05672. [Google Scholar] [CrossRef] [Scilit]
  46. Lee, J.; Chen, F.; Dua, S.; Cer, D.; Shanbhogue, M.; Naim, I.; Hernández Ábrego, G.; Li, Z.; Chen, K.; Vera, H.S.; et al. Gemini Embedding: Generalizable Embeddings from Gemini. arXiv 2025, arXiv:2503.07891. [Google Scholar] [CrossRef] [Scilit]
  47. Ciancone, M.; Kerboua, I.; Schaeffer, M.; Siblini, W. MTEB-French: Resources for French Sentence Embedding Evaluation and Analysis. arXiv 2024, arXiv:2405.20468. [Google Scholar] [CrossRef] [Scilit]
  48. Nurlykhan. KazEmbed-V5: Kazakh Embedding Model for RAG (Model Card). Available online: https://huggingface.co/Nurlykhan/kazembed-v5 (accessed on 23 June 2026).
  49. Sentence-Transformers. Paraphrase-Multilingual-Mpnet-Base-v2 (Model Card). Available online: https://huggingface.co/sentence-transformers/paraphrase-multilingual-mpnet-base-v2 (accessed on 23 June 2026).
  50. You, K. Semantics at an Angle: When Cosine Similarity Works Until It Doesn’t. arXiv 2025, arXiv:2504.16318. [Google Scholar] [CrossRef] [Scilit]
  51. Tleubayeva, A.; Makhambetova, Z.; Mansurova, A.; Shomanov, A. Enhancing Question Answering for Low-Resource Languages: The Case of Kazakh Language. In Proceedings of the 18th IEEE/ACM International Conference on Utility and Cloud Computing (UCC 2025), Nantes, France, 1–4 December 2025; Association for Computing Machinery: New York, NY, USA, 2025; p. 38. [Google Scholar] [CrossRef] [Scilit]
  52. Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, Ł.; Polosukhin, I. Attention Is All You Need. arXiv 2017, arXiv:1706.03762. [Google Scholar] [CrossRef] [Scilit]
  53. Liu, L.; Xu, X. Self-Attention Mechanism at the Token Level: Gradient Analysis and Algorithm Optimization. Knowl.-Based Syst. 2023, 277, 110784. [Google Scholar] [CrossRef] [Scilit]
  54. Landis, J.R.; Koch, G.G. The measurement of observer agreement for categorical data. Biometrics 1977, 33, 159–174. [Google Scholar] [CrossRef] [Scilit]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.