
In the clinical research space today, one of the greatest challenges is effectively harnessing unstructured data—data that does not conform to a predefined format, like free-text patient records, clinical notes, and even transcripts of patient interviews.
Traditional methods have often struggled to process this type of data due to its variability and complexity.
However, the advent of Transformers has enhanced the way we approach unstructured data in healthcare, offering more accuracy, efficiency, and deeper insights than ever before.
In this article, we’ll take a closer look at how Transformers work, the technical components that make them so effective, and provide a detailed example of their application in transforming unstructured healthcare text.
We’ll also explore how Srotas Health is utilising this cutting-edge technology to address critical challenges in clinical trials.
Understanding Unstructured Data in Healthcare
Unstructured data in healthcare includes a wide range of content, such as:
• Clinical notes: Free-text notes written by healthcare providers that describe patient conditions, diagnoses, and treatment plans.
• Radiology reports: Detailed descriptions of imaging results, often filled with medical jargon and complex language.
• Pathology reports: Free-text reports that summarize laboratory findings.
• Discharge Summaries: Summaries describing their observations, procedures, and responses to treatment.

These forms of unstructured data are rich in information but challenging to process using conventional data analysis methods that rely on structured data, such as spreadsheets or databases.
How Conventional Methods Handle Unstructured Data
Before the introduction of advanced models like Transformers, conventional methods of handling unstructured data involved:
• Manual annotation and extraction: Human experts would read through texts to extract relevant information. This process is time-consuming, prone to errors, and difficult to scale.
• Rule-based systems: Algorithms would use predefined rules to identify and extract specific pieces of information. While effective in narrow use cases, these systems often fail to generalize to broader or more complex datasets.
• Bag-of-Words and TF-IDF: These techniques convert text into numerical representations by counting word occurrences (Bag-of-Words) or by weighting words based on their frequency in a document relative to a corpus (TF-IDF). However, they lose the context and order of words, making it difficult to capture the nuances of language.
Enter Transformers: A Game-Changer for Unstructured Data
Transformers are advanced AI models that excel at processing sequences of data by using self-attention mechanisms, which allow the model to weigh the importance of different parts of the input. They incorporate feedforward neural networks within their layers to process and refine this attention-based information, enabling efficient and accurate analysis of complex data like language or medical records.
Transformer Architecture Simplified

Let’s break down how they work, using a detailed example of transforming a healthcare-related text.
1. Tokenisation
Tokenisation is the process of breaking down text into smaller units, usually words or subwords. For example, consider the clinical note: “The patient exhibits signs of severe acute respiratory distress.”
• Tokenisation output: ["The", "patient", "exhibits", "signs", "of", "severe", "acute", "respiratory", "distress"]
In more advanced scenarios, subword tokenisation may be applied, especially for medical jargon or terminology. For example, “respiratory” might be tokenised into ["resp", "iratory"] to handle uncommon or compound words more effectively.

2. Embeddings
Once tokenized, each word or subword is converted into an embedding—a dense vector of numbers that represents the token’s meaning in a multi-dimensional space. The key advantage of embeddings is that they capture semantic relationships between words.
• Example embeddings: For instance, the words “severe” and “acute” might have similar embeddings because they often appear in related medical contexts.
If we imagine a 3-dimensional space, the embeddings for “severe,” “acute,” and “critical” might all be close to each other, reflecting their related meanings. This proximity allows the model to recognise that these words are related, even if they don’t appear in identical contexts.

3. Positional Encoding
Transformers do not process text sequentially like older models (e.g., Recurrent Neural Networks). Instead, they look at the entire sequence of tokens at once. However, without some way to understand the order of words, the model could lose the sentence’s meaning. Positional encoding is a technique that adds positional information to the embeddings.
• Example: In the sentence “The patient exhibits signs of severe acute respiratory distress,” positional encoding ensures that “severe” is understood as describing “acute respiratory distress” rather than any other condition in the text.

