Serega6678 commited on
Commit
b411d6a
·
1 Parent(s): b4748e4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +28 -1
README.md CHANGED
@@ -15,4 +15,31 @@ tags:
15
 
16
  The base version of [roberta-base](https://huggingface.co/roberta-base) finetunned on an artificially annotated subset of C4. This model provides domain-independent embedding for Entity Recognition Task. Embeddings can be used out of the box or fine-tuned on specific datasets.
17
 
18
- ## Usage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  The base version of [roberta-base](https://huggingface.co/roberta-base) finetunned on an artificially annotated subset of C4. This model provides domain-independent embedding for Entity Recognition Task. Embeddings can be used out of the box or fine-tuned on specific datasets.
17
 
18
+ ## Usage
19
+
20
+ ```python
21
+ import torch
22
+ import transformers
23
+
24
+
25
+ model = transformers.AutoModel.from_pretrained(
26
+ 'numind/entity-recognition-general-sota-v1',
27
+ output_hidden_states=True
28
+ )
29
+ tokenizer = transformers.AutoTokenizer.from_pretrained(
30
+ 'numind/entity-recognition-general-sota-v1'
31
+ )
32
+
33
+ text = "NuMind is an AI company based in Paris and USA."
34
+ encoded_input = tokenizer(text, return_tensors='pt')
35
+ output = model(**encoded_input)
36
+
37
+ # for better quality
38
+ emb = torch.cat(
39
+ (output.hidden_states[-1], output.hidden_states[-7]),
40
+ dim=2
41
+ )
42
+
43
+ # for better speed
44
+ # emb = output.hidden_states[-1]
45
+ ```