Elamur Research

Developing a Clinical Language Model for Swedish: Continued Pretraining of Generic BERT with In-Domain Data

Paper · 2021 · Anastasios Lamproudis, Aron Henriksson and Hercules Dalianis

Summary

A hospital record can be written in Swedish and still pose a problem for software trained on general Swedish writing. The record may contain specialist terms, locally understood initials and familiar words used in a medical sense. Lamproudis and colleagues ask whether a general Swedish language model can become more useful on such records by spending an additional period of training reading them. They begin with KB-BERT, which was already available, and resume training on 17.8 GB of notes from Health Bank. During this stage, the system learns by predicting pieces of the notes from their surroundings. The notes can supply those targets without being labeled for any of the tasks used to assess the adaptation.

The authors train the original and adapted versions separately for each task using labeled examples, a process called fine-tuning. Clinical KB-BERT, the adapted version, achieves a test F1 of 92.48% for identifying protected health information, against 90.98% for the original. The main change is in recall, which reflects how much of the annotated information each version finds. On discharge summaries, the test F1 for assigning groups of diagnosis codes is 82.76% with clinical KB-BERT and 80.35% with the original. On sentence-level uncertainty, it is 93.69% and 93.05%, respectively. Both precision and recall increase on those classification tasks.

The pattern reverses on named entity recognition in Swedish web news. Clinical KB-BERT reaches a test F1 of 80.58%, while the original reaches 84.14%. The outcome suggests that the subject and style of the additional material matter to the benefit. An equally long continuation on general Swedish would be needed to measure how much of the clinical improvement could come from extra training outside the clinical domain. Saved states from the clinical run show that the gains can emerge well before the run is complete. The authors observe better results on all the clinical tasks after 20% of the notes have been used, although uncertainty classification dips late in training and then recovers.

The authors also examine tokenization, the procedure that converts writing into the units BERT processes. Compared with a simpler way of dividing sentences, KB-BERT's inherited procedure increases the average number of units more for the clinical sentences than for the news sentences. The authors suggest that more of the learning in clinical notes may consequently depend on short pieces of words. That explanation remains open to a direct test. What the study demonstrates is that changes to the learned parameters can improve these clinical tasks with the general Swedish vocabulary still in place.

Deep dive: Developing a Clinical Language Model for Swedish: Continued Pretraining of Generic BERT with In-Domain Data

Continuing Swedish BERT pretraining on hospital notes improved three clinical text tasks and lowered performance on Swedish news entity recognition. · about 33 minutes to read

The problem and its context

A language and a setting for using it

The authors frame the problem around the difference between knowing a language in general and having experience with a particular kind of writing. The Swedish encountered in newspapers and literature uses many of the same forms as a hospital record. Their frequencies can differ, and familiar forms can carry different meanings. Clinical staff also write with conventions that make sense within their work, including technical terminology, abbreviations and acronyms that may have been coined for a local purpose. The challenge is to learn enough about those conventions to make reliable decisions about the text.

Those decisions are diverse. If the purpose is to help de-identify a record, the relevant output may be the location and type of a name or date. If the purpose is to organize discharge summaries by diagnosis, the decision applies to an entire document and can produce several labels. A study of how clinicians phrase assessments may instead ask whether an individual sentence expresses uncertainty. The problem of handling clinical Swedish therefore extends beyond recognizing a list of medical terms. It includes seeing how expressions function in context and using that information to make decisions at different scales.

The authors place this problem within a broader shift in natural language processing. Teaching a system directly from examples of a particular task depends on having those examples labeled. The cost and effort of obtaining them can be high. A stock of hospital notes and a stock of examples in which relevant passages have been marked or categories have been assigned serve different purposes. A training procedure that can learn from the first collection gives researchers a way to make use of more text before asking the system to produce the outputs defined by the second collection.

In the framework the paper adopts, pretraining is the stage that builds general representations from text. A representation is a learned numerical description that the system can use in later decisions. Pretraining can make use of a prediction problem whose targets come from the text itself. Fine-tuning introduces the annotations needed for a particular application and adjusts the learned parameters to support that application. The labeled material determines what counts as a correct answer, while the pretrained system already has experience processing the language in which the evidence occurs.

BERT is the starting point for this approach. Its architecture comes from the Transformer, whose self-attention mechanism allows the representation at one position to draw on information from other positions in the input. For the Swedish study, the practical consequence of the earlier work is that the authors can reuse parameters learned in a substantial training run. The organization that trained the original system incurred the cost of learning from the general collection. A group with access to the resulting checkpoint can use it to begin learning a new task or to continue learning from text in a new setting.

The public Swedish starting point is KB-BERT, which was pretrained on material from the National Library of Sweden. The gap identified by the authors was a corresponding version adapted to Swedish clinical records. The published work they discuss had already established specialty pretraining as a research direction, especially for English biomedical and clinical writing. It supplied several ways to proceed, with different implications for how much of the original system to carry forward.

