Back to Case Studies

NLP for a Self-Help Psychology Trainer

Overlapping Entity Extraction and Personalised Exercises

ProductionHealthcare & WellbeingOct 2021 – Feb 2022NLP, Knowledge Systems & Generative AI
+17%
User growth after launch, per client
21
Self-help simulators in the app
2
Languages: Russian and Ukrainian
Production
Live in the app, handed over

My Role

Role
Sole ML engineer and data labeler
At CHI Software
Team
Only ML engineer on the project
Stage reached
In production, handed over
Key decisions
  • Define the entity scheme: beliefs, fears, people
  • Switch from NER to span categorization
  • Insert extracted elements into next exercise steps

Approach at a Glance

Details
  1. 1Entity Scheme and Data Labeling
  2. 2BERT-Based NER
  3. 3From NER to Span Categorization
  4. 4Recombination into Personalised Exercises
  5. 5Serving

Executive Summary

The NLP engine behind a self-help "trainer": an app for phone and computer where people work through their beliefs, fears, resentments, emotional situations and self-esteem. The full version has 21 simulators, guided exercises that would normally need a psychologist or coach leading the conversation.

In each exercise the user writes about their situation in their own words, in Russian or Ukrainian. The model reads that text and extracts what matters psychologically: the beliefs, fears and people involved, among other things. Those pieces are then recombined into the next steps of the exercise, so the guidance is built from the user's own words rather than from a generic script. That is what lets the app do work a human coach would otherwise do.

The hardest part was that these elements overlap: the same phrase can be a fear and describe a person at the same time. Classic named entity recognition can't represent that, so we moved from NER to span categorization. After launch, the client reported 17% user growth. I was the only ML engineer on the project and labeled the training data myself.


Client Profile

The client builds a self-help app that guides people through psychological exercises on their own, without a session with a specialist. For that to work, the app has to understand free-form, personal text: a user describing a conflict, a fear or a belief about themselves, in their own words and in two languages.

Several things made this hard:

  • No ready-made models: there were no off-the-shelf models that recognise psychological concepts like beliefs or fears, let alone for Russian and Ukrainian.
  • No labeled data: the training data had to be created from scratch.
  • Overlapping meaning: in real texts, one phrase can play several roles at once, which standard entity recognition doesn't allow.
  • Personal and emotional text: users write informally and emotionally, not in clean, structured sentences.

Technical Approach

  1. Entity Scheme and Data Labeling – I defined the categories the exercises need, such as beliefs, fears and the people involved, and labeled the training data myself in Russian and Ukrainian.

  2. BERT-Based NER – The first version used a BERT-based named entity recognition model in a spaCy pipeline to find these elements in the user's text.

  3. From NER to Span Categorization – Soon after the start it became clear that entities overlap: one phrase can belong to several categories. NER assigns each word to at most one entity, so overlapping elements were lost or mislabeled. We moved to span categorization, which scores any span for any category independently, and relabeled the data to match.

  4. Recombination into Personalised Exercises – The extracted elements are combined into the next steps of the simulator. The user is asked about their belief, their fear, and the people in their situation, which makes the exercise personal.

  5. Serving – The models are served through a Flask API in Docker for the app on phone and computer.


Business Outcome

The app could guide users through its exercises using their own words, doing work that would otherwise need a human coach. After launch, the client reported 17% user growth. The models run in production in the app and were handed over to the client.

The project also showed a lesson that holds beyond psychology: when the elements you need to extract overlap, standard NER is the wrong tool, and span categorization fits the problem.

Technologies

NLPBERTNamed Entity RecognitionSpan CategorizationspaCyData LabelingFlaskDocker

Planning something similar?

Tell me about it on a short call. New projects can start within 2 weeks