explosion / spaCy

💫 Industrial-strength Natural Language Processing (NLP) in Python
https://spacy.io
MIT License
30.21k stars 4.4k forks source link

Tensorflow Wrapping #12834

Closed mhyeonsoo closed 1 year ago

mhyeonsoo commented 1 year ago

How to reproduce the behaviour

I trained my own custom spacy ner model with the code below.

import random
from spacy.util import minibatch, compounding
from pathlib import Path
from spacy.training import Example

# TRAINING THE MODEL
nlp_ner=spacy.load('en_core_web_sm')
with nlp_ner.disable_pipes(*unaffected_pipes):

  # Training for 30 iterations
  for iteration in range(30):

    # shuufling examples  before every iteration
    random.shuffle(NER_TRAINING_DATA)
    losses = {}
    for batch in spacy.util.minibatch(NER_TRAINING_DATA, size=2):
        for text, annotations in batch:
            # create Example
            doc = nlp_ner.make_doc(text)
            example = Example.from_dict(doc, annotations)
            # Update the model
            nlp_ner.update([example], losses=losses, drop=0.3)

I would liked to convert this model into tensorflow format, but couldn't understand or follow the guides. Is there any documents explaining conversion of trained spacy ner model directly?

Your Environment

rmitsch commented 1 year ago

Hey @mhyeonsoo, a conversion of spaCy/Thinc models to TF is not supported at the moment.

rmitsch commented 1 year ago

Actually, let me convert this into a discussion.