Where earlier work put the domain knowledge

One route is to start anew, using specialized text and possibly some general text. This allows the training corpus to shape the vocabulary from the outset. Another route starts with parameters already learned from general text and continues pretraining on specialized material. The authors call the broad version of this second route domain-adaptive pretraining. They also discuss task-adaptive pretraining, where the added text is selected because it is especially close to the eventual task. The distinction concerns how the additional corpus is chosen. It can seek to represent clinical writing broadly, or it can target the particular kind of text a single application will process.

The precedent that most closely illustrates the reuse of both parameters and vocabulary is BioBERT. In the Swedish paper's account, that project started with general BERT and extended its training to abstracts from PubMed and full articles from PMC. It retained the general system's vocabulary and improved performance on biomedical tasks. The significance of this example for Swedish is that the inventory of input units and the experience acquired using them can be changed independently. An existing inventory can still support further learning on a corpus with a different distribution of words.

Other biomedical studies made changes on a larger scale. The paper describes BioMegatron as exploring larger systems and larger specialized corpora, with a vocabulary tailored to the domain in some settings. The study on domain-specific pretraining from scratch is cited for evidence that building a system directly from biomedical text could yield stronger downstream results than continuing from a general checkpoint. The Swedish authors also note the computing demands of training from the beginning. Their own setup has a public checkpoint that already represents Swedish, a substantial hospital corpus and a question about the value of continuing from that checkpoint.

An important precedent comes from Clinical BERT, which used notes from MIMIC-III. The earlier study tried starting from general BERT and from BioBERT. It also examined whether to use a range of note types or restrict the clinical corpus to discharge summaries. As Lamproudis and colleagues describe it, starting from BioBERT gave stronger downstream performance, while the choice of note types made little difference to most of the tasks. The earlier clinical systems improved some of the evaluations. The variation across tasks gives a reason to assess adaptation on multiple labeled problems, including one that concerns identifiers.

Work on combined biomedical and clinical training raised a related question about scale. The study on pretraining for biomedical and clinical tasks investigated choices of corpus, system size and vocabulary, with pretraining changes drawn from RoBERTa. In the Swedish authors' account, a larger general system could be preferable to a smaller specialist system, and the addition of clinical material yielded substantial gains specifically on clinical tasks. They also describe a benefit from specialized vocabulary on sequence labeling, where the task assigns labels to parts of a text. The benefit was less clear for classification. These findings give size, corpus choice and vocabulary distinct roles in the design of a study of adaptation.

The Swedish experiment also draws on Don't Stop Pretraining. That work examined several choices of material for continuation, including collections from a broader domain, the training text of the intended task used without its labels, and other unlabeled examples closely related to that task. The Swedish paper highlights the value of the material close to the intended application and the earlier study's attention to how long the additional training lasted. The researchers in Sweden have much more clinical text than labeled material, and they describe the annotated clinical collections as small parts of the larger source. Their experiment uses the clinical corpus broadly and asks how far a single continuation can support different tasks.

Why the comparison extends to news

The hypothesis is that experience with the way Swedish is used in clinical notes will improve the results on clinical benchmarks. The comparison with the existing KB-BERT checkpoint is a direct way to test whether the proposed procedure delivers that benefit. It also leaves several circumstances aligned. The adapted version receives more training, the training material comes from a new domain, and it gets a particular schedule for the new run. A comparison confined to clinical scores would show the effect of the procedure in the intended domain, with limited information about performance elsewhere.

The authors include a news test to examine whether the added training behaves like a general improvement in Swedish text processing. Web news supplies a different genre, and the task of recognizing entities has a clinical counterpart in identifying protected health information. The test therefore allows a comparison across domains that does not depend entirely on changing the kind of output. Each dataset still has its own definitions of an entity and its own relation between inputs and labels. The comparison concerns the effect of using the adapted starting point within each task, with the clinical and news datasets serving as different probes of that effect.

The method, step by step

Reuse the Swedish checkpoint

The procedure begins with a saved state of KB-BERT. This state, called a checkpoint, contains the parameter values learned during the original pretraining. Starting there gives the researchers a system that can already process Swedish. Its architecture defines how the inputs are transformed into internal representations, and its vocabulary supplies the units available to encode the text. The continuation uses this same starting architecture and vocabulary while giving the parameters a new distribution of examples to learn from.

The original checkpoint plays another role in the design. It is the starting point for the baseline on each downstream task. The researchers can fine-tune it immediately on the relevant annotation, or they can first run the additional pretraining and fine-tune from a state saved during that run. This makes the conditions easy to identify. There is a common origin for the parameters, an optional stage of further learning from notes, and a supervised stage in which each candidate learns the required output.

Training and evaluating clinical KB-BERT

The steps in order.

