mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-10 16:22:29 +03:00
Update embeddings-transformers.mdx, update trf_data examples info in <Runtime usage> (#13811)
This commit is contained in:
parent
98a19df91a
commit
aa8de0ed37
|
@ -268,7 +268,12 @@ require_gpu(0)
|
||||||
|
|
||||||
nlp = spacy.load("en_core_web_trf")
|
nlp = spacy.load("en_core_web_trf")
|
||||||
for doc in nlp.pipe(["some text", "some other text"]):
|
for doc in nlp.pipe(["some text", "some other text"]):
|
||||||
tokvecs = doc._.trf_data.tensors[-1]
|
# For spaCy v3.0-v3.6, trf pipelines use spacy-transformers and the transformer output in doc._.trf_data is a TransformerData object.
|
||||||
|
try:
|
||||||
|
tokvecs = doc._.trf_data.tensors[-1]
|
||||||
|
# For spaCy v3.7+, trf pipelines use spacy-curated-transformers and doc._.trf_data is a DocTransformerOutput object.
|
||||||
|
except AttributeError as e:
|
||||||
|
tokvecs = doc._.trf_data.last_hidden_layer_state # or doc._.trf_data.all_outputs[-1]
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also customize how the [`Transformer`](/api/transformer) component sets
|
You can also customize how the [`Transformer`](/api/transformer) component sets
|
||||||
|
|
Loading…
Reference in New Issue
Block a user