<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>Jaén, Spain
* Corresponding author.
$ jonathan.heras@unirioja.es (J. Heras)
 https://www.unirioja.es/cu/joheras (J. Heras)</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Two-stage Fine-Tuning for Automatic Identification of Sections in Clinical Documents</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Jónathan Heras</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Mathematics and Computer Science, University of La Rioja</institution>
          ,
          <country country="ES">Spain</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2023</year>
      </pub-date>
      <volume>000</volume>
      <fpage>0</fpage>
      <lpage>0003</lpage>
      <abstract>
        <p>Electronic Clinical Narratives (ECN) are the standard for storing relevant information to describe and evaluate a patient's clinical episode or evolution. The ClinAIS task aims to tackle the problem of automatic identification of sections in unstructured Spanish ECNs. In this work, we tackle this challenge by first ifne-tuning a language model with the ClinAIS dataset, for later applying a second fine-tuning stage for section identification. The performance of several models was studied using this approach, and a Longformer based model obtained the best results in the validation set. Using this model, we achieved the third position in the ClinAIS challenge with a weighted B2 score of 0.7036 in the test set.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Fine-tuning</kwd>
        <kwd>ClinAIS</kwd>
        <kwd>Clinical Documents</kwd>
        <kwd>HuggingFace</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        The amount of digitised data available from healthcare systems is increasing exponentially [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
Among that data, Electronic Clinical Narratives (ECN) have become the standard for storing all
the information a practician finds relevant to describe and evaluate a patient’s clinical episode
or evolution. Within these documents, practicians can find information such as past medical
conditions, medical procedures undergone, disease progression, or prescribed treatments. As
ECNs have become the standard for data storage, their secondary use has gained prominence in
addressing various tasks such as the identification of rare medical events, prediction of hospital
readmissions, and public health surveillance.
      </p>
      <p>A fundamental task for the advancement of higher-level applications in healthcare is the
accurate identification of medical sections within patient narratives documented in ECNs.
This task involves the division of the text into semantic segments and assigning them specific
predefined labels. Through section identification, valuable insights can be gleaned regarding
diferent entities, which may vary significantly depending on the section in which they are
found. For example, a pathology mentioned in the patient’s medical history section could be
utilized to predict future conditions and assess the risk of illness. Similarly, the presence of
specific symptoms in the Evolution section of the narrative might indicate adverse reactions to
a particular treatment.</p>
      <p>
        The ClinAIS task presented at IberLEF 2023 [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] aims to tackle the problem of automatic
identification of sections in unstructured Spanish clinical documents [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. The task is focused on
identifying seven predefined medical sections: Present Illness, Derived from/to, Past Medical
History, Family history, Exploration, Treatment and Evolution. In this work, we tackle this
challenge by first fine-tuning a language model with the ClinAIS dataset, for later applying
a second fine-tuning stage for section identification. The code of this project is available at
https://github.com/joheras/ClinAIS.
      </p>
    </sec>
    <sec id="sec-2">
      <title>2. Dataset Description</title>
      <p>
        The ClinAIS dataset’s corpus was obtained from the CodiEsp dataset, which was presented in
the eHealth CLEF 2020 task [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. The CodiEsp dataset is a corpus of unstructured clinical case
reports from diferent medical specialties, and it contains 1000 annotated documents for Named
Entity Recognition and 2751 unannotated documents as a background set. From the CodiEsp
dataset, 1038 distinct notes were randomly selected to form the ClinAIS dataset [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ].
      </p>
      <p>For annotation, a set of guidelines were initially created to identify patterns and categorize
each section in unstructured clinical notes into 7 categories: Present Illness, Derived from/to, Past
Medical History, Family history, Exploration, Treatment and Evolution. From those guidelines,
a group of experts went through several rounds of annotating a small set of notes and updating
the guidelines accordingly. When the annotation process became more mature, two doctors,
trained in clinical report annotation for diferent tasks, performed a double annotation on the
notes. The annotation task was iterative and the evaluation metric was employed to measure
the inter-tagger agreement, reaching 75%.</p>
      <p>Once the dataset was annotated, the 1038 notes were split into three groups: training (75%,
781 notes), validation (12.5%, 127 notes), and test (12.5%, 130 notes) sets. The training and
validation sets were publicly released with their annotations, whereas the annotation of the
test set was kept private. The evaluation on the test set was conducted by the judges of the
competition.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Methods</title>
      <p>
        The approach followed here for section identification is based on the transfer learning method
proposed in the ULMFIT paper [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. Given a language model pre-trained on a large dataset, the
ULMFIT method consists of two stages. In the first stage, the language model is specialized
to a particular context by fine-tuning it with a small dataset of text; after that, the specialised
language model is trained to tackle a particular task. In this work, we used the training set of
the ClinAIS dataset as small text dataset for the first stage — obtaining in this manner, language
models specialized into clinical case reports. Subsequently, for the second stage, we trained
those specialized models for the task of clinical section identification using the ClinAIS dataset.
      </p>
      <p>
        For our work, we have studied several pre-trained language models available at HuggingFace.
In particular, we considered two versions of the multi-lingual XLM-RoBERTa model (base and
large versions) [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]; a DistilBert Spanish model [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] trained on the Large Spanish Corpus [9]; two
RoBERTa-based models one trained on a biomedical-clinical corpus in Spanish collected from
several sources and the other trained on a clinical dataset [10]; and a Longformer version of the
roberta-base-bne masked language model for the Spanish language [11]. The links to the base
models are provided in Table 1
      </p>
      <p>
        All the models were trained using the functionality provided by the HuggingFace libraries [12]
and using a GPU Nvidia GeForce 3090. The hyperparameters used for training the models can
be checked in the code available on the project webpage. The validation set was used to evaluate
the performance of the models and to select the model that was finally used to perform the
predictions in the test set. The metric employed to evaluate the models is an adaption of the
boundary distance  developed by C. Fournier [13] called weighted B2 metric — details about
this metric can be found in [
        <xref ref-type="bibr" rid="ref3 ref5">3, 5</xref>
        ].
      </p>
      <p>Given a sentence, the final models classify each token into B-Class, E-Class or Class — where
Class corresponds with one of the 7 predefined medical sections of the ClinAIS dataset, B-Class
indicates the beginning of a section, E-Class indicates the end of a section, and Class means that
the token is inside a section. Since such an output might produce inconsistencies (for instance a
token classified as Class2 inside a sentence that started with B-Class1), the output of the model
is post-process to deal with those inconsistencies.</p>
    </sec>
    <sec id="sec-4">
      <title>4. Results</title>
      <p>We start by evaluating the trained models, but we skip the first stage of fine-tuning with the
ClinAIS dataset. Instead, we solely train the models for the task of section identification. Please
refer to Table 2. The best model using this approach, with a weighted B2 score of 0.7341, was a
Longformer-based model combined with the post-processing step. If we analyze the rest of the
models, the 3 best models were initially pre-trained with a biomedical Spanish dataset; whereas,
the other models, which were trained with generic Spanish or multi-lingual datasets, obtained
considerably worse results. It is also worth mentioning the importance of the post-processing
stage, since the plain output of all models was inferior to their post-processed counterparts.</p>
      <p>In our second set of experiments, we evaluated the models trained using the two-stage
approach presented previously, see Table 3. In general, all the models, except for the
Longformerbased model, obtained better results than their counterparts trained only for section
identification. We can draw similar conclusions to those noticed in the first set of experiments: the
models initially pre-trained with biomedical Spanish datasets obtained better results, and the
post-processing stage improved the performance of the models. However, the best performing
plain output post-process
plain output post-process
plain output post-process
model, a RoBERTa-based model with a weighted B2 score of 0.7311, achieved worse results than
those obtained by the Longformer-based model trained only on section identification.</p>
      <p>Finally, we applied the two-stage procedure to an artificially augmented version of the
ClinAIS dataset. In particular, we hide some of the words of the notes, and used a
RoBERTabased language model to predict those missing words. This allowed us to obtain a training
dataset of 2850 notes. The results obtained for this augmented dataset are presented in Table 4.
Unfortunately, this approach did not lead to any improvement.</p>
      <p>Following this study, we utilized the one-stage fine-tuned Longformer-based model,
determined as the best model based on our evaluation, to generate predictions for the test set of the
ClinAIS challenge. This model achieved a weighted B2 score of 0.7036.</p>
    </sec>
    <sec id="sec-5">
      <title>5. Conclusions</title>
      <p>In this paper, we have used the two-stage training procedure presented in the ULMFIT work
for training several models for medical section identification in unstructured clinical notes.
In general, the two stage procedure (first building a specialized language model, and then
ifne-tuning the model for section identification) provides better results than only training the
models for section identification. However, the best model was a Longformer-based model that
was only trained for section identification and achieved a final score of 0.7036 in the test set.</p>
    </sec>
    <sec id="sec-6">
      <title>Acknowledgments</title>
      <p>This work was partially supported by Ministerio de Ciencia e Innovación [PID2020-115225RB-I00
/ AEI / 10.13039/501100011033].
[9] L. Tunstall, The large spanish corpus, 2022. https://huggingface.co/datasets/large_spanish_
corpus.
[10] C. P. Carrino, J. Armengol-Estapé, A. Gutiérrez-Fandiño, J. Llop-Palao, M. Pàmies,
A. Gonzalez-Agirre, M. Villegas, Biomedical and clinical language models for
spanish: On the benefits of domain-specific pretraining in a mid-resource scenario, 2021.
arXiv:2109.03570.
[11] I. Beltagy, M. E. Peters, A. Cohan, Longformer: The long-document transformer,
arXiv:2004.05150 (2020).
[12] L. Tunstall, L. Von Werra, T. Wolf, Natural language processing with transformers, "</p>
      <p>O’Reilly Media, Inc.", 2022.
[13] C. Fournier, Evaluating text segmentation using boundary edit distance, in: Proceedings
of the 51st Annual Meeting of the Association for Computational Linguistics (Volume 1:
Long Papers), 2013, pp. 1702–1712.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>H.</given-names>
            <surname>Dalianis</surname>
          </string-name>
          ,
          <article-title>Clinical text mining: Secondary use of electronic patient records</article-title>
          , Springer Nature,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>S. M.</given-names>
            <surname>Jiménez-Zafra</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Rangel</surname>
          </string-name>
          ,
          <string-name>
            <surname>M.</surname>
          </string-name>
          <article-title>Montes-y Gómez, Overview of IberLEF 2023: Natural Language Processing Challenges for Spanish and other Iberian Languages, in: Proceedings of the Iberian Languages Evaluation Forum (IberLEF 2023), co-located with the 39th Conference of the Spanish Society for Natural Language Processing (SEPLN 2023), CEURWS</article-title>
          .org,
          <year>2023</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>I. de la Iglesia</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Vivó</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          <string-name>
            <surname>Chocrón</surname>
            , G. de Maeztu,
            <given-names>K.</given-names>
          </string-name>
          <string-name>
            <surname>Gojenola</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          <string-name>
            <surname>Atutxa</surname>
          </string-name>
          , Overview of ClinAIS at IberLEF 2023:
          <article-title>Automatic Identification of Sections in Clinical Documents in Spanish</article-title>
          ,
          <source>Procesamiento del Lenguaje Natural</source>
          <volume>71</volume>
          (
          <year>2023</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>A.</given-names>
            <surname>Miranda-Escalada</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Gonzalez-Agirre</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Armengol-Estapé</surname>
          </string-name>
          ,
          <string-name>
            <surname>M.</surname>
          </string-name>
          <article-title>Krallinger, Overview of automatic clinical coding: Annotations, guidelines, and solutions for non-english clinical cases at codiesp track of CLEF ehealth 2020</article-title>
          , in: L.
          <string-name>
            <surname>Cappellato</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          <string-name>
            <surname>Eickhof</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          <string-name>
            <surname>Ferro</surname>
            ,
            <given-names>A</given-names>
          </string-name>
          . Névéol (Eds.), Working Notes of CLEF 2020 -
          <article-title>Conference and Labs of the Evaluation Forum</article-title>
          , Thessaloniki, Greece,
          <source>September 22-25</source>
          ,
          <year>2020</year>
          , volume
          <volume>2696</volume>
          <source>of CEUR Workshop Proceedings, CEUR-WS.org</source>
          ,
          <year>2020</year>
          . URL: https://ceur-ws.
          <source>org/</source>
          Vol-
          <volume>2696</volume>
          /paper_263.pdf.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <surname>I. de la Iglesia</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Vivó</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          <string-name>
            <surname>Chocrón</surname>
            , G. de Maeztu,
            <given-names>K.</given-names>
          </string-name>
          <string-name>
            <surname>Gojenola</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          <string-name>
            <surname>Atutxa</surname>
          </string-name>
          ,
          <article-title>An Open Source Corpus and Automatic Tool for Section Identification in Spanish Health Records</article-title>
          ,
          <source>Journal of Biomedical Informatics</source>
          (
          <year>2023</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>J.</given-names>
            <surname>Howard</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Ruder</surname>
          </string-name>
          ,
          <article-title>Universal language model fine-tuning for text classification</article-title>
          , arXiv preprint arXiv:
          <year>1801</year>
          .
          <volume>06146</volume>
          (
          <year>2018</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>A.</given-names>
            <surname>Conneau</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Khandelwal</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Goyal</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Chaudhary</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Wenzek</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Guzmán</surname>
          </string-name>
          , E. Grave,
          <string-name>
            <given-names>M.</given-names>
            <surname>Ott</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Zettlemoyer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Stoyanov</surname>
          </string-name>
          ,
          <article-title>Unsupervised cross-lingual representation learning at scale</article-title>
          , CoRR abs/
          <year>1911</year>
          .02116 (
          <year>2019</year>
          ). URL: http://arxiv.org/abs/
          <year>1911</year>
          .02116. arXiv:
          <year>1911</year>
          .02116.
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>V.</given-names>
            <surname>Sanh</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Debut</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Chaumond</surname>
          </string-name>
          , T. Wolf,
          <article-title>Distilbert, a distilled version of bert: smaller, faster, cheaper and lighter</article-title>
          , ArXiv abs/
          <year>1910</year>
          .01108 (
          <year>2019</year>
          ).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>