Training and evaluating clinical KB-BERTStep 1: Initialize from the public Swedish checkpoint1. Initialize from the public Swedish checkpointStep 2: Gather clinical notes from Health Bank2. Gather clinical notes from Health BankStep 3: Convert note text into WordPiece tokens3. Convert note text into WordPiece tokensStep 4: Pack tokens with markers at document boundaries4. Pack tokens with markers at document boundariesStep 5: Resume masked prediction and save training states5. Resume masked prediction and save training statesStep 6: Fit each checkpoint to the task annotations6. Fit each checkpoint to the task annotationsStep 7: Score predictions on the task test sets7. Score predictions on the task test sets

Use the notes as a source of prediction targets

Health Bank, the Swedish Health Record Research Bank at Stockholm University, supplies the text. The authors describe the resource as containing over 2 million patient records from 500 clinical units at Karolinska University Hospital, with coverage from 2007-2014. For continuation they use 17.8 GB of uncompressed clinical notes, encompassing the available types of notes rather than a collection selected for just one of the downstream problems. The paper compares the volume with that used to build general KB-BERT and describes the amounts as similar. This comparison refers to the reported volume of material. A volume in bytes, a count of patient records and the number of tokens a system consumes describe different aspects of the corpus.

The clinical records used in the continuation were non-pseudonymized. The paper reports approval from the Swedish Ethical Review Authority. The notes are used as text to learn from, even when the document has information of the kind that later appears in a labeled task. A name occurring in a note, for example, can provide a token for the pretraining objective without being marked as a name. The categories in the clinical benchmarks only enter the supervised task training. This separation explains how the same notes can be useful for pretraining even when the researchers have relatively little labeled material for a particular application.

Choosing all available types of notes also defines what the adaptation represents. It can draw on the phrasing of discharge documents while learning from a wider variety of clinical notes. A run using only the unlabeled discharge summaries for diagnosis assignment would represent a more focused kind of adaptation. The authors' design instead asks whether broad exposure supplies a useful starting point for several problems. That breadth describes the choice within Health Bank. It does not make the notes a sample of all the institutions or specialties that could be encountered in Swedish clinical work.

Convert the text to fixed-length sequences

KB-BERT uses WordPiece, a method of subword tokenization. A token is a unit the system processes, which might represent a written word or a smaller portion of one. A specialist expression can therefore be encoded even when there is no entry for it as a whole. The paper describes the construction of a WordPiece inventory as beginning with characters and progressively adding larger units, with the likelihood of the training data guiding the vocabulary choice. For the clinical run, the inventory has already been built. The researchers encode the notes with the general Swedish vocabulary and use the resulting token sequences for learning.

This distinction between text and its encoding matters for the input length. A long expression represented by a single vocabulary entry uses a single position. When the same amount of ordinary text takes more pieces to represent, it uses more positions. Sequence length in the training recipe counts tokens, so a sequence with a given length can correspond to different amounts of text before segmentation. Later, the paper measures one aspect of this effect by applying the inherited tokenizer to two annotated corpora and comparing it with a simpler way of segmenting the same sentences.

The clinical notes vary in length. The authors treat a note as a document when assembling the training input. They concatenate material to form sequences and insert extra [SEP] tokens where notes end. The separator is a special input unit that marks a boundary. Including it allows the data preparation to represent the end of a note even when material from different documents is packed into the same sequence. The paper describes the separators as markers. Its account does not establish that interactions between tokens are blocked across a marked boundary.

For the additional run, the training sequences have length 512. The original KB-BERT pretraining used 128 and 512. The paper relates the choice of exclusively longer sequences to earlier evidence from RoBERTa about downstream performance. It is a choice about the inputs used during continuation. On its own, it says nothing about how a long discharge summary was handled in the separate classification experiment, where the input preparation would have to address the characteristics of that task.

Learn by recovering selected tokens

The pretraining objective is masked language modeling, typically abbreviated MLM. In this task, the input is altered at selected positions and the system learns to predict the token originally present there. The answer can be taken directly from the note. Attention allows the prediction to use information from surrounding positions. In a specialist expression broken into pieces, those surroundings may include other pieces of the same expression as well as other words in the passage. The prediction task thus provides learning signals at the level of the vocabulary the system actually uses.

The paper lists the MLM probability as 15% for both original and clinical pretraining. This parameter controls selection for the masked prediction procedure. It is distinct from the share of the clinical corpus processed by an intermediate checkpoint. Each selected position supplies an opportunity to predict text. As the parameters are updated over many such examples, the system can learn which combinations of units occur in clinical writing and in what context. The eventual value of that learning for an entity label or a diagnosis group is assessed later through fine-tuning.

The continuation lasts 40,000 steps. The authors describe this as roughly one epoch, meaning a pass through the data, and report ten days of training on a GeForce RTX 1080. The original training is listed at 1,000,000 update steps in the paper's comparison of settings. The clinical run adds its updates to a checkpoint that already reflects the earlier learning. Its elapsed time is the time for the continuation on the authors' hardware. The authors do not give a corresponding training run from scratch on Health Bank with which to compare that time.

