bert-deid
Code to fine-tune BERT on a medical note de-identification task.
Install
- (Recommended) Create an environment called
deidconda env create -f environment.yml
- pip install locally
pip install bert-deid
Download
To download the model, we have provided a helper script in bert-deid:
# note: MODEL_DIR environment variable used by download
# by default, we download to bert_deid_model in the current directory
export MODEL_DIR="bert_deid_model"
bert_deid download
Usage
The model can be imported and used directly within Python.
from bert_deid.model import Transformer
# load in a trained model
model_path = 'bert_deid_model'
deid_model = Transformer(model_path)
with open('tests/example_note.txt', 'r') as fp:
text = ''.join(fp.readlines())
print(deid_model.apply(text, repl='___'))
# we can also get the original predictions
preds = deid_model.predict(text)
# print out the identified entities
for p, pred in enumerate(preds):
prob = pred[0]
label = pred[1]
start, stop = pred[2:]
# print the prediction labels out
print(f'{text[start:stop]:15s} {label} ({prob:0.3f})')
Metadata
Release files for bert-deid 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bert_deid-0.2.3.tar.gz | 33.2 kB | Without provenance | Details for bert_deid-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bert_deid-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for bert_deid-0.2.3-py3-none-any.whl |
Total release size: 73.3 kB
Release files / bert_deid-0.2.3.tar.gz
| Download URL | bert_deid-0.2.3.tar.gz |
|---|---|
| Size | 33.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2e60fd8997f3dad81e1e50efe632e265a850fef0e19419cbaa4fff77d5ae7dc4
|
|
BLAKE2b-256 checksum How to use checksums |
34a1cef86527dbed07c88d7c2cdb0af8e398693a7f0a2e9edd9b918bad125e29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.7.9
|
Release files / bert_deid-0.2.3-py3-none-any.whl
| Download URL | bert_deid-0.2.3-py3-none-any.whl |
|---|---|
| Size | 40.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1b3d7c1d9ef5d22509d8886b6c597afcf5c8c0f6d51e89ccf71a2c451454f4f9
|
|
BLAKE2b-256 checksum How to use checksums |
cc372c2ce03a91887d6e418865ea15ca42b84b436030413df55dc3596c76435f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.7.9
|
Security for bert-deid 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.