https://github.com/bmi-labmedinfo/bat
Package for Biomedical Textual data Augmentation
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.8%) to scientific vocabulary
Repository
Package for Biomedical Textual data Augmentation
Basic Info
- Host: GitHub
- Owner: bmi-labmedinfo
- License: mit
- Language: Python
- Default Branch: main
- Size: 88.9 KB
Statistics
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
BAT - Biomedical Augmentation for Text 
Keywords: Data augmentation, Neuro-Symbolic AI, NLP, LLM, UMLS
A Toolkit for Biomedical Text Augmentation
Package Overview
This Python package consists of a Neuro-Symbolic pipeline, blending knowledge-driven and data-driven approaches.
Pipeline Components
Knowledge-Based perturbation (knowledge-driven):
* Med-synonym replacement: Replaces medical terms with one of their formalized synonyms from structured domain knowledge (UMLS Metathesaurus).
* General synonym replacement: Replaces terms with one of their general-purpose synonyms from Wordnet.
Transformer-Based perturbation (data-driven):
* Back-translation: Translates text into an intermediate language and then back into the original language using multilingual MT models.
* Contextual word prediction: Fills in masked single-token words within the input text based on the in-context predictions from BERT-based language models.
* Rephrasing: Rewrites text using the capabilities of LLMs.
Requirements
- Unified Medical Language System (UMLS) License:
- Mandatory for using the
Med-synonym replacementcomponent. - Optional for the
General synonym replacement. - LLM Functional Block:
- A functional block with any preferred (open source or proprietary) LLM must be configured to use the
Rephrasingcomponent. - Alternatively, you can use the default gpt-4o-mini model by providing your personal API key.
Installation
- Make sure you have the latest version of pip installed
sh pip install --upgrade pip - Install
BiomedicalAugmentation-for-Textthrough pipsh pip install --index-url https://test.pypi.org/simple/ --no-deps BiomedicalAugmentation-for-Text
Usage
Here is a minimal example of how the BAT package can be invoked with BiomedicalAugmentation-for-Text.
1. Through the AugmentedSample class: A compact and streamlined interface that integrates all components into a cohesive workflow.
```python
from bioTextAugPackage.init import *
import bioTextAugPackage.augmentedsample as augsample
config = Config() inputtext = "No lytic lesions are observed at the vertebral levels included in the scans. No signs of listhesis." augmentedsample = augsample.AugmentedSample(configparams=config, techniquetag="TB-backtranslation", srcdata=inputtext, srclang="english", nsynthdata=5) ans = augmentedsample.run() ```
- By invoking individual functions: Provides more control and flexibility to apply specific components independently. ```python from bioTextAugPackage.init import * import bioTextAugPackage.transformerbasedfunctions as tb import bioTextAugPackage.metrics as metrics
config = Config() input_text = "No lytic lesions are observed at the vertebral levels included in the scans. No signs of listhesis."
srclang = "en" trglang = "fr"
mtmodelname1 = f"Helsinki-NLP/opus-mt-{srclang}-{trglang}" mtmodel1 = AutoModelForSeq2SeqLM.frompretrained(mtmodelname1) mttokenizer1 = AutoTokenizer.frompretrained(mtmodelname1)
mtmodelname2 = f"Helsinki-NLP/opus-mt-{trglang}-{srclang}" mtmodel2 = AutoModelForSeq2SeqLM.frompretrained(mtmodelname2) mttokenizer2 = AutoTokenizer.frompretrained(mtmodelname2, cleanuptokenization_spaces=True)
ans = tb.backtranslation(srctext=inputtext, model1=mtmodel1, tokenizer1=mttokenizer1, model2=mtmodel2, tokenizer2=mt_tokenizer2)
print(ans) overlapscore = metrics.computeoverlap(syntheticdata=ans[0], srcdata=inputtext, tokenizer=config.basetokenizer) similarityscore = metrics.computesimilarity(syntheticdata=ans[0], srcdata=inputtext, semodelname=config.semodelname) print(f"overlapscore: {overlapscore} - similarityscore: {similarity_score}") ```
A more extensive example, including advanced usage, can be found in this notebook.
Contacts and Useful Links
Project Link: https://github.com/bmi-labmedinfo/BAT
Package Link: https://test.pypi.org/project/BiomedicalAugmentation-for-Text/
License
Distributed under MIT License. See LICENSE
Owner
- Name: BMI "Mario Stefanelli" Lab - UNIPV
- Login: bmi-labmedinfo
- Kind: organization
- Email: labmedinfo@unipv.it
- Location: Italy
- Website: http://www.labmedinfo.org
- Repositories: 1
- Profile: https://github.com/bmi-labmedinfo
Repository for BMI lab code and sw products
GitHub Events
Total
- Push event: 1
Last Year
- Push event: 1
Dependencies
- Babel ==2.15.0
- Jinja2 ==3.1.3
- Keras-Preprocessing ==1.1.2
- Markdown ==3.7
- MarkupSafe ==2.1.5
- PyYAML ==6.0.1
- Pygments ==2.17.2
- QtPy ==2.4.1
- Send2Trash ==1.8.3
- Werkzeug ==3.0.4
- XlsxWriter ==3.2.0
- absl-py ==0.15.0
- accelerate ==0.28.0
- aiofiles ==23.2.1
- aiohttp ==3.9.5
- aiosignal ==1.3.1
- annotated-types ==0.7.0
- anyio ==4.4.0
- appnope ==0.1.4
- argon2-cffi ==23.1.0
- argon2-cffi-bindings ==21.2.0
- arrow ==1.3.0
- asttokens ==2.4.1
- astunparse ==1.6.3
- async-lru ==2.0.4
- async-timeout ==4.0.3
- attrs ==23.2.0
- backcall ==0.2.0
- beautifulsoup4 ==4.12.3
- bert-score ==0.3.13
- bleach ==6.1.0
- cachetools ==4.2.4
- certifi ==2024.6.2
- cffi ==1.16.0
- charset-normalizer ==3.3.2
- clang ==5.0
- click ==8.1.7
- cloudpickle ==3.0.0
- cmake ==3.29.0.1
- comm ==0.2.2
- config ==0.5.1
- contourpy ==1.1.1
- cycler ==0.12.1
- debugpy ==1.8.1
- decorator ==5.1.1
- defusedxml ==0.7.1
- distro ==1.9.0
- et-xmlfile ==1.1.0
- exceptiongroup ==1.2.1
- executing ==2.0.1
- fastapi ==0.112.2
- fastjsonschema ==2.19.1
- ffmpy ==0.3.2
- filelock ==3.13.3
- flatbuffers ==1.12
- fonttools ==4.50.0
- fqdn ==1.5.1
- frozenlist ==1.4.1
- fsspec ==2024.3.1
- gast ==0.4.0
- google-auth ==1.35.0
- google-auth-oauthlib ==0.4.6
- google-pasta ==0.2.0
- gradio ==4.42.0
- gradio_client ==1.3.0
- grpcio ==1.66.1
- h11 ==0.14.0
- h5py ==3.1.0
- httpcore ==1.0.5
- httpx ==0.27.0
- huggingface-hub ==0.23.3
- idna ==3.6
- importlib_metadata ==7.1.0
- importlib_resources ==6.4.0
- install ==1.3.5
- ipdb ==0.13.13
- ipykernel ==6.29.4
- ipython ==8.12.3
- ipywidgets ==8.1.3
- isoduration ==20.11.0
- jedi ==0.19.1
- jiter ==0.5.0
- joblib ==1.3.2
- json5 ==0.9.25
- jsonpointer ==3.0.0
- jsonschema ==4.22.0
- jsonschema-specifications ==2023.12.1
- jupyter ==1.0.0
- jupyter-console ==6.6.3
- jupyter-events ==0.10.0
- jupyter-lsp ==2.2.5
- jupyter_client ==8.6.2
- jupyter_core ==5.7.2
- jupyter_server ==2.14.1
- jupyter_server_terminals ==0.5.3
- jupyterlab ==4.2.2
- jupyterlab_pygments ==0.3.0
- jupyterlab_server ==2.27.2
- jupyterlab_widgets ==3.0.11
- keras ==2.6.0
- kiwisolver ==1.4.5
- llvmlite ==0.41.1
- marisa-trie ==1.1.0
- markdown-it-py ==3.0.0
- matplotlib ==3.7.5
- matplotlib-inline ==0.1.6
- mdurl ==0.1.2
- mistune ==3.0.2
- mpmath ==1.3.0
- multidict ==6.0.5
- nbclient ==0.10.0
- nbconvert ==7.16.4
- nbformat ==5.10.4
- nest-asyncio ==1.6.0
- networkx ==3.1
- nltk ==3.8.1
- notebook ==7.2.1
- notebook_shim ==0.2.4
- numba ==0.58.1
- numpy ==1.24.4
- oauthlib ==3.2.2
- openai ==1.42.0
- openpyxl ==3.1.5
- opt-einsum ==3.3.0
- orjson ==3.10.7
- overrides ==7.7.0
- packaging ==24.0
- pandas ==2.0.3
- pandocfilters ==1.5.1
- parso ==0.8.3
- pexpect ==4.9.0
- pickleshare ==0.7.5
- pillow ==10.3.0
- pkgutil_resolve_name ==1.3.10
- platformdirs ==4.2.2
- prometheus_client ==0.20.0
- prompt-toolkit ==3.0.43
- protobuf ==3.19.6
- psutil ==5.9.8
- ptyprocess ==0.7.0
- pure-eval ==0.2.2
- pyarrow ==9.0.0
- pyasn1 ==0.6.0
- pyasn1_modules ==0.4.0
- pycparser ==2.22
- pydantic ==2.8.2
- pydantic_core ==2.20.1
- pydub ==0.25.1
- pyparsing ==3.1.2
- python-dateutil ==2.9.0.post0
- python-dotenv ==1.0.1
- python-json-logger ==2.0.7
- python-multipart ==0.0.9
- pytz ==2024.1
- pyzmq ==26.0.3
- qtconsole ==5.5.2
- referencing ==0.35.1
- regex ==2023.12.25
- requests ==2.31.0
- requests-oauthlib ==2.0.0
- rfc3339-validator ==0.1.4
- rfc3986-validator ==0.1.1
- rich ==13.8.0
- rouge ==1.0.1
- rpds-py ==0.18.1
- rsa ==4.9
- ruff ==0.6.3
- sacremoses ==0.1.1
- safetensors ==0.4.2
- scikit-learn ==1.3.2
- scipy ==1.10.1
- seaborn ==0.13.2
- semantic-version ==2.10.0
- sentencepiece ==0.1.96
- shap ==0.44.1
- shellingham ==1.5.4
- six ==1.15.0
- slicer ==0.0.7
- sniffio ==1.3.1
- soupsieve ==2.5
- stack-data ==0.6.3
- starlette ==0.38.4
- sympy ==1.12
- tensorboard ==2.6.0
- tensorboard-data-server ==0.6.1
- tensorboard-plugin-wit ==1.8.1
- tensorflow-estimator ==2.6.0
- termcolor ==1.1.0
- terminado ==0.18.1
- threadpoolctl ==3.4.0
- tiktoken ==0.7.0
- tinycss2 ==1.3.0
- tokenizers ==0.19.1
- tomli ==2.0.1
- tomlkit ==0.12.0
- torch ==2.2.2
- tornado ==6.4.1
- tqdm ==4.66.2
- traitlets ==5.14.2
- transformers ==4.44.2
- typer ==0.12.5
- types-python-dateutil ==2.9.0.20240316
- typing ==3.7.4.3
- typing_extensions ==4.12.2
- tzdata ==2024.1
- uri-template ==1.3.0
- urllib3 ==2.2.1
- uvicorn ==0.30.6
- wcwidth ==0.2.13
- webcolors ==24.6.0
- webencodings ==0.5.1
- websocket-client ==1.8.0
- websockets ==12.0
- widgetsnbextension ==4.0.11
- wrapt ==1.12.1
- yarl ==1.9.4
- zipp ==3.18.1