Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom model for NER #36

Closed
espoirMur opened this issue Jun 6, 2022 · 6 comments · Fixed by #75
Closed

Custom model for NER #36

espoirMur opened this issue Jun 6, 2022 · 6 comments · Fixed by #75
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@espoirMur
Copy link

Hello thanks you for setting up this ..

The examples are amazing.

Is it possible to use this wrapper with a Named Entity Recognition model?

If that is the case, is it possible to add an example with a NER model from hugging face?

Following the example, I am trying to add this but it is not working, I do not why may be I should go back and learn how spacy works.

import spacy
import spacy_wrap

nlp = spacy.blank("fr")

config = {
    "model": {
        "@architectures": "spacy-transformers.TransformerModel.v3",
        "name": "Jean-Baptiste/camembert-ner-with-dates",
        "tokenizer_config" : {"use_fast": False},
        "get_spans":  {"@span_getters": "spacy-transformers.doc_spans.v1"}
    }
}

transformer = nlp.add_pipe("ner", config=config)
@espoirMur espoirMur added the enhancement New feature or request label Jun 6, 2022
@KennethEnevoldsen KennethEnevoldsen changed the title Help with an example to use custom model for NER Custom model for NER Jun 7, 2022
@KennethEnevoldsen KennethEnevoldsen added the good first issue Good for newcomers label Jun 7, 2022
@KennethEnevoldsen
Copy link
Owner

Hi @espoirMur, it seems like the model architecture you are using uses the spacy-transformers.TransformerModel.v3 which is from spacy-transformers. If you want to use spacy-wrap you need to use the classification-transformer, however that currently only support classification models.

It is however a plan to add NER model to this library as well, I would welcome a PR on this.

@LisaHoek
Copy link

Hi @espoirMur @KennethEnevoldsen, I was wondering, is anybody currently implementing this? It would be nice to have this in the near future, so I am curious whether I should get my hands dirty or whether I can expect this NER model anytime soon?

@KennethEnevoldsen
Copy link
Owner

Hi, @LisaHoek. Sorry for the late response was on holiday. I am currently not working on this feature, but I would very much welcome a pull request on the feature, and I would also help if solving any problems or kinks you might discover while tackling the problem.

@KennethEnevoldsen
Copy link
Owner

Hi @LisaHoek and @espoirMur, space-wrap now support NER and token classification as well 🍾

@espoirMur
Copy link
Author

Thank you @KennethEnevoldsen 💪🏻

@KennethEnevoldsen
Copy link
Owner

There are still a few edge cases where performance is not 1-1 (see #74), but that is mostly due to the spacy tokenizer (and I have only seen it for one case).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
3 participants