# scispaCy

> spaCy models for biomedical and clinical text

- Category: Science & Biomedical AI / Clinical & Biomedical NLP
- Language: Python
- Repository: https://github.com/allenai/scispacy
- Website: https://allenai.github.io/scispacy/
- Canonical page: https://ai-tldr.dev/tools/scispacy/

## In short

scispaCy is a Python package containing spaCy models for processing biomedical, scientific, or clinical text. It sits in the Clinical & Biomedical NLP category of the Science & Biomedical AI tools and is open-source, written in Python. To get started: install scispaCy.

## Overview

scispaCy is a Python package containing spaCy models for processing biomedical, scientific, or clinical text. It is developed by the Allen Institute for AI and gives you full spaCy pipelines trained on scientific and biomedical data, so you can run tokenization, part-of-speech tagging, parsing, and named entity recognition on documents that general-purpose models struggle with.

The package ships several models. There are full pipeline models (en_core_sci_sm, en_core_sci_md, en_core_sci_lg, and en_core_sci_scibert) that differ in vocabulary size and word vectors, along with named entity recognition models (en_ner_craft_md, en_ner_jnlpba_md, en_ner_bc5cdr_md, and en_ner_bionlp13cg_md) trained on specific biomedical entity sets.

Beyond the base pipelines, scispaCy adds components you can insert into a spaCy pipeline: an abbreviation detector, an entity linker that maps mentions to biomedical knowledge bases, and a hyponym detector. Because it is built on spaCy, it fits into existing spaCy code and workflows.

## What it does

- Custom tokenizer with biomedical-specific rules for scientific and clinical text
- Part-of-speech tagger and syntactic parser trained on biomedical data
- Named entity recognition models trained on specific entity sets (CRAFT, JNLPBA, BC5CDR, BioNLP13CG)
- AbbreviationDetector component that finds abbreviations and their long forms using the Schwartz & Hearst (2003) algorithm
- EntityLinker component that links mentions to knowledge bases including UMLS, MeSH, RxNorm, Gene Ontology, and Human Phenotype Ontology
- HyponymDetector component that extracts hyponymy relations using Hearst patterns

## Getting started

Install the scispaCy package and a model, then load the model with spaCy and process biomedical text.

1. Install scispaCy

   Install the base package with pip.

```bash
pip install scispacy
```

2. Install a model

   Install a model from its release URL. Each model is distributed as a wheel or archive hosted by the project.

```bash
pip install https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.5.4/en_core_sci_sm-0.5.4.tar.gz
```

3. Load the model and process text

   Load the installed model with spaCy and run it over a biomedical document.

```python
import spacy

nlp = spacy.load("en_core_sci_sm")
doc = nlp("Alterations in the hypocretin receptor 2 and preprohypocretin genes produce narcolepsy in some animals.")
print(list(doc.ents))
```

## When to use it

- Extract biomedical entities such as chemicals, diseases, genes, and proteins from research papers or clinical notes
- Expand abbreviations in scientific or clinical text to their long forms for cleaner downstream processing
- Link entity mentions to biomedical knowledge bases like UMLS, MeSH, or RxNorm for normalization
- Tokenize and parse biomedical documents with a pipeline tuned for scientific rather than general-purpose text