The reported batch size is 256, achieved with gradient accumulation. A gradient describes how the training error changes as the parameters change. Accumulation lets the training procedure combine gradient contributions from parts of a batch before using them to update the system. This provides a distinction between the effective batch used to compute an update and the amount of data that has to be processed together at any instant. The paper reports the former and identifies the accumulation procedure.

The continuation uses Adam, an optimizer that bases parameter updates on running information from the gradients. Its coefficient β₁ is 0.9 and its coefficient β₂ is 0.999. The first controls the averaging of gradients, and the second controls the averaging of their squares. The training settings also include L2 weight decay of 0.01 and dropout of 0.1. Weight decay acts on parameter magnitudes, and dropout removes selected activations during training. The original and continued runs share those settings in the authors' comparison, alongside the same reported batch size and masking probability.

The paper gives the continuation learning rate in the following form.

1 · 10⁻⁴

The expression gives the scale used for parameter updates under the stated schedule. The 1 is the coefficient, · denotes multiplication, 10 is the base and ⁻⁴ is the exponent. The schedule includes 10,000 warm-up steps and linear decay. Warm-up is an initial period of increasing the learning rate. Linear decay then reduces it over training. The authors specify the masked prediction objective in words and report optimizer settings. They do not give an explicit equation for the prediction loss.

Throughout continuation, saved states make it possible to revisit earlier stages. Each state stands for an amount of exposure to the notes under the same run. To assess an intermediate state, the authors use it to initialize downstream fine-tuning. The scores that trace training progress are thus estimates of how well that state supports each labeled task. They are separate from the error on masked token prediction, which is the signal used to train on the notes.

Train the system to produce the required answers

All the evaluations need task-specific outputs. For the protected health information task and the web-news task, the outputs describe spans and their entity types. For diagnosis-group prediction, the output concerns the entire discharge summary, and several groups can apply to a single example. For uncertainty, each sentence receives one category. The latter tasks are forms of text classification. They differ both in the amount of text classified and in how many labels can be predicted for it.

The authors keep the main BERT architecture for these uses and fit the final classification layers to the task. They allow the BERT parameters to change along with those layers. A fine-tuned checkpoint is therefore shaped by both its pretraining history and the supervised examples it receives. This matters when interpreting a score. The experiment compares the usefulness of different initial states for training a system on a labeled clinical or news problem. The scores are produced after that training, with the output structure and labels appropriate to the task.

For the diagnosis task, the fine-tuning batch size is 32, with the following learning rate.

2 · 10⁻⁵

The 2 is the coefficient multiplying 10 to the power ⁻⁵, and · marks the multiplication. This setting applies to the document-level task that permits several diagnosis groups per input. Both entity recognition tasks and the uncertainty task use a batch size of 64 and a different learning rate.

3 · 10⁻⁵

The coefficient is 3, · means multiplication, and 10 is raised to the exponent ⁻⁵. Within each task, the chosen settings provide a common basis for comparing the starting checkpoints. The authors use values within the ranges suggested in the BERT work and describe stopping training early once the loss converges. They leave a larger search over fine-tuning settings outside the scope of the comparison.

Separate supervised training from evaluation

For an annotated corpus without an existing test division, the study uses roughly 80% of the examples for training, 10% for validation and 10% for testing. The role of the training portion is to supply the labeled answers used to adjust the parameters. The validation portion provides a separate set for assessing training progress. The test portion is reserved for the eventual evaluation. The arrangement allows the original and clinical checkpoints to be compared on the same test material for a given task.

Swedish Web News already has a test split. The authors keep that split and divide the original training portion into new training and validation sets using the reported 90-10% split. The latter percentages apply to the original training portion, so they describe a different division from the percentages for the clinical corpora. Keeping the existing news test split also means the experiment evaluates predictions on the established test examples for that resource.

The supervised split describes where the task annotations enter the experiment. The continued pretraining has a separate source of examples and uses masked text as its target. In the clinical tasks, the paper describes the annotated corpora as small subsets of the material available for pretraining. As a result, a supervised test set held apart from fine-tuning implies separation from the labeled task training. The design would require an additional exclusion at the pretraining stage to demonstrate a comparison on entirely new clinical text.

Experiments and results

How to read the scores

The main result compares the original KB-BERT and the checkpoint from the end of the clinical continuation. For each corpus, both starting points are fine-tuned for the corresponding task. There is no common set of labels shared across the evaluations. The relevant result is the comparison on the same test set and under the same task setup. Intermediate checkpoints are an additional analysis of training progress, while the principal table gives the endpoint scores.

