/ Модель

Характеристики

Размер весов
452 МБ
Лицензия
BSD 3-Clause
Библиотека
edsnlp
Опубликована
16 июн 2024

eds-pseudo-public

Разметка токеновТекст → label3 профессии

Гибридная французская модель AP-HP находит идентифицирующие сведения в документах для их псевдонимизации или удаления.

946скачиваний за 30 дней20лайковвеса обновлены17 июн 2024

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

EDS-Pseudo — гибридная модель AP-HP на базе библиотеки edsnlp для обнаружения идентифицирующих сведений в документах. Публичная предварительно обученная версия обучена на синтетических данных; в README указано, что её преимущественно проверяли на клинических отчётах хранилища клинических данных AP-HP. Модель сочетает правила и глубокое обучение и размечает сущности для последующей псевдонимизации или редактирования документов.

Модель предназначена для извлечения персональных данных, включая адреса, даты и даты рождения; в карточке также заявлена медицинская направленность и французский язык. Для запуска используется edsnlp. Репозиторий содержит веса safetensors, лицензия — BSD 3-Clause. В README приведены высокие оценки точности и полноты для нескольких типов сущностей, однако тестирование на синтетических данных и клинических отчётах AP-HP не гарантирует такие же результаты на других типах документов и данных.

Сценарии применения

  • обнаружение адресов в клинических документах
  • извлечение дат и дат рождения из медицинских отчётов
  • поиск персональных данных перед псевдонимизацией документов
  • разметка идентифицирующих сущностей для редактирования текста

Ограничения

Публичная версия обучена на синтетических данных и преимущественно проверялась на клинических отчётах AP-HP, поэтому качество на иных типах документов может отличаться. В README метрики приведены лишь для части меток.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

EDS-Pseudo

This project aims at detecting identifying entities documents, and was primarily tested on clinical reports at AP-HP's Clinical Data Warehouse (EDS).

The model is built on top of edsnlp, and consists in a hybrid model (rule-based + deep learning) for which we provide rules (eds-pseudo/pipes) and a training recipe train.py.

We also provide some fictitious templates (templates.txt) and a script to generate a synthetic dataset generate_dataset.py.

The entities that are detected are listed below.

LabelDescription
ADRESSEStreet address, eg 33 boulevard de Picpus
DATEAny absolute date other than a birthdate
DATE_NAISSANCEBirthdate
HOPITALHospital name, eg Hôpital Rothschild
IPPInternal AP-HP identifier for patients, displayed as a number
MAILEmail address
NDAInternal AP-HP identifier for visits, displayed as a number
NOMAny last name (patients, doctors, third parties)
PRENOMAny first name (patients, doctors, etc)
SECUSocial security number
TELAny phone number
VILLEAny city
ZIPAny zip code

Downloading the public pre-trained model

The public pretrained model is available on the HuggingFace model hub at AP-HP/eds-pseudo-public and was trained on synthetic data (see generate_dataset.py). You can also test it directly on the demo.

  1. Install the latest version of edsnlp

    pip install "edsnlp[ml]" -U
    
  2. Get access to the model at AP-HP/eds-pseudo-public

  3. Create and copy a huggingface token with permission "READ" at https://huggingface.co/settings/tokens?new_token=true

  4. Register the token (only once) on your machine

    import huggingface_hub
    
    huggingface_hub.login(token=YOUR_TOKEN, new_session=False, add_to_git_credential=True)
    
  5. Load the model

    import edsnlp
    
    nlp = edsnlp.load("AP-HP/eds-pseudo-public", auto_update=True)
    doc = nlp(
        "En 2015, M. Charles-François-Bienvenu "
        "Myriel était évêque de Digne. C’était un vieillard "
        "d’environ soixante-quinze ans ; il occupait le "
        "siège de Digne depuis 2006."
    )
    
    for ent in doc.ents:
        print(ent, ent.label_, str(ent._.date))
    

To apply the model on many documents using one or more GPUs, refer to the documentation of edsnlp.

Metrics

AP-HP Pseudo Test Token ScoresPrecisionRecallF1RedactRedact Full
ADRESSE98.296.997.697.696.7
DATE9998.498.798.885.9
DATE_NAISSANCE97.596.997.299.399.4
IPP91.990.891.398.599.3
MAIL96.199.897.999.899.7
NDA92.183.587.687.497.2
NOM94.495.394.898.289.5
PRENOM93.596.6959993.2
SECU88.310093.8100100
TEL97.599.998.799.999.6
VILLE96.793.895.295.191.1
ZIP96.810098.3100100
micro9797.897.498.863.1

Installation to reproduce

If you'd like to reproduce eds-pseudo's training or contribute to its development, you should first clone it:

git clone https://github.com/aphp/eds-pseudo.git
cd eds-pseudo

And install the dependencies. We recommend pinning the library version in your projects, or use a strict package manager like Poetry.

poetry install

How to use without machine learning

import edsnlp

nlp = edsnlp.blank("eds")

# Some text cleaning
nlp.add_pipe("eds.normalizer")

# Various simple rules
nlp.add_pipe(
    "eds_pseudo.simple_rules",
    config={"pattern_keys": ["TEL", "MAIL", "SECU", "PERSON"]},
)

# Address detection
nlp.add_pipe("eds_pseudo.addresses")

# Date detection
nlp.add_pipe("eds_pseudo.dates")

# Contextual rules (requires a dict of info about the patient)
nlp.add_pipe("eds_pseudo.context")

# Apply it to a text
doc = nlp(
    "En 2015, M. Charles-François-Bienvenu "
    "Myriel était évêque de Digne. C’était un vieillard "
    "d’environ soixante-quinze ans ; il occupait le "
    "siège de Digne depuis 2006."
)

for ent in doc.ents:
    print(ent, ent.label_)

# 2015 DATE
# Charles-François-Bienvenu NOM
# Myriel PRENOM
# 2006 DATE

How to train

Before training a model, you should update the configs/config.cfg and pyproject.toml files to fit your needs.

Put your data in the data/dataset folder (or edit the paths configs/config.cfg file to point to data/gen_dataset/train.jsonl).

Then, run the training script

python scripts/train.py --config configs/config.cfg --seed 43

This will train a model and save it in artifacts/model-last. You can evaluate it on the test set (defaults to data/dataset/test.jsonl) with:

python scripts/evaluate.py --config configs/config.cfg

To package it, run:

python scripts/package.py

This will create a dist/eds-pseudo-aphp-***.whl file that you can install with pip install dist/eds-pseudo-aphp-***.

You can use it in your code:

import edsnlp

# Either from the model path directly
nlp = edsnlp.load("artifacts/model-last")

# Or from the wheel file
import eds_pseudo_aphp

nlp = eds_pseudo_aphp.load()

Documentation

Visit the documentation for more information!

Publication

Please find our publication at the following link: https://doi.org/mkfv.

If you use EDS-Pseudo, please cite us as below:

@article{eds_pseudo,
  title={Development and validation of a natural language processing algorithm to pseudonymize documents in the context of a clinical data warehouse},
  author={Tannier, Xavier and Wajsb{\"u}rt, Perceval and Calliger, Alice and Dura, Basile and Mouchet, Alexandre and Hilka, Martin and Bey, Romain},
  journal={Methods of Information in Medicine},
  year={2024},
  publisher={Georg Thieme Verlag KG}
}

Acknowledgement

We would like to thank Assistance Publique – Hôpitaux de Paris and AP-HP Foundation for funding this project.

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · edsnlp · token-classification

Нельзя запустить

В репозитории нет config.json: не понять архитектуру модели.

Ревизия весов
bbee3fe

0 моделей