Terminology Enhanced Retrieval Augmented Generation for Spanish Legal Corpora
Paper · 2025 · Patricia Martín Chozas, Pablo Calleja and Carlos Rodríguez Limón
Summary
A person asking about Spanish labour law can use different words from the ones that appear in the statute. A search system has to bridge that gap before an answer can draw on the relevant provisions. The authors test a way to help it do so using a controlled vocabulary assembled from the Spanish Workers’ Statute. In their retrieval-augmented generation system, the question can be expanded with synonyms and related terms before the search. A separate ranking step then reassesses the retrieved passages, and a generator uses the selected material to compose an answer.
The study keeps its setting deliberately narrow. The statute provides the text to search, the source for a terminology resource containing 1,015 terms, and the basis for 149 manually validated question–answer pairs. The authors compare LLaMA3.2, Granite3-dense and Mistral as answer generators. For each, they test generation without retrieval and retrieval using either a general Spanish text encoder or one trained on Spanish legal texts. They also test each retrieval configuration with and without terminology expansion. This design makes it possible to ask what the vocabulary contributes after a system already has access to the statute.
Adding retrieved context produces the clearest gains on measures of wording overlap with the reference answers. For Mistral, ROUGE-L rises from 0.15 without retrieval to 0.23 with RoBERTalex, the legal encoder. Adding terminology expansion leaves that score at 0.23 in the results table. LLaMA3.2 gains more from expansion in the same retrieval setting, going from 0.21 to 0.23 on ROUGE-L. Semantic Answer Similarity gives a different picture. LLaMA3.2 scores 0.62 without retrieval and 0.56 with expanded RoBERTalex retrieval, even as the latter configuration improves its other reported scores over the no-retrieval baseline.
The vocabulary reached relatively few questions, which limits its effect across the evaluation as a whole. The authors also found errors on questions that required evidence from multiple sources. One result needs particular care. The paper’s narrative gives Mistral an increase in F1 and Semantic Answer Similarity when it adds expansion to RoBERTalex, while the corresponding table rows show unchanged F1 and lower Semantic Answer Similarity. Across the tabulated comparisons, terminology helps some configurations, ties others on several measures, and has a smaller and less consistent effect than adding retrieval. The experiment establishes how closely the answers resemble validated references in this setting. Whether expansion improves the legal correctness of individual answers or brings the necessary passages into view more reliably remains open.
Deep dive: Terminology Enhanced Retrieval Augmented Generation for Spanish Legal Corpora
A Spanish labour law study tests whether adding terms from a legal vocabulary to a question helps retrieve better evidence and produce better answers. · about 33 minutes to read
The problem and its context
Getting from a question to the right provision
A legal search begins with two pieces of language written for different purposes. A question describes what someone wants to know. A statute states rules, obligations and conditions in the language of legislation. Even when the question and the statute concern the same subject, the question can use an expression that gives a search system little evidence about where to look. A useful answer then depends on finding the connection between the two pieces of language before writing begins. The paper treats terminology as a resource for making that connection explicit.
The challenge has both a vocabulary side and a scope side. On the vocabulary side, legal texts can contain older expressions and terminology specific to a jurisdiction. The question may use a synonym, a more general label or another expression associated with the relevant legal concept. On the scope side, the paper notes that legal texts frequently use long sentences. Locating the right term can get a search close to a useful provision while leaving it with the task of identifying the conditions that govern the answer. Where a question depends on evidence from several places, the search also has to assemble enough of that evidence for the generator to use it.
The authors place the study in the context of Legal AI and the relative scarcity of resources tailored to Spanish legal language. Their concern is the availability of the corpora, terminologies and validated examples that support this kind of processing. They describe difficulties with approaches based on rules and earlier statistical methods when these approaches encounter long legal sentences, specialised usage and variation across jurisdictions. They also explain that the resources developed in prior projects had left gaps in semantic search and entity recognition for Spanish law. A small corpus with a terminology resource offers a way to investigate one of those gaps in a setting where the source of the vocabulary is known.
What legal infrastructure had already addressed
The paper distinguishes the search problem from problems that European legal information initiatives had already taken up. It describes EUR-Lex as a point of access to materials such as legislation, case law, treaties and proposals. It describes the European Case Law Identifier as a means of standardising the way cases are identified and cited, using a common identifier and associated metadata. Access and identification matter to information retrieval because they make legal materials easier to locate and reference. The question in this study concerns a later part of the task. Given a collection that can be searched, how does a system decide which passages are responsive to a question written in different terms?
Lynx is the immediate connection between those earlier efforts and the experiment. The project combined legal information infrastructure with services for processing and enriching legal texts. Its intended use included helping companies work through compliance questions across languages and legal systems. The terminology and evaluation material used in the paper came from work associated with Lynx. The experiment brings those resources together around one statute, so the authors can study vocabulary reuse on a defined question-answering task.
That history explains the appeal of a terminology list that already exists. Building a specialised vocabulary takes effort, and its entries have a purpose beyond appearing in a search query. The paper asks whether such a resource can also influence the behaviour of a retrieval system at the moment it searches. Its narrower question concerns a terminology with a particularly direct connection to the text. The authors take the vocabulary from the same source that the system searches, giving the added words a plausible route to relevant passages in that source.
Why pass retrieved text to an answer generator?
The authors describe earlier concern about the use of large language systems in specialised domains. A generator can produce a fluent statement even when its training supplied insufficient, outdated or unreliable information about the subject. The paper uses the term hallucination for the problem of producing unsupported or false material with the appearance of an answer. Updating a generator’s learned parameters also carries a computational cost, and the authors note that legal terminology changes over time. An arrangement that can consult an external source has a practical attraction in a domain where the source matters to the answer.
The authors illustrate their concern by pointing to a study that found hallucination rates of 69% to 88% in answers to legal questions from some of the systems it tested. The range belongs to that earlier research and its legal questions. It gives the motivation for working with source material in the Spanish labour law experiment, whose measures and scope are different. The paper also cites an assessment of the reliability of legal research tools when explaining why access to authoritative information matters even for systems presented as specialised. Large Legal Fictions and Hallucination-Free?
In the retrieval-augmented approach associated with Lewis and colleagues, a search supplies documents or passages that a generator can consult when answering. The legal study applies the same division of work. The system holds the statute outside the generator, searches it for each question and supplies the selected text at answer time. A change to the terminology or retrieval process can therefore change the evidence available for an answer without requiring a change to the generator’s parameters. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks
The paper also describes earlier retrieval-augmented work on tasks that require accurate or current knowledge, including question answering. Some approaches investigate ways to identify useful facts or assess the material a system retrieves. Others show that access to relevant external information can reduce hallucinations in conversational settings. These studies motivate the use of retrieval, while leaving the Spanish legal experiment to specify how it searches and what the resulting answers are measured against. Self-RAG, REPLUG and Retrieval Augmentation Reduces Hallucination in Conversation
Where vocabulary enters the picture
The authors discuss specialised pretraining and fine-tuning as other ways of adapting to a domain. Their account also mentions reinforcement learning from human feedback and work applying retrieval-augmented techniques to document tasks in Spanish public institutions. Adaptation can affect how a component represents text or follows instructions. The experiment adds a question about the inputs it receives. If a legal terminology identifies expressions that a retriever might need, the system can use those expressions to modify its search before it asks the generator to do anything. Training language models to follow instructions with human feedback
This distinction defines the study’s contribution. The authors saw relatively little work on using dedicated linguistic resources within retrieval-augmented systems for Spanish legal text. The availability of specialised encoders gave them a comparison within that setting. An encoder trained on Spanish legal material may already represent some relationships among legal expressions. The terminology gives a separate way to expose relationships by adding words to a query. Comparing expanded and unexpanded searches with each encoder lets the authors study whether these two forms of domain knowledge work together.
The case also brings the search and answer questions into contact. A retrieval system can use a vocabulary to try to find better evidence. The benefit matters for the task if it survives the ranking stage and leads to a better answer. Conversely, an answer that fares better against a reference could reflect several choices in the pipeline. The study puts the vocabulary inside a full system, so its design and results have to be read with both levels in view.
The method, step by step
From the statute to an answer
The pipeline starts with the Spanish Workers’ Statute. The authors break its text into units that a search can return, represent those units numerically and store the representations in a searchable index. The index is prepared before a question arrives. The terminology resource is also prepared in advance. It supplies words or expressions that can be introduced into a search when a question matches its coverage.
At question time, the expansion variant consults the vocabulary before encoding the search query. The initial search uses the query representation to find nearby passages in the index. A second scoring stage reads a query and a candidate passage together to decide how they should be ordered. The highest-ranked material then passes to the answer generator as context. The unexpanded retrieval variants follow the same broad route with the question left in its original form for the search. The no-retrieval comparison sends the question for answer generation without adding passages from the index.
How the system retrieves evidence and generates an answer
The steps in order.
The sequence matters because an expansion can only affect the later stages through the search process described in the paper. Its direct output is a changed query. The ranking stages still have to find and prioritise useful passages, and the generator still has to read and express what those passages support. This separates the study’s use of a terminology from requiring an answer to contain a prescribed legal expression.
Preparing the collection and the vocabulary
The corpus contains 1,568 sentences and 54,849 tokens. The sentence count describes the statute as a body of text. The token count describes its size in units of tokenization and gives another sense of the amount of material involved. The authors report these counts for the corpus and describe segmenting it for the search index. The relationship between the reported sentence count and the number of indexed passages is left unspecified. This is worth distinguishing because a search can index units that span a different amount of text from the units used to describe the corpus.
The data selection was deliberate. The authors wanted a domain-specific collection small enough to study within a low-resource setting. Spanish labour law supplies the domain, and the Workers’ Statute supplies a bounded source. The system consequently searches for evidence within a particular text. The vocabulary and reference answers both have a traceable relationship to that text, which makes the experiment easier to interpret than a setting in which the source of each resource varies from question to question.
The terminology is a semi-automatically generated resource developed in the Lynx project. It contains 1,015 terms drawn from the statute. Main entries are accompanied by synonyms and by broader, narrower and related terms. These relationships carry different information. Synonyms address variations in how a concept can be named. A broader expression points toward a more general category, and a narrower one toward a more specific concept within it. A related expression can provide a connection without implying that the two expressions can replace each other. The resource therefore carries more structure than a plain list of words found in the text.
There is a distinction between the links available in the vocabulary and the links demonstrated in the experiment. The resource includes broader and narrower terms, while the paper characterises the query intervention in terms of synonyms and related expressions. It leaves the precise contribution of each relation type open. That distinction keeps the contents of the resource from becoming a claim about how comprehensively its relationships were used. A reader can follow the expansion mechanism without assuming that every available type of entry was activated or assessed separately.
The evaluation resource consists of 149 manually validated question–answer pairs from the same statute. Each pair supplies a question for the system and an expected answer for comparison. The reference answer and the indexed corpus have different roles. The corpus is available to the retrieval system as evidence. The reference answer supplies the target for scoring the generated response. The paper describes these pairs as evaluation data and gives no separate training split or task-specific training procedure based on them.
Adding terms before the search
Query expansion changes a search by incorporating expressions that supplement the ones in the original question. Consider the situation the authors are trying to address. A question contains an expression for a concept that appears under a different name in the statute. If the terminology links those expressions, the system can put the statute’s wording into the search query alongside the language supplied by the question. For a reader following the pipeline, the essential operation is that the search receives extra evidence about the intended concept before it looks for passages.
A related term offers a slightly different route. It can point to material that is relevant to the question because of a conceptual association, even where it would be inappropriate to substitute that expression for the original one in a legal answer. This difference is especially important when the added term changes the level of generality. Moving toward a broader expression may make more passages eligible for consideration. A more specific expression might direct attention to a smaller portion of the statute. The intended benefit is greater coverage of useful evidence, with the ranking stages responsible for judging which candidates deserve priority.
The experiment compares the overall effect of such changes to the query. The paper gives the vocabulary source, the position of expansion in the pipeline and the kinds of relations that motivate it. It does not specify enough matching rules to reconstruct which individual expressions were added to each question. Details such as how a match handles alternative word forms, how multiple possible expansions are chosen and how they are ordered therefore remain open. The authors' later observation about low synonym recall makes the coverage of this step consequential. Any question that triggers no expansion offers little opportunity to observe what the vocabulary could have done.
The design also makes the original question valuable in its own right. The question supplies the requested issue and the way the user frames it. Additional expressions supply clues to vocabulary used in the statute. A close match between those clues and the evidence is useful only insofar as the resulting passages still address the requested issue. The paper tests this balance by comparing answers obtained from expanded and unexpanded versions of the search under otherwise corresponding retrieval settings.
Encoding queries and passages for the initial ranking
A text encoder produces an embedding, a vector of numbers that represents a piece of text. A retrieval system compares a query vector to passage vectors to estimate semantic similarity, or closeness of meaning. A query and passage can be close under this representation even when their wording differs. In this experiment, expansion comes before encoding, so the added expressions can influence this numerical representation and thereby change which passages the initial ranking favours.
The authors use FAISS to store and search the passage vectors. Its role is to locate candidates by their vector similarity to the query. Encoding the corpus in advance lets the search reuse the stored representations each time it processes a question. The encoding choice applies on both sides of the comparison. The corpus and the query have to be represented in the corresponding vector space for the system to compare them as intended.
The first encoder, roberta-base-bne, is a Spanish adaptation of RoBERTa trained on a corpus from the Biblioteca Nacional de España. The training collection includes administrative and legal writing within a broader Spanish collection. The second encoder, RoBERTalex, was trained on Spanish legal texts. Both are associated with the PlanTL initiative. The paper compares general and more narrowly specialised training within Spanish, a practical choice given that both the statute and the questions are in Spanish. RoBERTa
The comparison changes the representations used to search, even if the underlying text and the wording of a particular query stay the same. In the converse comparison, the encoder stays in place and the query can acquire new terms. A difference associated with the legal encoder and a difference associated with expansion thus reflect different interventions. One changes how text is represented. The other changes the text that is represented on the query side. Their combined effect could vary with the text already available to the encoder and the relevance of the extra terms.
The paper describes initial ranking by vector similarity and subsequent ranking by a cross-encoder. It gives no equations defining either score and leaves the exact vector similarity calculation unspecified. The formal specification within the paper is the ordering of operations and the identity of the components. The score for the initial search should therefore be understood at the level the authors document, as a comparison of the separately encoded query and passages.
Reranking by reading the pair together
Initial retrieval narrows the corpus to a set of candidates. A cross-encoder then evaluates a query and a candidate passage jointly. This is the reranking stage. Rather than relying solely on the proximity of representations produced separately, the cross-encoder assigns a relevance score after considering the pair together. The authors use ms-marco-MiniLM-L-12-v2 for this step.
The division between the two stages gives each one a different job. The first stage searches the indexed collection. The second revisits the candidates already returned and decides which ones should have priority for generation. A passage that looks broadly similar to a labour law question can receive a different position when the scorer considers how well it addresses the query as a whole. Conversely, the second stage can reorder only the passages it receives. If useful evidence falls outside the initial candidate set, reranking alone supplies no way to bring it back.
The paper presents reranking as part of the retrieval system. Its account places it after query expansion and initial search, before the context reaches the generator. It describes the cross-encoder as assessing query–passage relevance and leaves some details of how the query is passed between stages unspecified. In particular, the results do not isolate what happens when expansion changes only the initial search and the reranker scores candidates solely against the original question. The measured outcome belongs to the implemented pipeline as a whole.
Prompting and producing the answer
For generation, the authors use LLaMA3.2, Granite3-dense and Mistral. They describe choosing these systems for their text processing and contextual capabilities, with particular interest in their suitability for Spanish and specialised writing. Mistral is also discussed in connection with multilingual and domain-specific training. The experiment compares their outputs on the same legal task. The explanations the paper offers for differences in performance concern likely advantages of their training. The experiment changes the generator as a whole, leaving individual training factors untested. Mistral 7B
The prompt is the text through which the question and context are presented to the generator. The authors report following prompt design practices centred on clarity, specificity, context and length. In the retrieval conditions, prompt construction gives the selected evidence a route into the answer. The method is described as response generation from the information retrieved and ranked upstream. It is evaluated through the written response, so a good ranking is an intermediate accomplishment and the answer still depends on how the generator handles the supplied material.
Different settings can produce different answers even with a common evidence source. A generator may express the statute in wording that closely follows the reference, use a paraphrase or elaborate beyond the information the reference includes. The paper’s metrics capture some of those differences. They also give a reason to compare the same generator across retrieval settings, since comparing different generators at once combines changes in evidence delivery with changes in expression.
The experimental implementation is available in the authors’ open term-rag repository. The account in the paper describes preparation of the corpus, use of an existing terminology and use of existing encoders and generators. The preparation specific to this experiment is chiefly the organisation of the legal text for search and its use alongside the vocabulary and validated questions.
Experiments and results
What was compared
The evaluation uses the 149 manually validated Spanish Workers’ Statute question–answer pairs. The experiment runs the comparison separately for LLaMA3.2, Granite3-dense and Mistral. Each generator has a no-retrieval baseline, retrieval with roberta-base-bne, retrieval with RoBERTalex, expanded retrieval with roberta-base-bne, and expanded retrieval with RoBERTalex. In the results table, the general Spanish encoder appears under the shorter label roberta-base. The method identifies it as roberta-base-bne.
The choice of baselines determines which questions the results can address. Comparing a generator with and without retrieved text tests the outcome of supplying the evidence selected by the retrieval pipeline. Keeping retrieval and the generator fixed while changing the encoder tests the effect of using a different representation for search within that pipeline. Comparing expansion with its corresponding unexpanded condition brings the terminology intervention into view. The complete comparison varies generator, encoder and expansion in a way that permits these narrower readings. It also makes an overall ranking of whole systems less informative than a comparison matched to a particular question about the method.
The reported scores are comparisons between generated responses and the reference answers for this evaluation set. Each metric describes a different kind of agreement. A system can improve on one while tying or declining on another, so the result is best read as a profile of response behaviour. The paper gives no separate train, validation or test counts for these pairs. The numbers below refer to the reported evaluation on the Workers’ Statute questions.
What the scores measure
The paper reports ROUGE-1, ROUGE-2 and ROUGE-L. ROUGE measures overlap with a reference, with each variant defining overlap differently. ROUGE-1 concerns individual words. ROUGE-2 concerns adjacent pairs of words, making the comparison sensitive to short stretches of matching phrasing. Both are examples of n-gram comparisons, where an n-gram is a sequence of adjacent units of a chosen length. ROUGE-L captures a shared sequence in the same order while allowing gaps. Together, the variants distinguish overlap in vocabulary from overlap in how words are arranged.
An answer can gain on these measures by expressing more of the reference content in similar language. Supplying the statute at generation time can give it the same legal wording that informs a reference answer. The score then picks up a useful connection between evidence and output. A reference can also express a valid answer in only one of several possible ways, which means that wording overlap has to be read in light of how freely a correct answer can be phrased. This is particularly relevant to the paper’s emphasis on synonymous expressions. The retrieval intervention can recognise vocabulary variation even when an overlap measure penalises some of that variation in the final answer.
F1 balances precision and recall. Here, precision concerns how much of what is counted in the generated answer matches what is expected, and recall concerns how much of what is expected the answer recovers. The balance makes F1 responsive both to missing material and to extra material that fails to match. The paper gives this rationale for F1, while leaving the exact matching and normalisation procedure unspecified. The reported F1 values are therefore best cited as results from the authors’ scoring setup.
Semantic Answer Similarity, abbreviated SAS, compares the meaning of the generated response with the meaning of the reference. It is intended to give credit for agreement beyond shared wording. BERTScore likewise uses representations sensitive to the context in which words appear to assess similarity between a candidate and a reference. The paper labels this column BERT. Both measures provide a wider view of resemblance than lexical matching, but they can react differently to the same change in an answer. The disagreement in the results matters because a statement can remain semantically close to another statement while changing a detail important to legal relevance.
The strongest pattern comes from retrieving context
LLaMA3.2 illustrates the effect of moving from generation alone to the retrieval conditions. Its ROUGE-1 score is 0.24 without retrieval, 0.28 with the general Spanish encoder and 0.31 with the legal encoder. The expanded versions score 0.29 and 0.33, respectively. Within this generator’s results, the lexical-overlap advantage appears in the move to retrieval and continues across the choice of encoder and the addition of terminology. The graph shows the full comparison for this metric, including the setting that introduced the vocabulary the authors wanted to test.
LLaMA3.2 retrieval settings on the Spanish Workers’ Statute questions by ROUGE-1
The legal encoder leads the corresponding general encoder settings, and expansion raises the score for either encoder.
The numbers
| System or setting | ROUGE-1 |
|---|---|
| No retrieval | 0.24 |
| roberta-base-bne | 0.28 |
| RoBERTalex | 0.31 |
| roberta-base-bne with expansion | 0.29 |
| RoBERTalex with expansion (this paper) | 0.33 |
The same generator shows a related pattern on ROUGE-2 and ROUGE-L. Its no-retrieval scores are 0.06 and 0.14, respectively. With RoBERTalex, they reach 0.13 and 0.21. Expanded RoBERTalex gives 0.14 and 0.23 on those measures. This means the observed improvement includes adjacent-word overlap and a measure sensitive to shared order. Its F1 goes from 0.1 without retrieval to 0.18 with RoBERTalex and 0.19 when expansion is added to that configuration. These results concern the output text. They show that the full retrieval configurations lead to answers that more closely resemble the references under the reported measures.
Granite3-dense starts with the lowest ROUGE-L among the three generators at 0.11 in the no-retrieval condition. It reaches 0.14 with either unexpanded encoder. The expanded general encoder gives 0.14, while expanded RoBERTalex gives 0.15. Its other overlap measures also improve on the no-retrieval baseline. For example, on ROUGE-2, the baseline is 0.04 and both RoBERTalex variants score 0.08. F1 follows a less uniform ordering within its retrieval conditions. The general encoder gives 0.12 without expansion, while the legal encoder gives 0.11 without expansion. Both expanded conditions score 0.12.
Mistral’s lexical scores start higher in several columns. Its no-retrieval ROUGE-1 is 0.27 and its ROUGE-L is 0.15. With roberta-base-bne they are 0.33 and 0.21, and with RoBERTalex they are 0.35 and 0.23. The two expanded settings retain those respective values for both measures. On ROUGE-2, Mistral scores 0.06 without retrieval, 0.12 with the general encoder and 0.14 with the legal encoder. Expansion again gives the same reported values within each encoder. This is a clear example of retrieval contributing to measured answer quality while expansion has little visible effect on those particular output scores.
Where Mistral leads and where its scores tie
The paper describes Mistral as having the strongest overall performance. Its best tabulated values include 0.35 for ROUGE-1, 0.14 for ROUGE-2, 0.23 for ROUGE-L, 0.19 for F1 and 0.95 for BERTScore. The legal encoder reaches those values with Mistral in both the expanded and unexpanded rows. For BERTScore, the general Spanish encoder also gives 0.95 with or without expansion, compared with Mistral’s 0.93 without retrieval. The near-uniform BERTScore for its retrieval variants makes that column useful for describing the overall effect of supplied context but less useful for distinguishing the retrieval settings.
The strongest expanded RoBERTalex setting for LLaMA3.2 ties Mistral on ROUGE-2, ROUGE-L and F1. The F1 chart below shows how Mistral reaches its tabulated best value. Its two general-encoder settings both give 0.18, and its two legal-encoder settings both give 0.19. The star identifies the proposed expanded legal setting, which shares the top F1 with its unexpanded counterpart.
Mistral retrieval settings on the Spanish Workers’ Statute questions by F1
The legal encoder gives the highest F1, with a tie between the expanded and unexpanded settings.
The numbers
| System or setting | F1 |
|---|---|
| No retrieval | 0.12 |
| roberta-base-bne | 0.18 |
| RoBERTalex | 0.19 |
| roberta-base-bne with expansion | 0.18 |
| RoBERTalex with expansion (this paper) | 0.19 |
The paper suggests that Mistral’s performance may reflect its exposure to specialised material in training. The quantitative comparison supports the observation that the tested Mistral configurations often produce answers closer to the references. It leaves the reason open because the comparison changes the generator, with all the differences that entails. Its advantage also depends on the metric. SAS gives examples where LLaMA3.2 scores higher, including the no-retrieval comparison. The paper’s overall assessment of Mistral makes the most sense as a description of its performance across the reported columns, including shared best values.
The semantic comparison changes the ordering
SAS is the clearest qualification to the general result in favour of retrieval. LLaMA3.2 has its highest SAS in the no-retrieval condition. Its expanded legal setting makes gains over its other retrieval settings and still comes below the no-retrieval score. The chart keeps the generator constant so that this change in the ordering is visible. The star identifies the paper’s expanded legal configuration.
LLaMA3.2 retrieval settings on the Spanish Workers’ Statute questions by Semantic Answer Similarity
Generation without retrieval leads this comparison, and the expanded legal setting scores highest among the retrieval variants.
The numbers
| System or setting | SAS |
|---|---|
| No retrieval | 0.62 |
| roberta-base-bne | 0.53 |
| RoBERTalex | 0.55 |
| roberta-base-bne with expansion | 0.54 |
| RoBERTalex with expansion (this paper) | 0.56 |
For Granite3-dense, the no-retrieval SAS is 0.55. The general encoder gives 0.53 with and without expansion. Its RoBERTalex scores are 0.56 without expansion and 0.57 with expansion. For Mistral, the baseline is 0.58. The general encoder scores 0.56 before expansion and 0.57 after it. RoBERTalex scores 0.59 before expansion and 0.58 in the corresponding expanded row. This gives examples of improvements and declines depending on the combination. It also helps explain why the paper’s claim about the strongest configurations has to be tied to individual measures.
BERTScore follows a different pattern from SAS. LLaMA3.2 scores 0.9 without retrieval, 0.93 in both general-encoder settings and 0.94 in both legal-encoder settings. Granite3-dense scores 0.77 without retrieval and also 0.77 with unexpanded RoBERTalex. Its other retrieval settings reach 0.79. These are similarities to the expected answers, and the discussion remarks that high values sometimes coexist with answers of questionable relevance. The reported numbers establish the differences seen by the metrics. The paper provides no separate result for how frequently a response is substantively correct under legal review.
A discrepancy in the reported expansion gains
In describing the results, the authors call the effect of query expansion moderate and report average gains of approximately 1% to 5%, with the figure varying by metric and system. It also gives a specific Mistral example. With RoBERTalex, expansion is said to raise F1 from 0.19 to 0.21 and SAS from 0.59 to 0.60. The results table reports 0.19 for F1 in both of those rows and SAS of 0.59 without expansion and 0.58 with expansion. Both the size and direction of the claimed gain therefore need to be read against the tabulated comparison.
The paper offers no reconciliation of these values. The charts above use the table, which gives a common set of scores for all conditions. Under that reading, LLaMA3.2 and Granite3-dense supply examples of positive expansion effects with the legal encoder. The Mistral result in the narrative remains a separate, unresolved report. Its tabulated values support a tie on F1 and a lower SAS in the expanded legal configuration. The broader evidence for terminology is consequently in the matched gains that can be identified in the table, with the size of those gains dependent on the generator, encoder and metric.
What the ablations show
Comparing each expanded search with its unexpanded counterpart
The direct ablation-style comparison is the switch between an unexpanded query and an expanded one with the same retrieval encoder and answer generator. The vocabulary intervention has a clear place in the process, so these rows are more informative about it than a comparison between generation alone and the full proposed system. They measure its effect on final answers within each configuration, with ranking and response generation downstream of the changed query.
The clearest positive comparisons for LLaMA3.2 occur with RoBERTalex. Its ROUGE-1, ROUGE-2, ROUGE-L, F1 and SAS are all higher with expansion, and its BERTScore is 0.94 in both settings. With the general Spanish encoder, expansion raises ROUGE-1, ROUGE-2, ROUGE-L and SAS while leaving the reported F1 and BERTScore unchanged. The comparison suggests that explicit terminology can add something even when a search has a legal encoder. Since the outcomes are answer comparisons, the evidence concerns the benefit of the complete route from the changed query to the response.
Granite3-dense shows a similarly instructive dependence on the retrieval encoder. Its scores with roberta-base-bne are unchanged across the reported measures when expansion is added. In the RoBERTalex setting, expansion is associated with gains on ROUGE-1, ROUGE-L, F1, SAS and BERTScore, while ROUGE-2 remains at 0.08. One reading is that the vocabulary’s measured value depends on how its added terms are represented and consequently used in the search. The design supports variation across encoder settings. It leaves open whether the observed differences arose mainly in candidate retrieval, the reranking of those candidates or the way the generator used different passages.
Mistral shows the limits of generalising from those positive comparisons. In the table, expansion leaves its ROUGE scores, F1 and BERTScore unchanged for both encoders. SAS rises with the general encoder and falls with the legal encoder. There are several ways such a pattern could arise. A search might already retrieve suitable material before expansion. Changed passages might lead to answers that obtain the same aggregate overlap score. Some questions might improve while others decline. The paper’s aggregate scores make these explanations possible, without choosing among them.
What changing the encoder can establish
The encoder comparison keeps the role of the terminology distinct from the role of Spanish legal training. In the unexpanded retrieval conditions, Mistral and LLaMA3.2 have higher scores on several overlap measures with RoBERTalex than with roberta-base-bne. This shows an advantage for the legal encoder on those answer measures even before the vocabulary is introduced. Granite3-dense is a reminder that the ordering depends on generation and scoring as well. Without expansion its ROUGE-L ties across the encoders, while its F1 and BERTScore are higher with the general encoder.
Once expansion is enabled, the corresponding RoBERTalex settings offer stronger overlap results in much of the table. The configuration is especially competitive for LLaMA3.2, which reaches the same ROUGE-2, ROUGE-L and F1 as Mistral in the expanded legal condition. A useful distinction is between the role the experiment assigns to a component and the mechanism it has measured. The legal encoder is designed to represent specialised language, and the terminology is designed to make particular lexical relationships available. Their joint results show that these choices can coexist productively. The experiment does not report a measurement of how the encoder represents an individual term or how that representation alters the rank of an identified provision.
The generator comparison provides a further control for interpretation. Every retriever is paired with all the generators, so one can see whether the same retrieval setting produces similar changes across them. The responses vary, particularly once expansion is introduced. A search setting can therefore be characterised by its average effect on these answers only with the generator named. The experiment gives little basis for assuming that a change which helps one generator will make the same contribution to another.
What reranking and error analysis add
The comparison with the no-retrieval baseline measures supplying context after the whole retrieval process. The paper includes the cross-encoder in that process and describes reranking as a way to prioritise query-relevant candidates. There is no separate unreranked retrieval row in the results. The improvements over generation alone therefore encompass the initial search, the cross-encoder ranking and the presentation of context to the generator. The isolated contribution of reranking remains undetermined, as does any interaction between reranking and the extra terms in the query.
The authors’ qualitative analysis identifies two points at which the benefits can be limited. The first comes early. The terminology has low synonym recall in this use, and relatively few questions are expanded. This means that the evaluation average combines questions on which the vocabulary can act with questions for which it has little or no direct role. The authors do not report the count of expanded questions or separate scores for them. The aggregate figure consequently combines the breadth of terminology coverage with whatever effect expansion has when it applies.
The second point arises when a question needs more than a close match to one passage. The authors found that several failures involved questions requiring multiple references. A candidate can be relevant by itself and still leave a necessary piece of evidence missing. The first search has to include the different sources, the second ranking has to retain the pertinent material, and the generator has to combine it accurately. The observed failures show that some questions place a demand on the pipeline beyond identifying a legal concept under the right name. The analysis does not give a stage-by-stage diagnosis for the failed examples, so the source of each missing or mishandled piece of evidence stays open.
Taken together, these comparisons support a specific interpretation. Retrieval delivers the more consistent improvements on answer overlap. Changing the encoder modifies how that retrieval behaves, with several advantages for the legal encoder. Terminology expansion adds a measurable benefit in some matched comparisons. The coverage and multi-reference analyses explain where the method faces practical bottlenecks, while the lack of passage-level judgments leaves the exact chain from added term to better evidence unmeasured.
Limitations
Limits identified by the authors
The authors identify the size of the reference dataset as a primary limitation. The 149 manually validated pairs make a comparison possible for the Spanish Workers’ Statute, while giving a limited basis for representing the range of questions a legal system might receive. This matters for the expansion experiment in particular. A terminology can only exhibit an effect where the sample contains expressions it covers. A sample with relatively few such questions offers a limited view of both the benefits and the mistakes that adding terms might produce.
The authors also report that the vocabulary has low recall for synonyms in the questions. This is a limitation of applicability as well as a limitation of average performance. The resource is drawn from the statute, but a question can use language that does not activate the relevant entry. The authors call for more specific and developed terminologies and further work on automatic term extraction. Their conclusion links the quality of that resource to whether the proposed intervention has a chance to act across the evaluation.
Questions that require multiple references are another limitation the authors specifically identify. Finding the right expression for part of a question may lead to one useful passage while leaving the answer incomplete. The paper’s error analysis treats this as difficult for current retrieval systems. Its proposed directions include investigating how structured legal data such as court rulings could be used alongside text and how a system could adapt retrieval to the complexity of the question. These directions describe future work on evidence coverage and selection. The experiment reports no evaluation of those extensions.
The authors give particular attention to the limits of answer scoring. They explain that BERTScore can be high for answers whose actual relevance is weaker than the score suggests. They also note that strict word-sequence comparisons can keep ROUGE low. The proposed use of RAGAS belongs to their discussion of possible future evaluation. It was considered as a way to obtain a fuller assessment of retrieval-augmented responses and study the effects of expansion and reranking. All results in the paper come from the reported overlap and similarity metrics. Ragas
Limits visible in the experimental setup
The evaluation has a close fit among the terminology, the questions and the corpus. It is an informative arrangement for studying whether vocabulary derived from a statute can assist retrieval over that statute. It leaves a transfer question open. A vocabulary drawn from one text could have different coverage when used on another statute, a collection containing several kinds of legal material or a different legal jurisdiction. The observed performance is evidence about the resource and the collection used together. The study contains no cross-corpus comparison that would measure how much of the effect carries over.
That common source also shapes the interpretation of lexical overlap. The corpus and the references are grounded in the same statute. Providing passages can make its wording available to a generator, which may then use terms that also appear in the reference. This is a plausible contributor to the strong movement in ROUGE. It is useful if the retrieved passage supports what the answer says. Establishing that support for individual answers would require inspecting the relevant passages and claims, which the reported metrics do not do. The evaluation therefore leaves room for both well-grounded paraphrases that receive modest lexical credit and closely worded answers that mishandle a material qualification.
The link between retrieval and answer quality is another open part of the design. Scores are given for generated outputs. The paper reports neither the rank of annotated supporting passages nor how many relevant passages each query returned. An increase in answer quality can be consistent with improved retrieval, even if a direct measurement of that change is absent. A stable answer score leaves still more possibilities. It can coexist with a changed ranking, with different passages that convey the same evidence, or with a generator whose output scarcely changes in spite of new context. Those possibilities have different implications for the vocabulary and the search, and the aggregate answer scores cannot separate them.
Likewise, the comparison under the no-retrieval baseline does not provide direct evidence for how often answers are grounded in the statute once retrieval is enabled. Supplying a passage makes it possible to base the response on that passage. The evaluation asks how similar the output is to a reference answer, a distinct question from whether each assertion is supported. A study interested in the hallucination concern introduced at the beginning of the paper would need judgments of claim support and errors. The hallucination rates cited from earlier work belong to those studies and cannot serve as a baseline for this experiment’s answer metrics.
The implementation details available in the paper support a description of the system at the level of components. They leave several choices that could affect passage retrieval difficult to assess from the article alone. The paper omits a full account of the chunk boundaries used in indexing and the matching procedure for query expansion. It also gives no systematic comparison of different amounts of retrieved context. A passage boundary can influence whether a legal condition stays with the rule it qualifies. A matching rule can determine whether a term is added at all. The absence of those comparisons gives the reported result a clearly defined level of interpretation. It is an evaluation of the implemented configurations, with the sensitivity to such choices still open.
How precisely the small changes can be read
The results appear as aggregate point scores. The paper reports no uncertainty estimates or tests of the stability of the differences. With a small evaluation dataset and relatively few expanded questions, this complicates the reading of nearby values. A difference in the printed table is an observed difference under the evaluation used. The table leaves open how consistently that difference would recur across another sample of questions, and ties at the reported precision leave open variation beneath the displayed digits.
The Mistral discrepancy adds a separate reporting issue. The narrative and the table disagree for F1 and SAS in the expanded RoBERTalex comparison. The table supplies results for all configurations in a consistent layout and therefore makes a sensible basis for comparing rows. Resolving the particular conflict would require a clarification of the reported values. As a result, that example offers weaker support for the narrative’s characterisation of expansion than the positive matched comparisons for LLaMA3.2 and Granite3-dense.
Finally, the condition-by-condition scores address a task narrower than legal advice. The study gives a real statute to a system and asks it to answer validated questions about that source. This setup can measure whether the system’s answers resemble known responses and help identify where terminology improves the pipeline. Correctness when a question depends on additional factual circumstances, other legal materials or evidence from several sources is a further matter. The authors’ analysis of multi-reference failures gives a concrete reason to keep the conclusion tied to the questions and source actually evaluated.
What came after
The subsequent citing work identified here takes terminology into a different task. Terminology-Augmented Generation for Intangible Cultural Heritage places it in a controlled translation framework. In the legal study, the terminology helps specify what the system should search for before it generates an answer. In the later work, the title places terminology alongside a machine translation task for intangible cultural heritage. The connection is the use of an explicit terminological resource in a generation workflow where specialised word choices matter. Terminology-Augmented Generation for Intangible Cultural Heritage
The distinction between the tasks is at the level of what the system is asked to produce. A legal answer has to respond to a question with evidence available in legal text. A translation has to convey a source text in another language, and the later title indicates that terminology is part of the framework for controlling that process. The citation establishes a connection between the works at that level. The later work’s ranking procedure, handling of synonyms, evaluation and results remain unspecified here, so the connection supports a description of the move from legal question answering to controlled translation. It leaves open which parts of the Spanish legal retrieval procedure, if any, were carried over.
Cite
Cite as Patricia Martín Chozas, Pablo Calleja and Carlos Rodríguez Limón. 2025. Terminology Enhanced Retrieval Augmented Generation for Spanish Legal Corpora. Proceedings of the 5th Conference on Language, Data and Knowledge.
@inproceedings{chozas2025terminology,
title = {{Terminology Enhanced Retrieval Augmented Generation for Spanish Legal Corpora}},
author = {Patricia Martín Chozas, Pablo Calleja and Carlos Rodríguez Limón},
booktitle = {Proceedings of the 5th Conference on Language, Data and Knowledge},
year = {2025},
url = {https://aclanthology.org/2025.ldk-1.16/}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/chozas-2025-terminology-enhanced-retrieval-augmented-generation/