The impact of LLaMA fine tuning on hallucinations for name entity extraction in legal documents

Autores
Vargas, Francisco; González Coene, Alejandro; Escalante, Gastón; Lobón, Exequiel; Pulido, Manuel
Año de publicación
2025
Idioma
inglés
Tipo de recurso
artículo
Estado
versión publicada
Descripción
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
Materia
Ciencias Informáticas
Named entity recognition
Large Language Models
Legal Documents
Reconocimiento de entidades nombradas
Grandes Modelos de Lenguaje
Documentos legales
Nivel de accesibilidad
acceso abierto
Condiciones de uso
http://creativecommons.org/licenses/by-nc-sa/4.0/
Repositorio
SEDICI (UNLP)
Institución
Universidad Nacional de La Plata
OAI Identificador
oai:sedici.unlp.edu.ar:10915/177987

id SEDICI_c79228e457dbf630724e7a3d15bb3d6a
oai_identifier_str oai:sedici.unlp.edu.ar:10915/177987
network_acronym_str SEDICI
repository_id_str 1329
network_name_str SEDICI (UNLP)
spelling The impact of LLaMA fine tuning on hallucinations for name entity extraction in legal documentsEl impacto del ajuste fino de LLaMA en las alucinaciones para la extracción de entidades nombradas en documentos legalesVargas, FranciscoGonzález Coene, AlejandroEscalante, GastónLobón, ExequielPulido, ManuelCiencias InformáticasNamed entity recognitionLarge Language ModelsLegal DocumentsReconocimiento de entidades nombradasGrandes Modelos de LenguajeDocumentos legalesThe 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 Operativa2025-04info:eu-repo/semantics/articleinfo:eu-repo/semantics/publishedVersionArticulohttp://purl.org/coar/resource_type/c_6501info:ar-repo/semantics/articuloapplication/pdfhttp://sedici.unlp.edu.ar/handle/10915/177987enginfo:eu-repo/semantics/altIdentifier/url/https://revistas.unlp.edu.ar/ejs/article/view/18839info:eu-repo/semantics/altIdentifier/issn/1514-6774info:eu-repo/semantics/altIdentifier/doi/10.24215/15146774e068info:eu-repo/semantics/openAccesshttp://creativecommons.org/licenses/by-nc-sa/4.0/Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)reponame:SEDICI (UNLP)instname:Universidad Nacional de La Platainstacron:UNLP2025-09-29T11:48:08Zoai:sedici.unlp.edu.ar:10915/177987Institucionalhttp://sedici.unlp.edu.ar/Universidad públicaNo correspondehttp://sedici.unlp.edu.ar/oai/snrdalira@sedici.unlp.edu.arArgentinaNo correspondeNo correspondeNo correspondeopendoar:13292025-09-29 11:48:08.52SEDICI (UNLP) - Universidad Nacional de La Platafalse
dc.title.none.fl_str_mv 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
title The impact of LLaMA fine tuning on hallucinations for name entity extraction in legal documents
spellingShingle The impact of LLaMA fine tuning on hallucinations for name entity extraction in legal documents
Vargas, Francisco
Ciencias Informáticas
Named entity recognition
Large Language Models
Legal Documents
Reconocimiento de entidades nombradas
Grandes Modelos de Lenguaje
Documentos legales
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 The impact of LLaMA fine tuning on hallucinations for name entity extraction in legal documents
dc.creator.none.fl_str_mv Vargas, Francisco
González Coene, Alejandro
Escalante, Gastón
Lobón, Exequiel
Pulido, Manuel
author Vargas, Francisco
author_facet Vargas, Francisco
González Coene, Alejandro
Escalante, Gastón
Lobón, Exequiel
Pulido, Manuel
author_role author
author2 González Coene, Alejandro
Escalante, Gastón
Lobón, Exequiel
Pulido, Manuel
author2_role author
author
author
author
dc.subject.none.fl_str_mv Ciencias Informáticas
Named entity recognition
Large Language Models
Legal Documents
Reconocimiento de entidades nombradas
Grandes Modelos de Lenguaje
Documentos legales
topic Ciencias Informáticas
Named entity recognition
Large Language Models
Legal Documents
Reconocimiento de entidades nombradas
Grandes Modelos de Lenguaje
Documentos legales
dc.description.none.fl_txt_mv 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
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%.
publishDate 2025
dc.date.none.fl_str_mv 2025-04
dc.type.none.fl_str_mv info:eu-repo/semantics/article
info:eu-repo/semantics/publishedVersion
Articulo
http://purl.org/coar/resource_type/c_6501
info:ar-repo/semantics/articulo
format article
status_str publishedVersion
dc.identifier.none.fl_str_mv http://sedici.unlp.edu.ar/handle/10915/177987
url http://sedici.unlp.edu.ar/handle/10915/177987
dc.language.none.fl_str_mv eng
language eng
dc.relation.none.fl_str_mv info:eu-repo/semantics/altIdentifier/url/https://revistas.unlp.edu.ar/ejs/article/view/18839
info:eu-repo/semantics/altIdentifier/issn/1514-6774
info:eu-repo/semantics/altIdentifier/doi/10.24215/15146774e068
dc.rights.none.fl_str_mv info:eu-repo/semantics/openAccess
http://creativecommons.org/licenses/by-nc-sa/4.0/
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
eu_rights_str_mv openAccess
rights_invalid_str_mv http://creativecommons.org/licenses/by-nc-sa/4.0/
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
dc.format.none.fl_str_mv application/pdf
dc.source.none.fl_str_mv reponame:SEDICI (UNLP)
instname:Universidad Nacional de La Plata
instacron:UNLP
reponame_str SEDICI (UNLP)
collection SEDICI (UNLP)
instname_str Universidad Nacional de La Plata
instacron_str UNLP
institution UNLP
repository.name.fl_str_mv SEDICI (UNLP) - Universidad Nacional de La Plata
repository.mail.fl_str_mv alira@sedici.unlp.edu.ar
_version_ 1844616344125833216
score 13.070432