The impact of LLaMA fine tuning on hallucinations for name entity extraction in legal documents
The extraction of information about traffic accidents from legal documents is crucial for quantifying insurance company costs. Extracting entities such as percentages of physical and/or psychological disability and the involved compensation amounts is a challenging process, even for experts, due to...
Guardado en:
| Autores principales: | , , , , |
|---|---|
| Formato: | Articulo |
| Lenguaje: | Inglés |
| Publicado: |
2025
|
| Materias: | |
| Acceso en línea: | http://sedici.unlp.edu.ar/handle/10915/177987 |
| Aporte de: |
| id |
I19-R120-10915-177987 |
|---|---|
| record_format |
dspace |
| institution |
Universidad Nacional de La Plata |
| institution_str |
I-19 |
| repository_str |
R-120 |
| collection |
SEDICI (UNLP) |
| language |
Inglés |
| topic |
Ciencias Informáticas Named entity recognition Large Language Models Legal Documents Reconocimiento de entidades nombradas Grandes Modelos de Lenguaje Documentos legales |
| spellingShingle |
Ciencias Informáticas Named entity recognition Large Language Models Legal Documents Reconocimiento de entidades nombradas Grandes Modelos de Lenguaje Documentos legales Vargas, Francisco González Coene, Alejandro Escalante, Gastón Lobón, Exequiel Pulido, Manuel The impact of LLaMA fine tuning on hallucinations for name entity extraction in legal documents |
| topic_facet |
Ciencias Informáticas Named entity recognition Large Language Models Legal Documents Reconocimiento de entidades nombradas Grandes Modelos de Lenguaje Documentos legales |
| description |
The extraction of information about traffic accidents from legal documents is crucial for quantifying insurance company costs. Extracting entities such as percentages of physical and/or psychological disability and the involved compensation amounts is a challenging process, even for experts, due to the subtle arguments and reasoning in the court decision. A two-step procedure is proposed: first, segmenting the document identifying the most relevant segments, and then extracting the entities. For text segmentation, two methodologies are compared: a classic method based on regular expressions and a second approach that divides the document into blocks of n-tokens, which are then vectorized using multilingual models for semantic searches (text-embedding-ada- 002/MiniLM-L12-v2). Subsequently, large language models (LLaMA-2 7b, 70b, LLaMA-3 8b, and GPT-4 Turbo) are applied with prompting to the selected segments for entity extraction. For the LLaMA models, finetuning is performed using LoRA. LLaMA-2 7b, even with zero temperature, shows a significant number of hallucinations in extractions which are an important contention point for named entity extraction. This work shows that these hallucinations are substantially reduced after finetuning the model. The performance of the methodology based on segment vectorization and subsequent use of LLMs significantly surpasses the classic method which achieves an accuracy of 39.5%. Among open-source models, LLaMA-2 70B with finetuning achieves the highest accuracy 79.4%, surpassing its base version 61.7%. Notably, the base LLaMA-3 8B model already performs comparably to the finetuned LLaMA-2 70B model, achieving 76.6%, highlighting the rapid progress in model development.
Meanwhile, GPT-4 Turbo achieves the highest accuracy at 86.1%. |
| format |
Articulo Articulo |
| author |
Vargas, Francisco González Coene, Alejandro Escalante, Gastón Lobón, Exequiel Pulido, Manuel |
| author_facet |
Vargas, Francisco González Coene, Alejandro Escalante, Gastón Lobón, Exequiel Pulido, Manuel |
| author_sort |
Vargas, Francisco |
| title |
The impact of LLaMA fine tuning on hallucinations for name entity extraction in legal
documents |
| title_short |
The impact of LLaMA fine tuning on hallucinations for name entity extraction in legal
documents |
| title_full |
The impact of LLaMA fine tuning on hallucinations for name entity extraction in legal
documents |
| title_fullStr |
The impact of LLaMA fine tuning on hallucinations for name entity extraction in legal
documents |
| title_full_unstemmed |
The impact of LLaMA fine tuning on hallucinations for name entity extraction in legal
documents |
| title_sort |
impact of llama fine tuning on hallucinations for name entity extraction in legal
documents |
| publishDate |
2025 |
| url |
http://sedici.unlp.edu.ar/handle/10915/177987 |
| work_keys_str_mv |
AT vargasfrancisco theimpactofllamafinetuningonhallucinationsfornameentityextractioninlegaldocuments AT gonzalezcoenealejandro theimpactofllamafinetuningonhallucinationsfornameentityextractioninlegaldocuments AT escalantegaston theimpactofllamafinetuningonhallucinationsfornameentityextractioninlegaldocuments AT lobonexequiel theimpactofllamafinetuningonhallucinationsfornameentityextractioninlegaldocuments AT pulidomanuel theimpactofllamafinetuningonhallucinationsfornameentityextractioninlegaldocuments AT vargasfrancisco elimpactodelajustefinodellamaenlasalucinacionesparalaextracciondeentidadesnombradasendocumentoslegales AT gonzalezcoenealejandro elimpactodelajustefinodellamaenlasalucinacionesparalaextracciondeentidadesnombradasendocumentoslegales AT escalantegaston elimpactodelajustefinodellamaenlasalucinacionesparalaextracciondeentidadesnombradasendocumentoslegales AT lobonexequiel elimpactodelajustefinodellamaenlasalucinacionesparalaextracciondeentidadesnombradasendocumentoslegales AT pulidomanuel elimpactodelajustefinodellamaenlasalucinacionesparalaextracciondeentidadesnombradasendocumentoslegales AT vargasfrancisco impactofllamafinetuningonhallucinationsfornameentityextractioninlegaldocuments AT gonzalezcoenealejandro impactofllamafinetuningonhallucinationsfornameentityextractioninlegaldocuments AT escalantegaston impactofllamafinetuningonhallucinationsfornameentityextractioninlegaldocuments AT lobonexequiel impactofllamafinetuningonhallucinationsfornameentityextractioninlegaldocuments AT pulidomanuel impactofllamafinetuningonhallucinationsfornameentityextractioninlegaldocuments |
| _version_ |
1852545715046187008 |
| spelling |
I19-R120-10915-1779872025-05-06T17:17:49Z http://sedici.unlp.edu.ar/handle/10915/177987 The impact of LLaMA fine tuning on hallucinations for name entity extraction in legal documents El impacto del ajuste fino de LLaMA en las alucinaciones para la extracción de entidades nombradas en documentos legales Vargas, Francisco González Coene, Alejandro Escalante, Gastón Lobón, Exequiel Pulido, Manuel 2025-04 2025-04-07T12:08:43Z en Ciencias Informáticas Named entity recognition Large Language Models Legal Documents Reconocimiento de entidades nombradas Grandes Modelos de Lenguaje Documentos legales The extraction of information about traffic accidents from legal documents is crucial for quantifying insurance company costs. Extracting entities such as percentages of physical and/or psychological disability and the involved compensation amounts is a challenging process, even for experts, due to the subtle arguments and reasoning in the court decision. A two-step procedure is proposed: first, segmenting the document identifying the most relevant segments, and then extracting the entities. For text segmentation, two methodologies are compared: a classic method based on regular expressions and a second approach that divides the document into blocks of n-tokens, which are then vectorized using multilingual models for semantic searches (text-embedding-ada- 002/MiniLM-L12-v2). Subsequently, large language models (LLaMA-2 7b, 70b, LLaMA-3 8b, and GPT-4 Turbo) are applied with prompting to the selected segments for entity extraction. For the LLaMA models, finetuning is performed using LoRA. LLaMA-2 7b, even with zero temperature, shows a significant number of hallucinations in extractions which are an important contention point for named entity extraction. This work shows that these hallucinations are substantially reduced after finetuning the model. The performance of the methodology based on segment vectorization and subsequent use of LLMs significantly surpasses the classic method which achieves an accuracy of 39.5%. Among open-source models, LLaMA-2 70B with finetuning achieves the highest accuracy 79.4%, surpassing its base version 61.7%. Notably, the base LLaMA-3 8B model already performs comparably to the finetuned LLaMA-2 70B model, achieving 76.6%, highlighting the rapid progress in model development. Meanwhile, GPT-4 Turbo achieves the highest accuracy at 86.1%. La extracción de información sobre accidentes de tráfico a partir de documentos legales es crucial para cuantificar los costes de las aseguradoras. Extraer entidades como los porcentajes de discapacidad física o psicológica y las indemnizaciones implicadas es un proceso complejo, incluso para expertos, debido a la sutileza de los argumentos y razonamientos de la sentencia judicial. Se propone un procedimiento en dos pasos: primero, segmentar el documento identificando los segmentos más relevantes y, posteriormente, extraer las entidades. Para la segmentación de texto, se comparan dos metodologías: un método clásico basado en expresiones regulares y un segundo enfoque que divide el documento en bloques de n-tokens, que posteriormente se vectorizan mediante modelos multilingües para búsquedas semánticas (text-embedding-ada- 002/MiniLM-L12-v2). Posteriormente, se aplican modelos de lenguaje grandes (LLaMA-2 7b, 70b, LLaMA-3 8b y GPT-4 Turbo) con prompts a los segmentos seleccionados para la extracción de entidades. Para los modelos LLaMA, se realiza un ajuste fino mediante LoRA. LLaMA-2 7b, incluso a temperatura cero, presenta un número significativo de alucinaciones en las extracciones, lo cual constituye un importante punto de contención para la extracción de entidades nombradas. Este trabajo demuestra que estas alucinaciones se reducen sustancialmente tras el ajuste fino del modelo. El rendimiento de la metodología basada en la vectorización de segmentos y el posterior uso de LLM supera significativamente al método clásico, que alcanza una precisión del 39,5 %. Entre los modelos de código abierto, LLaMA-2 70B con ajuste fino alcanza la mayor precisión, con un 79,4 %, superando a su versión base con 61,7 %. Cabe destacar que el modelo base LLaMA-3 8B ya presenta un rendimiento comparable al del modelo LLaMA-2 70B ajustado, alcanzando un 76,6 %, lo que demuestra el rápido progreso en el desarrollo del modelo. Por otro lado, GPT-4 Turbo alcanza la mayor precisión, con un 86,1 %. Sociedad Argentina de Informática e Investigación Operativa Articulo Articulo http://creativecommons.org/licenses/by-nc-sa/4.0/ Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) application/pdf |