Skip to content

Commit

Permalink
Allow span_marker spaCy component without importing
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaarsen committed Jun 19, 2023
1 parent 012363e commit 4057860
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Types of changes

### Added

- Added support for using `span_marker` spaCy pipeline component without importing SpanMarker.
- Added support for `load_in_8bit=True` and `device_map="auto"`.

## [1.2.0]
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ These trained models have Hosted Inference API widgets that you can use to exper
All [SpanMarker models on the Hugging Face Hub](https://huggingface.co/models?library=span-marker) can also be easily used in spaCy. It's as simple as including 1 line to add the `span_marker` pipeline. See the Documentation or API Reference for more information.
```python
import spacy
import span_marker

# Load the spaCy model with the span_marker pipeline component
nlp = spacy.load("en_core_web_sm")
Expand Down
7 changes: 2 additions & 5 deletions notebooks/spacy_integration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"outputs": [],
"source": [
"%pip install span_marker spacy\n",
"%spacy download en_core_web_sm"
"!spacy download en_core_web_sm"
]
},
{
Expand Down Expand Up @@ -170,7 +170,7 @@
"metadata": {},
"source": [
"### Using SpanMarker models for Named Entity Recognition with spaCy\n",
"We can easily add a SpanMarker model as a drop-in replacement of the original spaCy NER pipeline. It's as simple as two lines of code."
"We can easily add a SpanMarker model as a drop-in replacement of the original spaCy NER pipeline. It's as simple as one line of code."
]
},
{
Expand All @@ -179,8 +179,6 @@
"metadata": {},
"outputs": [],
"source": [
"import span_marker\n",
"\n",
"nlp.add_pipe(\"span_marker\", config={\"model\": \"tomaarsen/span-marker-roberta-large-ontonotes5\"})"
]
},
Expand Down Expand Up @@ -369,7 +367,6 @@
],
"source": [
"import spacy\n",
"import span_marker\n",
"\n",
"nlp = spacy.load(\"en_core_web_sm\")\n",
"nlp.add_pipe(\"span_marker\")\n",
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,8 @@ exclude = [

[tool.black]
line-length = 120

[tool.poetry.plugins]

[tool.poetry.plugins."spacy_factories"]
"spacy" = "span_marker.__init__:_spacy_span_marker_factory"

0 comments on commit 4057860

Please sign in to comment.