Update README.md
Browse files
README.md
CHANGED
|
@@ -49,6 +49,21 @@ pip install git+https://github.com/urchade/GLiNER.git
|
|
| 49 |
---
|
| 50 |
|
| 51 |
## Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
```python
|
| 54 |
from gliner import GLiNER
|
|
@@ -61,7 +76,7 @@ text = (
|
|
| 61 |
"develop and sell Wozniak's Apple I personal computer."
|
| 62 |
)
|
| 63 |
|
| 64 |
-
labels = ["person", "
|
| 65 |
|
| 66 |
model.run([text], labels, threshold=0.3, num_gen_sequences=1)
|
| 67 |
```
|
|
@@ -70,6 +85,57 @@ model.run([text], labels, threshold=0.3, num_gen_sequences=1)
|
|
| 70 |
|
| 71 |
### Example Output
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
```json
|
| 74 |
[
|
| 75 |
[
|
|
|
|
| 49 |
---
|
| 50 |
|
| 51 |
## Usage
|
| 52 |
+
If you need an open ontology entity extraction use tag `label` in the list of labels, please check example below:
|
| 53 |
+
|
| 54 |
+
```python
|
| 55 |
+
from gliner import GLiNER
|
| 56 |
+
|
| 57 |
+
model = GLiNER.from_pretrained("knowledgator/gliner-decoder-large-v1.0")
|
| 58 |
+
|
| 59 |
+
text = "Hugging Face is a company that advances and democratizes artificial intelligence through open source and science."
|
| 60 |
+
|
| 61 |
+
labels = ["label"]
|
| 62 |
+
|
| 63 |
+
model.predict_entities(text, labels, threshold=0.3, num_gen_sequences=1)
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
If you need to run a model on many text and/or set some labels constraints, please check example below:
|
| 67 |
|
| 68 |
```python
|
| 69 |
from gliner import GLiNER
|
|
|
|
| 76 |
"develop and sell Wozniak's Apple I personal computer."
|
| 77 |
)
|
| 78 |
|
| 79 |
+
labels = ["person", "company", "date"]
|
| 80 |
|
| 81 |
model.run([text], labels, threshold=0.3, num_gen_sequences=1)
|
| 82 |
```
|
|
|
|
| 85 |
|
| 86 |
### Example Output
|
| 87 |
|
| 88 |
+
```json
|
| 89 |
+
[
|
| 90 |
+
[
|
| 91 |
+
{
|
| 92 |
+
"start": 21,
|
| 93 |
+
"end": 26,
|
| 94 |
+
"text": "Apple",
|
| 95 |
+
"label": "company",
|
| 96 |
+
"score": 0.6795641779899597,
|
| 97 |
+
"generated labels": ["Organization"]
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
"start": 47,
|
| 101 |
+
"end": 60,
|
| 102 |
+
"text": "April 1, 1976",
|
| 103 |
+
"label": "date",
|
| 104 |
+
"score": 0.44296327233314514,
|
| 105 |
+
"generated labels": ["Date"]
|
| 106 |
+
},
|
| 107 |
+
{
|
| 108 |
+
"start": 65,
|
| 109 |
+
"end": 78,
|
| 110 |
+
"text": "Steve Wozniak",
|
| 111 |
+
"label": "person",
|
| 112 |
+
"score": 0.9934439659118652,
|
| 113 |
+
"generated labels": ["Person"]
|
| 114 |
+
},
|
| 115 |
+
{
|
| 116 |
+
"start": 80,
|
| 117 |
+
"end": 90,
|
| 118 |
+
"text": "Steve Jobs",
|
| 119 |
+
"label": "person",
|
| 120 |
+
"score": 0.9725918769836426,
|
| 121 |
+
"generated labels": ["Person"]
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"start": 107,
|
| 125 |
+
"end": 119,
|
| 126 |
+
"text": "Ronald Wayne",
|
| 127 |
+
"label": "person",
|
| 128 |
+
"score": 0.9964536428451538,
|
| 129 |
+
"generated labels": ["Person"]
|
| 130 |
+
}
|
| 131 |
+
]
|
| 132 |
+
]
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
---
|
| 136 |
+
|
| 137 |
+
### Example Output
|
| 138 |
+
|
| 139 |
```json
|
| 140 |
[
|
| 141 |
[
|