The paper reports precision, recall and F1. Precision measures how much of the positive output being counted is correct. Recall measures how much of the annotated target material the predictions recover. F1 combines the two, so it is sensitive to shortcomings in either. What constitutes a prediction depends on the problem. A diagnosis decision concerns a possible group for a document, while an entity prediction concerns a span and type. The scores are reported as percentages, and the paper's main table does not specify how scores are averaged. Its displayed F1 values are best read directly as reported, without assuming they can be reconstructed from the aggregate precision and recall in the same row.

That qualification matters also for comparisons across datasets. The diagnosis task has a different space of errors from the uncertainty task. An F1 value on the former speaks to the choices among groups assigned to the summaries, and an F1 value on the latter speaks to the labels assigned to sentences in its corpus. Their order by score does not rank the clinical importance of the problems or establish how difficult they would be under a different labeling scheme. A more direct reading asks what changes within each benchmark after additional exposure to notes.

Finding identifying information in clinical text

The Stockholm EPR PHI Corpus contains 21,653 sample sentences comprising 380,000 tokens. Its annotations mark 4,480 entities over 9 protected health information categories. The distinctions include given names and surnames, ages and phone numbers, places and health care units, organizations, complete dates and date parts. This inventory tells the system what to look for in the record. For example, a reference to a unit can be relevant to the task even when it is neither a person's name nor a geographical location.

The recognition problem has both a location and a type component. A passage can contain identifying information whose boundaries have to be found in the surrounding text. It also has to be placed in the appropriate category. The task reflects a stage of de-identification in which the system looks for the material that would need to be removed or replaced. When it overlooks a target, that annotation cannot be recovered by relying on its output alone. When it identifies additional material incorrectly, the prediction can direct attention to portions of the record that the annotation did not mark.

The original system records 90.53% precision, 90.34% recall and 90.98% F1 on the PHI test set. The clinical version records 90.51% precision, 94.04% recall and 92.48% F1. The clinical change is concentrated in recall. The precision scores are close, with the original slightly higher. Thus the evidence for improvement here is that the adapted system recovers more of the expected information at almost the same reported precision.

Test F1 for protected health information on the Stockholm EPR PHI Corpus

Clinical KB-BERT has the stronger aggregate result for detecting identifying information.

Test F1 for protected health information on the Stockholm EPR PHI CorpusOriginal KB-BERT: 90.98Original KB-BERT90.98Clinical KB-BERT (this paper): 92.48Clinical KB-BERT (this paper)92.48
The numbers
System or settingF1 %
Original KB-BERT90.98
Clinical KB-BERT (this paper)92.48

The result measures an ability to find spans in the labeled clinical material. The additional pretraining did not teach the categories for those spans. It supplied experience with records, and the PHI fine-tuning supplied examples of what kinds of spans count. Since the aggregate comparison does not identify the categories responsible for the recall change, the measured improvement could reflect easier recognition of some types, broader improvement across types, or both.

Assigning diagnosis groups to discharge summaries

The Stockholm EPR Gastro ICD-10 Corpus consists of 6,062 discharge summaries. Its categories group codes from K00 to K99 into 10 targets defined by body part. The dataset uses broader groupings than the individual ICD-10 codes. Its summaries average 1.2 labels per sample, and the classifier has to allow more than one group to be assigned to a summary. A multi-label output is important here because assigning one appropriate group cannot settle which other groups apply.

The input unit is the document. An expression in a discharge summary can provide evidence about a group, but the annotation says which groups belong to the summary overall. This changes the interpretation of a false prediction. A missed assignment means the system omitted an annotated group for the document. A spurious assignment adds a group the annotations do not support. The reported precision and recall assess those aspects of group assignment in aggregate.

On the diagnosis test set, general KB-BERT has 85.53% precision, 75.75% recall and 80.35% F1. Clinical KB-BERT has 86.83% precision, 79.06% recall and 82.76% F1. Both precision and recall are higher after adaptation, and the increase in recall is the more pronounced of the two. Each version has higher precision than recall in the reported results. The clinical version therefore improves coverage of the labels while also improving the reported correctness of the groups it proposes.

Test F1 for grouped diagnosis assignment on the Stockholm EPR Gastro ICD-10 Corpus

The clinically continued checkpoint scores higher on assigning diagnosis groups to discharge summaries.

Test F1 for grouped diagnosis assignment on the Stockholm EPR Gastro ICD-10 CorpusOriginal KB-BERT: 80.35Original KB-BERT80.35Clinical KB-BERT (this paper): 82.76Clinical KB-BERT (this paper)82.76
The numbers
System or settingF1 %
Original KB-BERT80.35
Clinical KB-BERT (this paper)82.76

This task provides evidence at a different level from protected health information recognition. The adapted starting point is useful when supervised training asks the system to make decisions about documents whose outputs consist of selected categories. It is also a deliberately bounded test. The labels are grouped diagnoses in the range used by this corpus. The result measures agreement with those annotations for discharge summaries and has that granularity.

Interpreting the uncertainty of a sentence

