fix t5 model initalization
Browse files
README.md
CHANGED
@@ -32,7 +32,10 @@ We recommend to use the model with transformers `ner` pipeline:
|
|
32 |
|
33 |
```python
|
34 |
from transformers import AutoTokenizer, T5PreTrainedModel, T5Config, T5EncoderModel
|
|
|
|
|
35 |
from transformers import pipeline
|
|
|
36 |
|
37 |
class T5EncoderForTokenClassification(T5PreTrainedModel):
|
38 |
_tied_weights_keys = ["encoder.embed_tokens.weight"]
|
@@ -155,7 +158,7 @@ def process(text, prompt, treshold=0.5):
|
|
155 |
|
156 |
return processed_results
|
157 |
|
158 |
-
tokenizer = AutoTokenizer.from_pretrained("knowledgator/UTC-
|
159 |
model = T5EncoderForTokenClassification.from_pretrained("knowledgator/UTC-T5-large")
|
160 |
|
161 |
nlp = pipeline("ner", model=model, tokenizer=tokenizer, aggregation_strategy = 'first')
|
|
|
32 |
|
33 |
```python
|
34 |
from transformers import AutoTokenizer, T5PreTrainedModel, T5Config, T5EncoderModel
|
35 |
+
from transformers.modeling_outputs import TokenClassifierOutput
|
36 |
+
from typing import Union, Optional, Tuple
|
37 |
from transformers import pipeline
|
38 |
+
import torch
|
39 |
|
40 |
class T5EncoderForTokenClassification(T5PreTrainedModel):
|
41 |
_tied_weights_keys = ["encoder.embed_tokens.weight"]
|
|
|
158 |
|
159 |
return processed_results
|
160 |
|
161 |
+
tokenizer = AutoTokenizer.from_pretrained("knowledgator/UTC-T5-large")
|
162 |
model = T5EncoderForTokenClassification.from_pretrained("knowledgator/UTC-T5-large")
|
163 |
|
164 |
nlp = pipeline("ner", model=model, tokenizer=tokenizer, aggregation_strategy = 'first')
|