Я обучаю специальную модель NER с помощью Spacy версии 3.5.0, используя некоторые фиктивные данные. Весь мой код и фиктивные данные приведены ниже. Это тот же код, что и во второй половине этой ссылки. Код работает нормально, но он выполняется только до тех пор, пока не будет выполнен этап Инициализация конвейера и Конвейер обучения.
Есть идеи, почему конвейер обучения не выполняется?
import pandas as pd
import os
from tqdm import tqdm
from spacy.tokens import DocBin
train = [
("An average-sized strawberry has about 200 seeds on its outer surface and are quite edible.",{"entities":[(17,27,"Fruit")]}),
("The outer skin of Guava is bitter tasting and thick, dark green for raw fruits and as the fruit ripens, the bitterness subsides. ",{"entities":[(18,23,"Fruit")]}),
("Grapes are one of the most widely grown types of fruits in the world, chiefly for the making of different wines. ",{"entities":[(0,6,"Fruit")]}),
("Watermelon is composed of 92 percent water and significant amounts of Vitamins and antioxidants. ",{"entities":[(0,10,"Fruit")]}),
("Papaya fruits are usually cylindrical in shape and the size can go beyond 20 inches. ",{"entities":[(0,6,"Fruit")]}),
("Mango, the King of the fruits is a drupe fruit that grows in tropical regions. ",{"entities":[(0,5,"Fruit")]}),
("undefined",{"entities":[(0,6,"Fruit")]}),
("Oranges are great source of vitamin C",{"entities":[(0,7,"Fruit")]}),
("A apple a day keeps doctor away. ",{"entities":[(2,7,"Fruit")]})
]
db = DocBin() # create a DocBin object
for text, annot in tqdm(train): # data in previous format
doc = nlp.make_doc(text) # create doc object from text
ents = []
for start, end, label in annot["entities"]: # add character indexes
span = doc.char_span(start, end, label=label, alignment_mode="contract")
if span is None:
print("Skipping entity")
else:
ents.append(span)
doc.ents = ents # label the text with the ents
db.add(doc)
db.to_disk("./train.spacy") # save the docbin object
!python -m spacy init fill-config base_config.cfg config.cfg
!python -m spacy train config.cfg --output ./output --paths.train ./train.spacy --paths.dev ./train.spacy
Ожидаемый результат
[img]https://i. sstatic.net/dm2Vn.png[/img]
Я обучаю специальную модель NER с помощью Spacy версии 3.5.0, используя некоторые фиктивные данные. Весь мой код и фиктивные данные приведены ниже. Это тот же код, что и во второй половине этой ссылки. Код работает нормально, но он выполняется только до тех пор, пока не будет выполнен этап [b]Инициализация конвейера[/b] и [b]Конвейер обучения[/b]. Есть идеи, почему конвейер обучения не выполняется? [code]import pandas as pd import os from tqdm import tqdm from spacy.tokens import DocBin
train = [ ("An average-sized strawberry has about 200 seeds on its outer surface and are quite edible.",{"entities":[(17,27,"Fruit")]}), ("The outer skin of Guava is bitter tasting and thick, dark green for raw fruits and as the fruit ripens, the bitterness subsides. ",{"entities":[(18,23,"Fruit")]}), ("Grapes are one of the most widely grown types of fruits in the world, chiefly for the making of different wines. ",{"entities":[(0,6,"Fruit")]}), ("Watermelon is composed of 92 percent water and significant amounts of Vitamins and antioxidants. ",{"entities":[(0,10,"Fruit")]}), ("Papaya fruits are usually cylindrical in shape and the size can go beyond 20 inches. ",{"entities":[(0,6,"Fruit")]}), ("Mango, the King of the fruits is a drupe fruit that grows in tropical regions. ",{"entities":[(0,5,"Fruit")]}), ("undefined",{"entities":[(0,6,"Fruit")]}), ("Oranges are great source of vitamin C",{"entities":[(0,7,"Fruit")]}), ("A apple a day keeps doctor away. ",{"entities":[(2,7,"Fruit")]}) ]
db = DocBin() # create a DocBin object
for text, annot in tqdm(train): # data in previous format doc = nlp.make_doc(text) # create doc object from text ents = [] for start, end, label in annot["entities"]: # add character indexes span = doc.char_span(start, end, label=label, alignment_mode="contract") if span is None: print("Skipping entity") else: ents.append(span) doc.ents = ents # label the text with the ents db.add(doc)
db.to_disk("./train.spacy") # save the docbin object
Сейчас я пытаюсь внедрить простой пользовательский компонент в свой процесс обучения spaCy. Для обучения я использую интерфейс командной строки spaCy, что означает, что я управляю конфигурацией конвейера через файл config.cfg, хотя у меня есть...
Я пытаюсь реализовать простой пользовательский компонент в своем обучающем конвейере SpaCy. Для обучения я использую интерфейс командной строки spaCy, что означает, что я управляю конфигурацией конвейера через файл config.cfg, хотя у меня есть...
Я использую Spacy с моделью PL_CORE_NEWS_LG для извлечения именованных объектов из польского текста. Он правильно обнаруживает как организации (ORG), так и имена людей (PER):
import spacy
nlp = spacy.load( pl_core_news_lg )
text = Jan Kowalski...
Последние версии Spacy имеют лучшую производительность и совместимость для ускорения графического процессора на устройствах Apple, но у меня есть существующий проект, который зависит от Spacy 3.1.4 и некоторых конкретных поведения моделей 3.1.0 (Web...