The Stockholm EPR Sentence Uncertainty Corpus supplies 5,515 examples. Each sentence is annotated as Certain, Uncertain or Undefined. In the full corpus, the Certain category accounts for 88% of the examples and Uncertain for 10%, with the remaining examples in Undefined. The category distribution makes the aggregate especially important to interpret carefully. A result across the corpus and a result for a particular, infrequent category answer different questions.

The supervised procedure teaches the system one label per sentence. There is a distinction between identifying what a sentence is about and identifying how the writer presents the assessment. A clinical condition can be mentioned in either a definite or a tentative formulation. The paper's task concerns the annotated status of the sentence. It is possible for additional experience with the recurring forms of clinical writing to help this decision even when the classifier is trained separately from the other clinical tasks.

The original KB-BERT achieves 92.89% precision, 93.84% recall and 93.05% F1 on the uncertainty test set. Clinical KB-BERT achieves 94.70% precision, 94.38% recall and 93.69% F1. The direction is favorable on every reported metric, with a smaller gain in F1 than for the two other clinical tasks. How much of the improvement reaches sentences annotated Uncertain or Undefined is an open question because the paper gives the aggregate rather than category-specific results.

This is the only clinical test in the study with a single label assigned at sentence level. It joins the entity and document tests in supporting the use of the adapted checkpoint under the authors' fine-tuning conditions. The trajectories add a qualification particular to uncertainty. A favorable endpoint can follow a training run in which some earlier states would be less useful. The checkpoint analysis examines that pattern directly.

Recognizing names and other entities in Swedish web news

The general-domain comparison uses the Swedish Web News Corpus. The paper describes approximately 8,000 sentence samples derived from Webbnyheter 2012 and says the annotation was prepared semi-automatically. The categories are PER for persons, LOC for locations, ORG for organizations and MISC for miscellaneous entities. The task uses the corpus's existing test set. Both checkpoints are adapted to the news annotations before that test.

There is overlap in the kinds of entities a reader can recognize across news and clinical text, but the target inventories serve different purposes. An organization can matter in both settings, while the PHI corpus includes dates and ages among its targets. The relevant observations come from comparing the two starting points on the news scheme and then making the corresponding comparison on the clinical scheme. The experiment never asks a classifier trained to label PHI to label a news article using those same categories.

On the news test set, the original KB-BERT scores 89.81% precision, 82.47% recall and 84.14% F1. Clinical KB-BERT scores 87.50% precision, 78.38% recall and 80.58% F1. The difference favors the original across the reported measures. It remains visible after the clinical version has been fine-tuned on the news task, so the additional supervised training under this setup does not erase the gap between the starting states.

Test F1 for entity recognition on the Swedish Web News Corpus

The original Swedish checkpoint performs better on the news test.

Test F1 for entity recognition on the Swedish Web News CorpusOriginal KB-BERT (this paper): 84.14Original KB-BERT (this paper)84.14Clinical KB-BERT: 80.58Clinical KB-BERT80.58
The numbers
System or settingF1 %
Original KB-BERT (this paper)84.14
Clinical KB-BERT80.58

The evaluation gives a concrete case in which more pretraining material goes together with a worse downstream result. The two entity tasks are particularly informative when read together. Training on clinical notes improves the reported F1 for identifying information in records while lowering it for recognizing entities in web news. The output category sets and corpora differ, but the task family is similar enough that success or failure cannot be attributed simply to the presence of an entity recognition layer. The particular text and labels for which that layer and the underlying parameters are trained matter to the comparison.

What the ablations show

The paper has no formal component ablation, but it compares outcomes across clinical and news tasks, measures downstream scores from intermediate checkpoints and examines how the common tokenizer segments the two kinds of text.

How the effect changes with the evaluation domain

The comparison across domains is a check on the breadth of the improvement. The same additional phase of clinical training supplies the initialization for downstream fine-tuning in every adapted condition. For a given task, the authors apply the same reported fine-tuning settings to the original and adapted checkpoints. Thus an advantage for the clinical version in one setting and a disadvantage in another arise when the effect of the new starting point is measured under different task conditions.

The observed pattern supports the paper's interpretation that the training material has a domain-specific effect. If additional exposure to Swedish yielded a uniform downstream improvement under the chosen procedure, the decline in news would be unexpected. The news result establishes that the clinical continuation has consequences beyond the clinical tasks and can make a general-domain task harder for the subsequent fine-tuning procedure. It also helps situate the gains on the intended tasks. The extra practice consists of Swedish written in the setting those tasks address.

A more narrowly causal question is how much of the clinical benefit is due to the choice of notes over some other extra text. The comparison measures performance with and without the continuation, so the extra updates and the choice of text vary together. The evaluation on news changes where the outcome is measured. It leaves the training intervention intact. To isolate the domain of the additional data more closely, the relevant comparison would be between continuations with similar training schedules and corpora drawn from different domains. Thus the paper supplies evidence of specialization while leaving the size of the corpus-choice effect uncertain.

