Preprint
Brief Report

This version is not peer-reviewed.

Private Local Large Language Model for Generating Context-Aware Responses About the Regulations of Book Four of the Civil Code of Catalonia and the Notary Profession of Spain

Submitted:

27 June 2026

Posted:

29 June 2026

You are already at the latest version

Abstract
The task of training machines to “understand” legal language has proven to be non-trivial. Large language models (LLMs) represent a cutting-edge breakthrough in the deep learning models designed for processing human languages. A private LLM is a controlled AI system that uses proprietary data to generate responses while enforcing security, access control, and governance. This study created a retrieval-augmented generation (RAG) local LLM to ensure accurate and traceable outputs: several chat models were locally installed, including Reasoner v1, Llama 3 8B Instruct, DeepSeek-R1-Distill-Qwen-14B, Mistral Instruct, Orca2 (Full), Wizard v1.2, Hermes, Snoozy, and Phi-3 Mini Instruct. All models were tested, but final analysis was performed using Llama 3 8B Instruct. The LLM based on Llama 3 8B Instruct indexed Book Four of the Civil Code of Catalonia relating to Successions and the regulations of the Notary Profession of Spain for summarization and answering questions in a context of increased security. The model summarized and replied to specific questions in a reasonable manner in terms of fluency (3+, 80%), coherence (3+, 80%), factuality (3+, 40%; 2+, 60%), and relevance (3+, 60%) metrics, but was not absent of information loss and contextual misinterpretation in complex questions. In comparison with Grok 4.2 and GPT5, the local LLM had comparable content quality, it was characterized by answers of less length and less sources, but replies of higher similarity to human (% human similarity) (all P values < 0.005). In conclusion, in the field of legal sciences, this technology represents an opportunity. However, only precise information and secure legal reliability should be considered valid.
Keywords: 
;  ;  ;  ;  ;  ;  ;  ;  ;  

1. Introduction

1.1. Fourth Book of Civil Code of Catalonia

The current law, following the plan for the codification of Catalan civil law outlined by Law 29/2003, of December 30, the first law of the Civil Code of Catalonia [1], approved the fourth book of the Civil Code, dedicated to the law of succession [2].
Book Four represented both technical and other innovations that reflected legal policy decisions with clear social impact [3]. The latter included a comprehensive overhaul of the system of inheritance agreements, the reconsideration of inheritance rights in intestate successions between spouses or cohabitants, the modification of the rules for calculating the statutory share, the new regulation of the widow’s share, and the elimination of reserved portions [2].
Book Four maintained the succession principles of Catalan law as they are embodied in the Succession Code [4]: the principles of need of an heir, universality of the title of an heir, incompatibility of succession titles, prevalence of the voluntary title, and permanence of the succession title [2].
These principles, which distinguish Catalan inheritance law from many other legal systems, have worked reasonably well in inheritance practice and so far, their alteration has not been considered appropriate [2].
Book Four contains six titles and several provisions. Title I of Book Four contains the general provisions regarding succession upon death. Title II deals with testate succession and begins with a chapter on wills, codicils, and testamentary memoranda. Other topics include the nullity and ineffectiveness of wills and testamentary provisions, institution of heir and fiduciary provisions, hereditary substitutions, trusts, legacies and modes of succession, and executors. Title III describes contractual succession and donations mortis causa. Title IV deals with intestate succession. Title V with other inheritance rights determined by law. Title VI deals with the acquisition of inheritance, and Book Four finishes with several provisions [2].

1.2. Regulations for the Organization and System of the Notary Profession

The law of notaries in Spain dates back to 1862 [5]. The Decree of June 2, 1944, approving the regulations for the organization and system of the notary profession was published by the BOE number 189 in 1944 [6]. Notaries are both public officials and legal professionals, and this dual nature is reflected in the organization of the notarial profession [7]. As public officials, they exercise notarial public faith, which has and protects a dual purpose. In the realm of facts, the accuracy of what the notary sees, hears, or perceives through their senses. In the realm of law, the authenticity and probative force of the declarations of intent of the parties in the public instrument drawn up in accordance with the law. Notably, the notary profession enjoys full autonomy and independence in its function, and in its hierarchical organization, it directly depends on the Ministry of Justice and the Directorate General of Registries and Notaries. Title I and II contain articles on notaries. Title III describes the notarial function. Title IV: Notary organization structure. Title VI presents the disciplinary corrections, followed by several attachments [6].

1.3. Large Language Models (LLMs)