4. Attention Mechanism
The attention mechanism is perhaps the most revolutionary aspect of Transformers. It allows the model to focus on specific parts of the input when making predictions, dynamically weighing the importance of different words in the context of the entire sentence.
• Example: In the phrase “The patient exhibits signs of severe acute respiratory distress,” the attention mechanism might focus more on the words “severe” and “acute respiratory distress” when predicting the patient’s condition. The model learns which parts of the sentence are most relevant to the task at hand, such as diagnosis or treatment recommendation.

5. Self-Attention and Contextual Understanding
Transformers use a technique called self-attention to compare each word in the sentence with every other word. This allows the model to understand the context in which a word appears fully.
• Example: In a more complex sentence like “Although the patient shows signs of improvement, severe acute respiratory distress remains,” self-attention helps the model understand that “severe acute respiratory distress” is the primary concern, despite the initial mention of “improvement.”
6. Softmax and Output Layer
Finally, the output of the Transformer model is passed through a Softmax function, which converts the raw output into probabilities. This step is crucial for making predictions or classifications based on the processed text.
• Example: After processing the clinical note, the Transformer might predict the likelihood of different diagnoses or recommend a specific treatment protocol with associated confidence levels.

Logits are the raw, unnormalised outputs of a machine learning model, particularly in the context of classification tasks. Before being passed through an activation function like Softmax, these logits represent the model’s confidence about each possible class or category. However, they aren’t yet in a form that is easily interpretable as probabilities.
Case Study: Transforming Unstructured Text in Clinical Trials
Let’s consider a practical example in a clinical trial setting:
Scenario:
A clinical trial aims to match patients with suitable trials based on their medical history, which is often documented in unstructured text form.
Traditional Approach:
• Manual review: Clinicians would manually read through each patient’s history, trying to identify key terms that match the inclusion criteria of the trial.
• Rule-based extraction: An algorithm might be set up to look for specific keywords like “severe,” “acute,” or “respiratory distress.” However, this approach could miss relevant information if the keywords don’t appear exactly as expected.
Transformer-Based Approach:
• Step 1: Tokenization and Embeddings: The patient’s medical history is tokenized and converted into embeddings, capturing the nuances of medical language.
• Step 2: Positional Encoding and Attention: The model processes the entire sequence of the patient’s history, paying attention to critical details such as the severity of symptoms and their temporal progression.
• Step 3: Self-Attention and Contextual Understanding: By comparing different parts of the medical history, the model can understand that “improvement” in one area does not negate “severe acute respiratory distress” in another.
• Step 4: Softmax Prediction: Finally, the model predicts the best matching clinical trial based on the processed and understood text, providing a ranked list of suitable trials.

How Srotas Health Utilises Transformers
At Srotas Health, our advanced Large Language Models (LLMs), powered by Transformers, are at the heart of our data processing pipeline, enabling us to address the challenges of unstructured data in clinical trials. Here’s how our LLMs, based on Transformer architecture, make a difference:

• Patient Matching: Our LLMs analyze complex patient histories, including free-text notes, to accurately match patients with the most suitable clinical trials. The attention mechanism within the Transformer ensures that the model focuses on the most relevant parts of a patient’s medical record, significantly improving the accuracy of the match.
• Clinical Outcome Prediction: By processing unstructured data from various sources, our LLMs predict patient outcomes, helping clinicians make informed decisions more quickly. The deep understanding of context and meaning, enabled by Transformers, makes these predictions highly reliable.
• Data Integration: Transformers allow our LLMs to seamlessly integrate data from diverse sources—such as clinical notes, pathology reports, and patient feedback—into a unified dataset. This integrated approach enables us to uncover patterns and insights that might otherwise remain hidden.
Conclusion
Transformers are transforming the way we handle unstructured data in clinical trials. By breaking down complex data into understandable chunks, embedding their meaning, and using attention mechanisms to focus on what’s important, these models are helping to unlock new insights and efficiencies in the clinical trial process.
At Srotas Health, we’re at the forefront of this revolution, using Transformers based LLMs to solve real-world challenges and bring better treatments to patients faster.
This is just the beginning of what’s possible when cutting-edge Gen-AI meets the world of clinical trials.
Thanks for reading. Check back soon for more updates!