What changes while learning continues

The saved checkpoints provide a way to ask when clinical continuation makes a difference. The authors find that, after 20% of the in-domain data has been used, the adapted checkpoint can outperform original KB-BERT on all the clinical tasks. This refers to a point in the reported run, during which the procedure is already training on clinical text, and to performance after downstream fine-tuning. It shows that the eventual benefit does not require waiting for the whole corpus to be used in that run.

The fraction has a specific interpretation. The observation comes from the amount of material processed at a checkpoint along a longer pretraining schedule. A different experiment could assemble a smaller clinical corpus, choose its mixture of notes independently and set the training schedule for that corpus. Its examples and optimization history would not necessarily match the early portion of this run. The authors take the early advantage as evidence that clinical adaptation may be useful with less data. The experiment substantiates that possibility through the saved state, without establishing a general requirement for the amount of clinical text.

The clinical trajectories generally trend upward as training progresses. Uncertainty classification is the clearest qualification. Most of its intermediate checkpoints appear to benefit from continuation, but the plotted scores dip near the end of the run before recovering at the final state. A temporary decline can be missed when only the starting and finishing scores are reported. It also shows why the extent of masked pretraining and the downstream F1 need to be treated as separate measurements. Processing more notes advances pretraining, and the usefulness of a particular state still depends on the task and its subsequent fine-tuning.

For the web-news task, the direction over training is generally downward. The authors describe a steady degradation without a clear recovery during the reported interval. This adds to the endpoint comparison because the weaker news result is visible as a developing pattern across checkpoints. The observations still come from a single continuation history. The trends show what happens over that run, and the late movement in the uncertainty scores illustrates the detail that can be lost by treating every task as if it followed the same curve.

What the shared vocabulary does to the inputs

To analyze segmentation, the study begins with the PHI and Web News corpora instead of the complete pretraining datasets. Both contain sentences, which lets the authors compare counts per example. For each corpus, they segment the sentences using whitespace and regular expressions, then examine their lengths when encoded by the KB-BERT WordPiece tokenizer. The simpler procedure supplies a reference number of pieces for the sentences in that corpus. The key observation is how much the average length changes when the segmentation procedure changes.

The clinical corpus shows the larger increase in average tokens per sentence. The paper also presents the sentence-length distributions under the different procedures. The comparison of changes is important because the two collections can have different starting sentence lengths. A longer clinical sentence would use more tokens on that basis alone. The authors' measure asks instead how sensitive the encoded length in each corpus is to the use of WordPiece. The larger expansion for PHI is evidence that the general inventory and segmentation divide that clinical material more finely relative to the reference procedure.

The proposed explanation concerns where the training signal falls. A common general Swedish word may be represented by a whole vocabulary entry or by a combination that occurred often in original pretraining. A clinical term or abbreviation may depend on smaller units used in surroundings that the original system encountered less often. When such sequences recur in the notes, the continuation can adjust the parameters for processing those contexts. The authors suggest that representations of short pieces, potentially down to individual characters, may carry an important share of the adaptation.

The same proposal provides a possible account of the news result. Training on the notes changes parameters that also participate in processing news. Yet the relative frequencies of pieces and their combinations, and the contexts in which they appear, differ across the two genres. An update that helps with a frequent use in a note can have a different effect in prose written for the general public. That makes the tokenizer analysis relevant to how gains and losses can arise together, even though the training begins and ends with the same vocabulary.

The analysis directly measures segmentation through sentence length. It does not identify which pieces receive the most consequential updates or show which of those updates cause particular predictions to change. Distinctive word meanings and patterns of context could affect training even when a form has the same segmentation in both genres. To assess the proposed mechanism directly, an experiment would need to vary or trace the use of the tokenizer during training and then connect that change to downstream results. The present evidence gives the authors a concrete difference in the inputs on which to base their explanation.

Limitations

Limits the authors identify

The researchers choose a comparison of starting checkpoints as their primary aim. They keep the supervised settings within ranges used for BERT and avoid an extensive search for the best settings on each task. They mention learning-rate scheduling, warm-up and clipping gradients as possible avenues for improving fine-tuning. The comparison therefore characterizes performance under the reported procedure. More extensive tuning could improve either checkpoint's best achievable score, and the study does not determine whether it would preserve the gap.

The continuation stops after approximately one epoch. The authors propose extending it to see whether further clinical gains are available. The checkpoint data give a basis for considering that question, since clinical results generally improve during the run. They also show variability for uncertainty and a cost on the news test. The measured interval therefore gives no firm trajectory for a longer run across all evaluations. Training for additional epochs would supply more optimization on the clinical text, and the consequences for the different tasks would need to be measured.