A large language model (LLM) is an advancement in natural language processing technology. LLM were developed by the introduction of the transformer architecture. Relevant studies in this field were “Attention is all you need” by Ashish Vaswani et al. in 2017 [8] and “BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding” by Jacob Devlin in 2018 [9], both from Google research.
LLM are AI systems based on transformers designed to understand, process, and generate human-like generated text [10]. They use of network architectures learn patterns, context, and semantics. The basic architecture includes an input layer (tokenization by braking the input text into smaller units such as words, subwords or characters), an embedding layer (the tokens are mapped into dense vectors using word embedding, and the order of tokens is set up by positional embedding), a transformer architecture (the relationship of each word is calculated by self-attention using queary (Q), key (K), and value (V) vectors, and multiple relationships are focused by multi-head attention), stacking layers (multiple blocks), and an output layer (an autoregressive model like GPT predicts the next word, a masked model like BERT predicts missing words, and a final softmax layer converts outputs into a probability distribution over the vocabulary (Figure 1).
A LLM is initially trained on models that contain billions of parameters using GPUs or TPUs and massive datasets from many sources. After pre-training, the models are fine-tuned and refined on specific datasets for particular tasks, and hyperparameters, including learning rate and batch size, are adjusted to obtain the best performance on a specific task. During training, the model minimizes a loss function, usually cross-entropy by adjusting weights by gradient descent [11] and backpropagation [12,13,14,15,16]. In an LLM, the words are represented in computing continuous vectors [17] (Figure 2).
A local LLM is an AI system that runs directly on your personal computer, sever, or local infrastructure instead of relying on cloud-based systems. Local LLMs are identical to their cloud counterparts and generate text, answer questions, write code, and process natural language. Appendix figure A explains the transformer in an interactive manner using a text-generative model [18]. The major benefits of local LLMs are enhanced privacy and security, cost-effectiveness for high-volume usage, ultra-low latency performance, and complete offline functionality. A local LLM is easily deployed and includes the following steps: hardware acquisition, selection of a runner such as Ollama [19] or LM Studio [20], runner installation, model download, testing the model, deployment, and use.
Meta developed and released the Meta Llama 3 family of LLMs, which are a collection of pre-trained and instruction, tuned generative text models in 8 and 70B sizes. The Llama 3 instruction models are optimized for dialogue [21]. The model input is text only, and the model output is text and code only. Llama 3 is an auto-regressive language model based on an optimized transformer architecture. The tuned versions use supervised fine-tuning (SFT) and reinforcement learning with human feedback (RLHF) to align with human preferences for helpfulness and safety. The Llama 3 model was released on April 18 2024 [21].
Appendix figure B depicts the Llama 3 system-level approach for safety.
Retrieval-Augmented Generation (RAG) is a technique that enables LLMs to retrieve and incorporate new information from external sources, improving the accuracy and relevance of their responses. With RAG, LLMs first refers to a specified set of documents, then respond to the user questions. Specific local files (documents) from the user are indexed and supplement the information of the pre-existing training data of the LLM. Therefore, the local LLM can use domain-specific and/or update information that is not available in the training data to improve accuracy and optimize performance [22,23,24].
This study created a local LLM to query and analyze the regulations of Book Four of the civil code of Catalonia relating to successions and the notary profession of Spain.

2. Methods

2.1. Hardware

GPT4All v3.10.0 was installed on a desktop workstation equipped with an AMD Ryzen 9 5900X CPU, 48.0 GB RAM, and NVIDIA GeForce RTX 4080 Super (16 GB) GPU.
The specific hardware details were as follows: 12-Core AMD Ryzen 9 5900X, 4900 MHz (49.25 x 99) CPU (Vermeer), ASRock B550M Pro4 motherboard, Dual DDR4 SDRAM bus type, 49076 physical memory (DIMM1/2: Crucial CT16G4DFRA32A.C8FF, and DIMM3/4: Crucial CT8G4DFRA32A.C8FP), AMD K19.2 IMC North Bridge chipset, AMI UEFI P3.40 BIOS, Microsoft Windows 10 IoT Enerprise LTSC 2021, and Gigabyte RTX 4080 Super WindForce V2 (GV-N408SWF3V2-16GD) Video Adapter (GPU).

2.2. Local LLM Models

Several chat models were locally installed:
  • Reasoner v1
  • Llama 3 8B Instruct (Meta-Llama-3-8B-Instruct.Q4_0.gguf)
  • DeepSeek-R1-Distill-Qwen-14B
  • Mistral Instruct
  • Orca2 (Full) (orca-2-13b.Q4_0.gguf)
  • Wizard v1.2
  • Hermes
  • Snoozy
  • Phi-3 Mini Instruct
All models were tested, but final analysis was performed using Llama 3 8B Instruct.

2.3. Retrieval-Augmented Generation (RAG) Technique

Llama 3 8B Instruct chat with local files included a folder with two-word docx files with the Spanish original versions:
  • Fourth Book of the Civil Code, dedicated to the law of succession (Ley 10/2008, de 10 de julio, del libro cuarto del Código civil de Cataluña, relativo a las sucesiones) [3]
  • The Decree of June 2, 1944, approving definitively the Regulations for the organization and system of the Notary Profession (Decreto 2 junio 1944, por el que se aprueba con carácter definitivo el Reglamento de la organización y régimen del Notariado) [7].
The settings were the following:
  • 4 CPU threads
  • Llama 3 8B Instruct (Meta-Lama-3-8B-Instruct.Q4_0.gguf)
  • 2048 context length
  • 128 prompt batch size
  • 0.4 Top-P
  • 0 Min-P
  • 32 GPU layers
  • 4096 max length
  • 0.7 temperature
  • 40 top-k
  • 64 repeat penalty tokens
  • 1.18 repeat penalty.
The local docs settings allowed docx, pdf, txt, md, and rst file extensions. The compute device used for embeddings was NVIDIA GeForce RTX 4080 SUPER (CUDA). The number of characters per document snippet was set at 512. The max document snippets per prompt were 3.
Several questions relevant to the legal policy decisions of Book Four of the Civil Code related to the law of succession and regulations of the notary profession were asked, and results were compared with the original information.

2.4. Comparison with Commercial Cloud-Based LLMs

The Local large language model (LLM), Llama 3 8B Instruct was compared with xAI Grok 4.2 (Expert mode, native tool use and real-time search integration) and Microsoft/Open AI GPT 5 (Microsoft 365 Copilot, Think Deeper). Replies were analyzed using GPTzero (Human % prediction of the input text, Model 4.4b) as well.

2.5. Statistical Analyses

All statistics were performed using IBM SPSS v27.0.1.0 (64-bit edition) (1 Orchard Road, Armonk, New York, United States). Comparison between groups were performed using nonparametric tests, including independent-samples Kruskal-Wallis and Mann-Whitney U tests. A p values of less than 0.05 was considered statistically significant.

3. Findings

3.1. General Findings and Evaluation Metrics

The local LLM (Llama 3 8B Instruct) managed to answer relevant questions in a reasonable and truthful manner. However, from a user point of view, although the text was well written and provided reasonable answers, the veracity of the replies was difficult to evaluate qualitatively without previously knowing the exact answers as described in the local files. Hallucinations with strikingly wrong answers were infrequent, but very specialized topics were difficult to evaluate.
Note: evaluating LLMs is important for ensuring that they work well in real-world applications. Key metrics for LLM evaluation include the following: accuracy and performance (perplexity, accuracy, BLEU, and ROUGE), bias and fairness (demographic parity, equal opportunity and counterfactual fairness), language quality (fluency and coherence), and content quality (factuality, relevance, and diversity).
Table 1 and Figure 3 show the language and content quality metrics for LLM evaluation. Fluency included the evaluation of naturalness and grammar, coherence evaluated the logical flow and consistency, and factuality the accuracy of information. The metrics were evaluated as an ordinal variable as 0 (none), 1+ (low), 2+ (moderate), 3+ (high). The LLM managed to reply in a reasonable and truthful manner with 80% 3+ fluency, 80% 3+ coherence, 40% 3+ and 60% 2+ factuality, and 60% 3+ and 40% 2+ relevance.

3.2. Comparison with Commercial Cloud-Based LLMs

The local LLM, which was based on Llama 3 8B Instruct, was compared to other currently available LLM architectures that are hosted in the cloud, including Grok 4.2 and GPT5. These LLMs require an active internet connection and a paid subscription. Both of them had no direct access to the two local files of the local LLM.
GPTzero (Model 4.4b) was used to predict the probability of the language model text of being created by a human (Human %). The xAI Grok 4.2 used the expert mode, native tool use and real-time search integration. The Microsoft/Open AI GPT 5 of Microsoft 365 Copilot used the Think Deeper mode.
The replies to the ten questions are shown as supplementary files. After revising the answers of the language models, no striking differences were found with the local LLM in terms of content quality (factuality and relevance). However, they differed regarding the length, percentage of human probability (Human %), and number of sources (files). In comparison to Grok 4.2 and GPT5, the local LLM was characterized by an answer of less length and less sources, but higher human % similarity (all P values < 0.005). Data are shown in Table 2 and Table 3, and Figure 4.

3.3. Specific Questions

The ten specific questions with the local LLM answers are as follows:
Question 1: Explain the difference between the legatee and heir.
Answer 1: “Based on the excerpts from the “Código Civil de Cataluña” (Spanish Civil Code), here’s a summary of the differences between a legatee and an heir:
Legatario/Legatee:
Receives specific assets or properties left behind by the testator through a legacy.
Does not inherit all of the testator’s assets, but only receives what is specifically bequeathed to them (Artículo 423-7).
Can have their share reduced if there are other legacies that need to be distributed first.
Heredero/Heir:
Inherits all assets left behind by the testator, including those not specifically disposed of in the will.
Has full control over managing these assets as they see fit (Artículo 462-4).
Can reduce excessive legacies if their distribution does not leave them with at least a quarter of the liquid estate’s value.
In summary:
Legatario/Legatee: Receives specific assets or properties through a legacy, but doesn’t inherit everything.”
Question 2: What is the “legítima”?
Answer 2: ”According to the excerpts from the “Código Civil de Cataluña” (Spanish Civil Code), the legitima refers to a portion of an inheritance reserved for the closest relatives, specifically:
Descendants: The minimum amount that must be left by a testator to their descendants.
Progenitors: The minimum amount that must be left by a testator to their ascendants.
The excerpts also establish rules and limitations regarding the legitima, including:
The testator cannot impose conditions, plazos or modes on legacies attributed to the legitima or imputable to it.
If the legacy has a value greater than what corresponds to the legitimario (the person entitled to receive the legitima), they must opt between accepting the legacy in its current form or claiming only their rightful share of the legitima.
If the legitimario accepts an inheritance or legacy subject to limitations, it is considered that they renounce exercising the option established by law.
In summary, the legitima refers to a minimum amount reserved for closest relatives (descendants and progenitors) in an inheritance, with specific rules governing its attribution, imputation, perception, and payment.”
Question 3: In what language can a will be written?
Answer 3: ”According to the excerpts from the “Código Civil de Cataluña” (Spanish Civil Code), a will can be written in either:
The official language of Catalonia, which is Catalan.
Additionally, if requested by the testator, another non-official language.
The notary public who witnesses the will must also sign it.”
Question 4: Which testamentary provisions are void?
Answer 4: ”According to the excerpts from the “Código Civil de Cataluña” (Spanish Civil Code), testamentary provisions that are void or revocable include:
Disposiciones Testamentarias: These can be revoked at any time, except for the recognition of non-marital children.
Testamentos anteriores: A new will supersedes and revokes all previous wills.
Additionally, according to the “Regimen del Notariado” (Notary Regulation), notarial positions that are:
Suppressed due to a demographic change and were not announced for provision in the Official Gazette (“Boletín Oficial del Estado”) will be abolished.
Served but must be suppressed: These notaries will continue serving until they leave their position or a certain period of time has passed, at which point they will become “Notarios excedentes de demarcación” (excess notaries) for all legal purposes.
These provisions are void and do not produce any effects.”
Question 5: Who cannot be a witness to a will?
Answer 5: ”Based on the excerpts from “Código Civil y Sucesiones” (Civil Code and Successions), it seems that there are certain individuals who cannot be witnesses to a will.
According to Article 421-19, notaries themselves cannot be witnesses to a will. This is because notaries have a specific role in verifying the authenticity of documents, including testaments, which requires them to maintain their impartiality and independence.
In other words, if a notary were to act as a witness to a will, it could compromise their ability to perform their duties objectively and fairly, potentially leading to questions about the validity or enforceability of the testament.”
Question 6:What happens if a notary falsifies a will?
Answer 6: “Consequences of a Notary Falsifying a Will.
According to the excerpts from “Regimen del Notariado” and “Código Civil y Sucesiones”, if a notary falsifies a will, it can have severe consequences.
Firstly, Article 143 states that documents authorized or intervened by a notary enjoy public faith. This means that any document bearing the notary’s signature is considered authentic and trustworthy.
However, if a notary were to falsify a will, they would be violating their professional duties as a notary. Notaries are responsible for verifying the authenticity of documents, including testaments, which requires them to maintain their impartiality and independence.
If a notary were found to have falsified a will, it could lead to:
Loss of credibility: The notary’s reputation would be severely damaged, making it difficult for them to continue practicing as a notary.
Legal consequences: The notary could face legal action, including criminal charges and fines.
Invalidation of the will: In extreme cases, the falsified will might be declared invalid or null and void by the courts.
In summary, if a notary were to falsify a will, it would have serious repercussions for their professional reputation, legal standing, and personal integrity.”
Question 7: What is the difference between a simple and a legal copy of a will?
Answer 7: “Simple Copy vs. Legal Copy of a Will
In the context of Notariado Sucesiones, there are two types of copies of a will: simple copy (simplex) and legal copy (auténtico).
Simple Copy (Simplex): A simple copy is an unofficial reproduction of the original will. It may be created by photocopying or scanning the document. This type of copy does not have any official standing, as it was not prepared under the supervision of a notary public.
Legal Copy (Auténtico): A legal copy, also known as an “auténtico,” is an officially certified reproduction of the original will. It is created by a notary public who verifies that the document is a true and accurate representation of the testator’s intentions. The notary public signs and seals the document to attest its authenticity.
Key differences between simple and legal copies:
Authenticity: A legal copy (auténtico) has official standing, as it was prepared under the supervision of a notary public who verified its accuracy.
Certification: Only a notary public can certify that a will is authentic. Simple copies do not have this certification.
In summary: if you need to prove the authenticity and validity of a will in court or for other legal purposes, it’s essential to use an officially certified legal copy (auténtico) rather than a simple copy.”
Question 8: What is the trustee’s responsibility?
Answer 8: ”Based on the excerpts, it appears that there is no specific mention of a “trustee” in these documents. However, I can infer some information about fiduciaries (fiduciantes) and their responsibilities from the text.
In the excerpt from Libro 4 Código Civil de Cataluña (Book 4 of the Catalan Civil Code), it seems that a fiduciary is responsible for:
Conservación y administración (conservation and administration): The fiduciary must manage and preserve the assets entrusted to them.
Responsabilidad del fiduciario (fiduciary’s responsibility): If something goes wrong, the fiduciary may be held accountable.
In general, a trustee is responsible for managing property or assets on behalf of another person, known as the beneficiary. The trustee must act in the best interests of the beneficiary and follow any instructions provided by them.”
Question 9: Is it possible to issue copies of revoked wills, and what is their use?
Answer 9: “According to the excerpts, it is possible to issue copies of revoked wills (Article 226), but their use is limited. The copy can only be used to “acreditar su contenido” (authenticate its content) and leave a record of its lack of validity.
In other words, the copy of a revoked will has no legal value or effect, it’s just a historical document that shows what was originally established in the will.”
Question 10: How long are protocols kept at the notary’s office?
Answer 10: “According to the excerpt, it seems that protocols are kept at the notary’s office for a period of time. The exact duration is not specified in this particular text.
However, we can infer from other excerpts that protocols are incorporated into each year’s protocol book (Protocolo Notarial) and are stored until they are transferred to an Archivo General de Protocolos (General Archive of Protocols).”

4. Discussion

Running local LLMs is a solution when there are privacy concerns, high subscription costs, and unreliable internet connections. Local LLMs allow complete control of sensitive data and are less expensive in the long term once the hardware has been purchased [25].
To achieve good performance with models of 7B, the recommended amount of RAM is 16 GB. For 13B models, the recommended amount is 32 GB. The use of GPU acceleration increases the speed of the local LLMs the cards that work best are NVIDIA, followed by Apple Silicon M hardware [26]. There are several tools to start using local LLMs such as Ollama, LM Studio, and LocalAI. In this study, we used GPT4all, a straightforward GUI-based method [27].
Llama 3 is an LLM AI model capable of generating text and code in response to prompts. Meta created the Llama 3 family, which included both 8 and 70B sizes pre-trained and instruction, tuned generative text models. Both models use grouped-query attention (GQA) for improved inference scalability [28,29,30,31]. The Llama 3 tuned models were optimized for dialogue use cases, such as the local files included in this study.
The Llama3-8b-instruct was designed to enhance natural language understanding and generation. It is characterized by instruction following, contextual understanding, scalability (with 8 billion parameters can handle language tasks with high accuracy and efficiency), fine-tuning capabilities, and multimodal integration (including images and audio). Overall, Llama3-8b-instruct is a lightweight and ultrafast variant for use when quick response times are needed most [32]. Additional information is found on the Hugging Face website [33].
Book Four of the Civil Code of Catalonia relating to Successions provides the legal framework for citizens to acquire inheritance. The text has many chapters and range from relevant ones like acquisition of inheritance, incapacity to inherit, types of wills, and illicit or erroneous motives in the institution of heir to less relevant and specialized like concurrence of multiple heirs, opposition of creditors, collatable assets, and will before a parish priest [1,4,5]. Because of its length only specialized lawyers have a deep knowledge of this field. Average citizens may not be aware that the book is freely available online and that it also appears in the Boletin Oficial del Estado, which is the official gazette of Spain, and other sites such as Noticias Juridicas and Civil Code of Catalonia and complementary legislation. All information is found in three specialized websites: https://www.boe.es/index.php, https://noticias.juridicas.com/, and the https://portaljuridic.gencat.cat/ca/normativa/dret-a-catalunya/Codis-legislacio/codi-civil-de-catalunya-i-legislacio-complementaria/.
Chat GPT is an artificial intelligence tool that emerged in 2022 and has been a game-changer for legal sciences. This new technology represents both an opportunity and a threat to the legal sector. It is unclear to what extent this transformation has been and will be a reality in the world of law. In today’s digital age, technical brilliance is no longer enough for legal professionals. The market demands other skills, such as digital and accounting competence, knowledge of new business models, and strong communication skills. Artificial intelligence platforms draw on the vast amounts of data from multiple sources available online. However, what sets them apart in the legal sector is that only information with precise and secure legal reliability is considered valid. Regarding legal security, confidentiality, and data protection, open platforms like ChatGPT pose a risk. In this respect, local LLMs may play a role in the future.

5. Conclusions

Large language models (LLMs) represent a cutting-edge breakthrough in the deep learning models designed for processing human languages. LLMs have many capabilities, such as language translation, text generation, question answering, sentiment analysis, and summarization. However, LLMs are associated with several risks, such as inaccurate translations, contextual misinterpretation, biased translations and amplification, information loss, privacy and data security breaches, and hallucinations. The use of a local LLM has the advantage of decreasing usage costs, increased reliability due to network outages, and increased security. The disadvantages are the high initial hardware costs, the necessity of technical expertise, and the limited availability of the most advanced LLM models.
In the field of legal sciences, this technology represents an opportunity. This study created a local LLM model to interact privately with Book Four of the Civil Code of Catalonia relating to Successions and the regulations of the Notary Profession of Spain. The local LLM managed to answer specific questions in a reasonable manner. However, only precise information and secure legal reliability should be considered valid. Therefore, all legal procedures should be performed by legal human specialists and agencies.

Supplementary Materials

The following supporting information can be downloaded at the website of this paper posted on Preprints.org, the Fourth Book of the Civil Code, dedicated to the law of succession (Ley 10/2008, de 10 de julio, del libro cuarto del Código civil de Cataluña, relativo a las sucesiones) and the Decree of June 2, 1944, approving definitively the Regulations for the organization and system of the Notary Profession (Decreto 2 junio 1944, por el que se aprueba con carácter definitivo el Reglamento de la organización y régimen del Notariado), can be downloaded at: https://www.mdpi.com/article/doi/s1 zip file.

Author Contributions

Conceptualization, methodology, software, formal analysis, and writing, JC. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by Ministry of Education, Culture, Sports, Science and Technology (MEXT), Grants-in-Aid for Scientific Research (KAKENHI) Japan Society for the Promotion of Science (JSPS) grant numbers 23K06454 and 25K10272.

Institutional Review Board Statement

Not applicable.

Data Availability Statement

All data are available as supplementary data and upon request to Joaquim Carreras (joaquim.carreras@tokai.ac.jp).

Acknowledgments

Not applicable.

Conflicts of Interest

None to declare.

Abbreviations

The following abbreviations are used in this manuscript:
AI Artificial intelligence
BERT Bidirectional transformers for language understanding
CPU Central processing unit
GPT Generative pre-trained transformer
GPU Graphics processing unit
LLM Large language model
RAM Random-access memory

Appendix A

Appendix A.1. Transformer Explainer: Example

Preprints 220524 i001

Appendix A.1. Transformer Explainer: Probability of “Expected” Token Being Sampled

Preprints 220524 i002

Appendix B. Llama 3 System-Level Approach for Safety

Preprints 220524 i003
Llama 3 uses a system-level approach to responsibility: instruction fine-tuning is used to ensure the safety of the model. Adversarial prompts are generated to elicit problematic responses [34]. Image reused from Meta (Meta ©, Website: https://ai.meta.com/blog/meta-llama-3/, last accessed on April 22, 2026).

References

  1. Código de Leyes Civiles de Cataluña. Agencia Estatal Boletin Oficial del Estado (BOE). Available online: https://www.boe.es/biblioteca_juridica/codigos/codigo.php?id=150&modo=2&nota=0&tab=2.
  2. Ley 10/2008, de 10 de julio, del libro cuarto del Código Civil de Cataluña, relativo a las sucesiones. «DOGC» núm. 5175, de 17/07/2008, «BOE» núm. 190, de 07/08/2008. Entrada en vigor: 01/01/2009. Departamento: Comunidad Autónoma de Cataluña. Referencia: BOE-A-2008-13533; Permalink ELI; Available online: https://www.boe.es/eli/es-ct/l/2008/07/10/10/con.
  3. Noticias Juridicas. Ley 10/2008, de 10 de julio, del libro cuarto del Código civil de Cataluña, relativo a las sucesiones. Available online: https://noticias.juridicas.com/base_datos/CCAA/ca-l10-2008.html (accessed on 3rd April 2026).
  4. GenCat. Departament de Justicia. Llibre quart del Codi civil de Catalunya, relatiu a les successions. Available online: https://repositori.justicia.gencat.cat/handle/20.500.14226/589#page=1 (accessed on 3rd April 2026).
  5. Ley del Notariado de 28 de mayo de 1862. Publicado en: «Gaceta de Madrid» núm. 149, de 29/05/1862. Entrada en vigor:19/06/1862. Departamento: Ministerio de Gracia y Justicia. Referencia: BOE-A-1862-4073. Permalink ELI. Available online: https://www.boe.es/eli/es/l/1862/05/28/(1)/con.
  6. Preliminary title. Fundamental principles. Article 1. Decreto 2 junio 1944, por el que se aprueba con carácter definitivo el Reglamento de la organización y régimen del Notariado. Órgano MINISTERIO DE JUSTICIA. Publicado en BOE núm. 189 de 07 de Julio de 1944. Vigencia desde 27 de Julio de 1944. 2015. [PubMed]
  7. Noticias Juridicas. Ley de 28 de mayo 1862, Orgánica del Notariado. Available online: https://noticias.juridicas.com/base_datos/Privado/ln.html (accessed on 3r April 2026).
  8. Vaswani, Ashish; Shazeer, Noam; Parmar, Niki; Uszkoreit, Jakob; Jones, Llion; Gomez, Aidan N.; Kaiser, Lukasz; Polosukhin, Illia. Attention Is All You Need. arXiv arXiv:1706.03762.
  9. Devlin, Jacob; Chang, Ming-Wei; Lee, Kenton; Toutanova, Kristina. BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. arXiv arXiv:1810.04805.
  10. Zhang, E.Y.; Cheok, A.D.; Pan, Z.; Cai, J.; Yan, Y. From Turing to Transformers: A Comprehensive Review and Tutorial on the Evolution and Applications of Generative Transformer Models. Sci 2023, 5, 46. [Google Scholar] [CrossRef]
  11. Ruder, Sebastian. An overview of gradient descent optimization algorithms. arXiv arXiv:1609.04747.
  12. HECHT-NIELSEN, R.O.B.E.R.T., III. 3 - Theory of the Backpropagation Neural Network**Based on “nonindent” by Robert Hecht-Nielsen, which appeared in Proceedings of the International Joint Conference on Neural Networks 1, 593–611, June 1989. © 1989 IEEE. In Neural Networks for Perception; Wechsler, Harry, Ed.; Academic Press, 1992; pp. Pages 65–93. ISBN 9780127412528. [Google Scholar] [CrossRef]
  13. LeCun, Y.; Bottou, L.; Orr, G. B.; Müller, K. R. Efficient backprop. In Neural networks: Tricks of the trade; Springer, 1998; pp. 9–50. [Google Scholar]
  14. Rumelhart, D. E.; Hinton, G. E.; Williams, R. J. Learning representations by back-propagating errors. Nature 1986, 323(6088), 533–536. [Google Scholar] [CrossRef]
  15. Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A. N.; Kaiser, Ł.; Polosukhin, I. Attention is all you need. Advances in neural information processing systems, 2017; Vol. 30. [Google Scholar]
  16. Guenole, N. (no date) Psychometrics.ai: Transforming Behavioral Science with Machine Learning. Available online: https://psychometrics.ai (accessed on 3rd April 2026).
  17. Mikolov, Tomas; Chen, Kai; Corrado, Greg; Dean, Jeffrey. Efficient Estimation of Word Representations in Vector Space. Available online: https://arxiv.org/abs/1301.3781.
  18. Cho, Aeree; Kim, Grace C.; Karpekov, Alexander; Helbling, Alec; Wang, Zijie J.; Lee, Seongmin; Hoover, Benjamin; Chau, Duen Horng. Transformer Explainer: Interactive Learning of Text-Generative Models. arXiv arXiv:2408.04619.
  19. Ollama. Available online: https://ollama.com/ (accessed on 3rd April 2026).
  20. LM Studio AI. Element Labs, Inc. (c) 2026. Available online: https://lmstudio.ai/ (accessed on 3rd April 2026).
  21. Llama 3 open-source AI model. Meta. Available online: https://www.llama.com/models/llama-3/ (accessed on 3rd April 2026).
  22. Klesel, M.; Wittmann, H.F. Retrieval-Augmented Generation (RAG). Bus. Inf. Syst. Eng. 2025, 67, 551–561. [Google Scholar] [CrossRef]
  23. Lewis, Patrick; Perez, Ethan; Piktus, Aleksandra; Petroni, Fabio; Karpukhin, Vladimir; Goyal, Naman; Küttler, Heinrich; Lewis, Mike; Yih, Wen-tau; Rocktäschel, Tim; Riedel, Sebastian; Kiela, Douwe. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. Accepted at NeurIPS 2020. Comput. Lang. (cs.CL); Machine Learning (cs.LG) . arXiv:2005.11401.
  24. Yang, R.; Ning, Y.; Keppo, E.; et al. Retrieval-augmented generation for generative artificial intelligence in health care. npj Health Syst. 2025, 2, 2. [Google Scholar] [CrossRef]
  25. Patil, R.; Gudivada, V. A Review of Current Trends, Techniques, and Challenges in Large Language Models (LLMs). Appl. Sci. 2024, 14, 2074. [Google Scholar] [CrossRef]
  26. Abdollahi, M.; Yeganli, S.F.; Baharloo, M.; Baniasadi, A. Hardware Design and Verification with Large Language Models: A Scoping Review, Challenges, and Open Issues. Electronics 2025, 14, 120. [Google Scholar] [CrossRef]
  27. Chen, X.; Ma, W.; Li, D.; Zhu, F.; Routray, S.; Guduri, M.; Margala, M. Kalman-based Adaptive Moment Estimation Optimisation Algorithm to Enhance GPT in LLMs for Medical Sentiment Analysis of Patient Health-related Feedback. IEEE J. BioMed Health Inf. 2025, PP. [Google Scholar] [CrossRef] [PubMed]
  28. Ke, Y.H.; Jin, L.; Elangovan, K.; Abdullah, H.R.; Liu, N.; Sia, A.T.H.; Soh, C.R.; Tung, J.Y.M.; Ong, J.C.L.; Kuo, C.F.; et al. Retrieval augmented generation for 10 large language models and its generalizability in assessing medical fitness. npj Digit Med. 2025, 8, 187. [Google Scholar] [CrossRef] [PubMed]
  29. Tayebi Arasteh, S.; Lotfinia, M.; Bressem, K.; Siepmann, R.; Adams, L.; Ferber, D.; Kuhl, C.; Kather, J.N.; Nebelung, S.; Truhn, D. RadioRAG: Online Retrieval-Augmented Generation for Radiology Question Answering. Radiol. Artif. Intell. 2025, 7, e240476. [Google Scholar] [CrossRef] [PubMed]
  30. Zhang, R.; Wang, Y.; Yang, W.; Wen, J.; Liu, W.; Zhi, S.; Li, G.; Chai, N.; Huang, J.; Xie, Y.; et al. PlantGPT: An Arabidopsis-Based Intelligent Agent that Answers Questions about Plant Functional Genomics. Adv. Sci. (Weinh) 2025, 12, e03926. [Google Scholar] [CrossRef] [PubMed]
  31. Zhong, W.; Liu, Y.; Liu, Y.; Yang, K.; Gao, H.; Yan, H.; Hao, W.; Yan, Y.; Yin, C. Performance of ChatGPT-4o and Four Open-Source Large Language Models in Generating Diagnoses Based on China’s Rare Disease Catalog: Comparative Study. J. Med. Internet Res. 2025, 27, e69929. [Google Scholar] [CrossRef] [PubMed]
  32. Meta. Llama API. Meet the models. Available online: https://llama.developer.meta.com/docs/models (accessed on 4th April 2026).
  33. Face, Hugging. meta-llama/Meta-Llama-3-8B-Instruct. Available online: https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct (accessed on 4th April 2026).
  34. Bhatt, Manish; Chennabasappa, Sahana; Li, Yue; Nikolaidis, Cyrus; Song, Daniel; Wan, Shengye; Ahmad, Faizan; Aschermann, Cornelius; Chen, Yaohui; Kapil, Dhaval; Molnar, David; Whitman, Spencer; Saxe, Joshua. CYBERSECEVAL 2: A Wide-Ranging Cybersecurity Evaluation Suite for Large Language Models. 18 April 2024. Available online: https://scontent-nrt1-1.xx.fbcdn.net/v/t39.2365-6/438983861_247813051691642_9146727788360945492_n.pdf?_nc_cat=109&ccb=1-7&_nc_sid=3c67a6&_nc_ohc=tBls4fRWQ_8Q7kNvwHoW18p&_nc_oc=Adq4YoideawjH7-NW2VJUggo0dMuM_CdgLEcN3MWdWjFnX4COTrcIA3FBJJL7oo4UKs&_nc_zt=14&_nc_ht=scontent-nrt1-1.xx&_nc_gid=Tmw7kR2coZGoQOdQi95KXg&_nc_ss=7a389&oh=00_Af3uwJMRY6nuhebx632lFwAjuHK6-dl8hkxRJLRiDF12Kg&oe=69EE432A (accessed on 22 April 2026).
Figure 1. LLM architecture.
Figure 1. LLM architecture.
Preprints 220524 g001
Figure 2. Gradient descent. Gradient descent is an optimization algorithm used to minimize the loss function in machine learning models. (A) There are 3 major variants of the gradient descent algorithm, batch, stochastic, and mini-batch gradient descent. (B) Word representation in vector space.
Figure 2. Gradient descent. Gradient descent is an optimization algorithm used to minimize the loss function in machine learning models. (A) There are 3 major variants of the gradient descent algorithm, batch, stochastic, and mini-batch gradient descent. (B) Word representation in vector space.
Preprints 220524 g002
Figure 3. Language and content quality metrics for LLM evaluation. Fluency (naturalness and grammar), coherence (logical flow and consistency), factuality (accuracy of information), diversity (variety in generated content). None (0), Low (1+), Medium (2+), and High (3+). Local language model (LLM), Llama 3 8B Instruct.
Figure 3. Language and content quality metrics for LLM evaluation. Fluency (naturalness and grammar), coherence (logical flow and consistency), factuality (accuracy of information), diversity (variety in generated content). None (0), Low (1+), Medium (2+), and High (3+). Local language model (LLM), Llama 3 8B Instruct.
Preprints 220524 g003
Figure 4. Comparison of local LLM with other commercial language models. In comparison to Grok 4.2 and GPT5, the local LLM was characterized by an answer of less length and less sources, but higher human % similarity (all P values < 0.005). Local large language model (LLM), Llama 3 8B Instruct.
Figure 4. Comparison of local LLM with other commercial language models. In comparison to Grok 4.2 and GPT5, the local LLM was characterized by an answer of less length and less sources, but higher human % similarity (all P values < 0.005). Local large language model (LLM), Llama 3 8B Instruct.
Preprints 220524 g004
Table 1. Language and content quality metrics for local LLM evaluation.
Table 1. Language and content quality metrics for local LLM evaluation.
Question Language quality Content quality
Fluency Coherence Factuality Relevance
1 3+ 3+ 3+ 3+
2 3+ 3+ 2+ 3+
3 3+ 3+ 3+ 3+
4 2+ 2+ 2+ 2+
5 2+ 2+ 2+ 2+
6 3+ 3+ 3+ 3+
7 3+ 3+ 2+ 2+
8 3+ 3+ 2+ 2+
9 3+ 3+ 3+ 3+
10 3+ 3+ 2+ 3+
Summary 80% 3+
20% 2+
80% 3+
20% 2+
40% 3+
60% 2+
60% 3+
40% 2+
Fluency (naturalness and grammar), coherence (logical flow and consistency), factuality (accuracy of information), diversity (variety in generated content). None (0), Low (1+), Medium (2+), and High (3+). Local large language model (LLM), Llama 3 8B Instruct.
Table 2. Comparison with other commercial language models (descriptive data).
Table 2. Comparison with other commercial language models (descriptive data).
Question Local LLM (Llama 3 8B Instruct) Grok 4.2 (Expert mode) GPT5 (Think Deeper)
Length Human % Local files Length Human % Sources Length Human % Steps
1 147 99 2 1015 0 30 939 0 28
2 177 50 2 513 0 55 542 0 19
3 48 99 2 671 94 50 314 0 14
4 133 100 2 467 0 35 633 0 28
5 103 48.5 2 369 90 50 394 81 13
6 192 0 2 562 40 70 964 6 23
7 207 0 2 517 0 65 552 0 21
8 128 99 2 429 0 50 789 49 24
9 71 98 2 435 0 70 912 0 14
10 64 97 2 368 58 70 334 0 21
Average 127.0 69.1 2.0 534.6 28.2 54.5 637.3 13.6 20.5
STD 55.3 41.6 0.0 192.0 39.4 14.4 251.3 28.2 5.5
Local language model (LLM), Llama 3 8B Instruct. GPTzero (Human % prediction, Model 4.4b); xAI Grok 4.2 (Expert mode, native tool use and real-time search integration); Microsoft/Open AI GPT 5 (Microsoft 365 Copilot, Think Deeper). STD, standard deviation.
Table 3. Comparison of local LLM with other commercial language models (statistics).
Table 3. Comparison of local LLM with other commercial language models (statistics).
  Length Human % similarity Sources
Local LLM (Llama 3 8B Instruct) 127 ±55.3 69.1% ±41.6 2.0 ±0.0
Grok 4.2 534.6 ±191.9 28.2% ±39.4 54.5 ±14.4
GPT5 637.3 ±251.3 13.6% ±28.2 20.5 ±5.5
P value (across groups) < 0.001 0.009 < 0.001
P value (LLM vs. others) < 0.001 0.004 < 0.001
Length, number of words.
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.
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.
Prerpints.org logo

Preprints.org is a free preprint server supported by MDPI in Basel, Switzerland.

Subscribe

© 2026 MDPI (Basel, Switzerland) unless otherwise stated

Accessibility

Disclaimer

Terms of Use

Privacy Policy

Privacy Settings