spacy-transformers | 🛸 Use pretrained transformers like BERT , XLNet and GPT-2 | Natural Language Processing library
kandi X-RAY | spacy-transformers Summary
kandi X-RAY | spacy-transformers Summary
🛸 Use pretrained transformers like BERT, XLNet and GPT-2 in spaCy
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Create a TransformerV3vec model
- Convert tensors to arrays
- Forward transformer computation
- Calculate the alignment of tokens
- Verify inputs are correct
- Transpose a list
- Reads the configuration from a byte string
- Create a temporary directory
- Convert the model to a bytes object
- Create a TransformerV2vec model
- Creates a model for the transformer
- Transformer for Transformer
- Find listeners for this component
- Adds a listener to the model
- Replace listener configuration with listener cfg
- Deserialize Transformer data
spacy-transformers Key Features
spacy-transformers Examples and Code Snippets
pipeline:
- name: HFTransformersNLP
model_name: "bert"
model_weights: "PATH_TO_YOUR_FINETUNED_MODEL_DIRECTORY"
cache_dir: "PATH_TO_SOME_CACHE_FOLDER"
- name: LanguageModelFeaturizer
- name: DIETClassifier
random_seed: 42
intent_clas
[components.transformer.model]
@architectures = "ginza-transformers.TransformerModel.v1"
name = "megagonlabs/transformers-ud-japanese-electra-base-discriminator"
[components.transformer.model.tokenizer_config]
use_fast = false
tokenizer_class = "sud
[components.transformer]
factory = "transformer_custom"
[components.transformer.model]
name = "megagonlabs/transformers-ud-japanese-electra-base-ginza"
Community Discussions
Trending Discussions on spacy-transformers
QUESTION
I have created a spacy transformer model for named entity recognition. Last time I trained till it reached 90% accuracy and I also have a model-best
directory from where I can load my trained model for predictions. But now I have some more data samples and I wish to resume training this spacy transformer. I saw that we can do it by changing the config.cfg
but clueless about 'what to change?'
This is my config.cfg
after running python -m spacy init fill-config ./base_config.cfg ./config.cfg
:
ANSWER
Answered 2022-Jan-20 at 07:21The vectors setting is not related to the transformer
or what you're trying to do.
In the new config, you want to use the source
option to load the components from the existing pipeline. You would modify the [component]
blocks to contain only the source
setting and no other settings:
QUESTION
I use the following commands (from spacy website here) to install spacy and en_core_web_trf under Windows 10 home 64 bit, however, I have encountered problems while running the last (third line) command.
...ANSWER
Answered 2022-Jan-15 at 21:24try:
pip uninstall spacy-transformers 1.1.4
pip uninstall spacy-transformers 1.1.3
pip uninstall spacy-transformers 1.1.2
then execute:
QUESTION
I'm trying to build a SpaCy pipeline using multiple components. My current pipeline only has two components at the moment, one entity ruler, and another custom component.
The way I build it is like this:
...ANSWER
Answered 2021-Dec-21 at 10:15At the place where you load the model, you need to have access to the code that defined the custom component. So if your file that defines the custom component is custom.py
, you can put import custom
at the top of the file where you're loading your pipeline and it should work.
Also see the docs on saving and loading custom components.
QUESTION
I'm here to ask you guys if it is possible to use an existing trained huggingface-transformers model with spacy.
My first naive attempt was to load it via spacy.load('bert-base-uncased')
, it didn't work because spacy demands a certain structure, which is understandable.
Now I'm trying to figure out how to use the spacy-transformers
library to load the model, create the spacy structure, and use it from that point as a normal spacy-aware model.
I don't know if it is even possible as I couldn't find anything regarding the subject. I've tried to read the documentation but all guides, examples, and posts I found, start from a spacy structured model like spacy/en_core_web_sm, but how did that model was created in the first place? I can believe someone has to train everything again with spacy.
Can I get some help from you?
Thanks.
...ANSWER
Answered 2021-Oct-29 at 03:58What you do is add a Transformer component to your pipeline and give the name of your HuggingFace model as a parameter to that. This is covered in the docs, though people do have trouble finding it. It's important to understand that a Transformer is only one piece of a spaCy pipeline, and you should understand how it all fits together.
To pull from the docs, this is how you specify a custom model in a config:
QUESTION
I was trying to create a custom NER model. I used spacy library to create the model. And this line of code is to create the config file from the base.config
file.
My code is :
ANSWER
Answered 2021-Oct-24 at 10:22This happened since spacy had a new update 3.1 recently. And the base_config file have the architecture mentioned as "spacy-transformers.TransformerModel.v3". Change it into "spacy-transformers.TransformerModel.v1"
QUESTION
As the self guide says, I've installed it with (conda environment)
...ANSWER
Answered 2021-Oct-01 at 23:49Are you sure you did install spacy-transformers? After installing spacy?
I am using pip: pip install spacy-transformers and I have no problems loading the en_core_web_trf.
QUESTION
I'm using Spacy-Transformers to build some NLP models.
The Spacy-Transformers docs say:
spacy-transformers
spaCy pipelines for pretrained BERT, XLNet and GPT-2
The sample code on that page shows:
...ANSWER
Answered 2021-Aug-28 at 05:16The en_core_web_trf
uses a specific Transformers model, but you can specify arbitrary ones using the TransformerModel
wrapper class from spacy-transformers
. See the docs for that. An example config:
QUESTION
Following the official instruction, I'm trying to add an extra training dataset and train a model on local cpu environment.
But I don't change the content of base_config.cfg and config.cfg files.
How can I fix these errors to build a model and evaluate it?
ErrorI'm not sure about the first one is an issue or not, and I have no idea to fill the config.cfg file.
The config.cfg file was an empty even after executing the code on the below procedure so far section.
The error message was shown when executing train command.
ANSWER
Answered 2021-Jul-23 at 08:19It looks like you double-pasted the config or something? From the errors you'll note that it says you have two [paths]
sections. About halfway through your file there's a comment like this:
QUESTION
I'm a Spacy's new user and I'm trying to run this ner_demo_update project and I got this error : catalogue.RegistryError: [E893] Could not find function 'spacy.copy_from_base_model.v1' in function registry 'callbacks'. If you're using a custom function, make sure the code is available. If the function is provided by a third-party package, e.g. spacy-transformers, make sure the package is installed in your environment. I'll like to know if someone has face the same issue.
...ANSWER
Answered 2021-May-03 at 17:08copy_from_base_model.v1
is a new function, introduced in spaCy v3.0.6. Are you perhaps running an older version of spaCy? If so, can you try updating it? This will likely resolve your error.
See also: https://github.com/explosion/spaCy/discussions/7985
QUESTION
I'm trying to use the spacy_langdetect package and the only example code I can find is (https://spacy.io/universe/project/spacy-langdetect):
...ANSWER
Answered 2021-Mar-20 at 23:11With spaCy v3.0 for components not built-in such as LanguageDetector, you will have to wrap it into a function prior to adding it to the nlp pipe. In your example, you can do the following:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install spacy-transformers
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page