Instructions to use sayef/fsner-bert-base-uncased with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sayef/fsner-bert-base-uncased with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="sayef/fsner-bert-base-uncased")# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("sayef/fsner-bert-base-uncased") model = AutoModel.from_pretrained("sayef/fsner-bert-base-uncased") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -24,14 +24,8 @@ The FSNER model was proposed in [Example-Based Named Entity Recognition](https:/
|
|
| 24 |
|
| 25 |
## Installation and Example Usage
|
| 26 |
------
|
| 27 |
-
You need to clone `transformers` repository and go to this directory: `transformers/examples/research_projects/fsner`. Then, you will be able to use the FSNER model in two ways:
|
| 28 |
-
|
| 29 |
-
1. Install as a package: `python setup.py install` and import the model as shown in the code example below
|
| 30 |
-
|
| 31 |
-
or
|
| 32 |
-
|
| 33 |
-
2. Change directory to `src` and import the model as shown in the code example below
|
| 34 |
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
```python
|
|
@@ -41,8 +35,7 @@ model = FSNERModel("sayef/fsner-bert-base-uncased")
|
|
| 41 |
|
| 42 |
tokenizer = FSNERTokenizerUtils("sayef/fsner-bert-base-uncased")
|
| 43 |
|
| 44 |
-
# size of query and supports must be the same.
|
| 45 |
-
|
| 46 |
|
| 47 |
query = [
|
| 48 |
'KWE 4000 can reach with a maximum speed from up to 450 P/min an accuracy from 50 mg',
|
|
@@ -72,7 +65,7 @@ supports = [
|
|
| 72 |
device = 'cpu'
|
| 73 |
|
| 74 |
W_query = tokenizer.tokenize(query).to(device)
|
| 75 |
-
W_supports = tokenizer.tokenize(
|
| 76 |
|
| 77 |
start_prob, end_prob = model(W_query, W_supports)
|
| 78 |
|
|
|
|
| 24 |
|
| 25 |
## Installation and Example Usage
|
| 26 |
------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
- Installation: `pip install fsner`
|
| 29 |
|
| 30 |
|
| 31 |
```python
|
|
|
|
| 35 |
|
| 36 |
tokenizer = FSNERTokenizerUtils("sayef/fsner-bert-base-uncased")
|
| 37 |
|
| 38 |
+
# size of query and supports must be the same. Each query corresponds to the same index of supports.
|
|
|
|
| 39 |
|
| 40 |
query = [
|
| 41 |
'KWE 4000 can reach with a maximum speed from up to 450 P/min an accuracy from 50 mg',
|
|
|
|
| 65 |
device = 'cpu'
|
| 66 |
|
| 67 |
W_query = tokenizer.tokenize(query).to(device)
|
| 68 |
+
W_supports = tokenizer.tokenize(supports).to(device)
|
| 69 |
|
| 70 |
start_prob, end_prob = model(W_query, W_supports)
|
| 71 |
|