The authors discuss several future changes to the input vocabulary. One is to pretrain from the beginning with a tokenizer built from the clinical corpus. Another is to add selected specialized units to a checkpoint that already exists. A tokenizer learned separately on clinical material could supply candidates that are missing from the general inventory. These ideas address the segmentation difference observed in the paper. They would introduce experimental changes beyond the update of parameters with the inherited vocabulary, so the present numbers cannot tell how well either route would work in Swedish.

Other proposed extensions include exploring different Transformer approaches and continuing on selected portions of the notes. The latter could bring the extra training closer to a specific task by using its textual examples without their labels. There is also a proposal to train on pseudonymized material with the aim of making a clinical version publicly available. The public KB-BERT checkpoint is the starting point of the experiment, and the clinical scores concern the continuation on non-pseudonymized notes. A future run using pseudonymized text would have different inputs and would need its own evaluation.

Limits apparent in the design

The principal comparison bundles extra training time, the choice of clinical text and the continuation recipe. The inputs used for clinical continuation have length 512, while the original pretraining used 128 and 512. General-domain performance helps establish that the whole procedure has selective effects. The study does not quantify the distinct contributions of domain, additional updates and sequence length. In particular, the news test cannot show what would have happened to clinical performance under a matched continuation on additional general Swedish material.

Another limit concerns what counts as a new example. The clinical task annotations are split for fine-tuning and testing, while continued pretraining uses the full collection of available notes described by the paper. The authors describe the annotated corpora as small subsets of the pretraining data and do not report an exclusion procedure for the clinical test texts. Seeing an unlabeled passage during masked prediction differs from seeing its annotated answer during fine-tuning. It can still make the passage familiar. As a consequence, the results leave open how the gains would change under evaluation on clinical notes wholly outside the pretraining material.

The institutional scope is also bounded. The paper describes many clinical units within the hospital source, but reports no separate evaluation on another hospital or subsequent collection period. Differences in writing conventions motivate the adaptation from general Swedish in the first place. They also give a reason to distinguish improvement within the studied resource from improvement on Swedish clinical text across institutions. The data show performance on the named corpora, without a measurement of how much depends on their relation to the place and period covered by Health Bank.

The task definitions set further limits. PHI recognition tests how well the predictions match marked entities. It does not test whether a complete de-identification process produces records suitable for release. The diagnosis experiment uses broad labels within the stated code range, which limits what it establishes about assigning individual codes or working across other parts of the taxonomy. Uncertainty classification tests how well a system reproduces the sentence labels. It leaves the clinical accuracy of the assessments expressed in those sentences outside the evaluation.

The aggregate scores also leave the distribution of benefits unresolved. There is no category-by-category account of the increase in PHI recall, and no separate estimate for the rarer categories in the uncertainty task. The paper gives no confidence intervals or report of how much the main scores vary across repeated runs. The point estimates allow the direction and scale of the reported changes to be read. They supply limited information about how precisely a new fine-tuning run would reproduce those changes, particularly when a gain in aggregate F1 is small.

Finally, the evidence about other domains comes from one news task. The paper documents a decrease there and follows it through the run. It does not measure a corresponding effect across other general Swedish genres or tasks. The segmentation analysis is narrower still in a specific way. It compares the clinical PHI sample and web news, with a simpler segmentation procedure as the reference. That comparison identifies an input difference in those corpora. It leaves open how much a change in vocabulary would influence the results once training, task labels and the mix of text are taken into account.

What came after

The later study Natural Language Processing for Electronic Health Records (2025) cites the Swedish experiment in work whose scope covers Norwegian, Swedish and Danish. Lamproudis and colleagues contribute a specific case within that wider subject. Their experiment begins with an existing general Swedish checkpoint, continues its training on hospital records and measures the resulting starting point on several labeled clinical tasks. It also supplies an example of an adaptation that benefits clinical evaluations while reducing performance on a general-domain evaluation.

The citation links that Swedish case to a discussion of electronic health records across the three languages. The later work's stated scope and citation establish that connection. They leave open whether its authors used the clinical checkpoint in an experiment, reproduced the Swedish procedure or applied a similar continuation to Norwegian or Danish.

Cite

Cite as Anastasios Lamproudis, Aron Henriksson and Hercules Dalianis. 2021. Developing a Clinical Language Model for Swedish: Continued Pretraining of Generic BERT with In-Domain Data. Proceedings of the International Conference on Recent Advances in Natural Language Processing (RANLP 2021).

The paper itself, not this page. BibTeX from the library's record of the work.

@inproceedings{lamproudis2021developing,
  title = {{Developing a Clinical Language Model for Swedish: Continued Pretraining of Generic BERT with In-Domain Data}},
  author = {Anastasios Lamproudis, Aron Henriksson and Hercules Dalianis},
  booktitle = {Proceedings of the International Conference on Recent Advances in Natural Language Processing (RANLP 2021)},
  year = {2021},
  doi = {10.26615/978-954-452-072-4\_090},
  url = {https://doi.org/10.26615/978-954-452-072-4_090}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/lamproudis-2021-developing-clinical-language-model-swedish/