buriy / spacy-ru

Russian language models for spaCy
MIT License
242 stars 29 forks source link

Почему 0ая точность для POS ru2? #29

Closed sbushmanov closed 4 years ago

sbushmanov commented 4 years ago

Следующий код дает 0ую точность для POS:

import spacy
from spacy.gold import GoldParse, GoldCorpus
from spacy.scorer import Scorer

ru2 = spacy.load("../../ru2")

corpus = GoldCorpus('../../data/syntagrus/ru_syntagrus-ud-train.json', 
                    '../../data/syntagrus/ru_syntagrus-ud-test.json')

scorer = Scorer()

for doc, gold in corpus.dev_docs(ru2):
    pred = ru2(doc.text)
    scorer.score(pred, gold)

pd.DataFrame(scorer.scores,index=[0])

  | uas          | las              | ents_p    | ents_r | ents_f | ents_per_type | tags_acc | token_acc
  88.523841      | 84.689796        | 0.0       | 0.0    | 0.0    | NaN           | 0.0        | 98.161359

Почему? Заранее спасибо за ответ!

PS Я так понимаю разные форматы TAG? Как корректно привести к одинаковому формату?

buriy commented 4 years ago

Не совпадают морфологические теги. Добавь print(gold.tags[:3], [p.pos_ for p in pred[:3]])

В gold приходят значения ADJ__Case=Nom|Degree=Pos|Gender=Fem|Number=Sing вместо "ADJ".

Варианты:

Спасибо за красивый и простой пример!

On Thu, Jul 30, 2020 at 5:12 AM sbushmanov notifications@github.com wrote:

Следующий код дает 0ую точность для POS:

import spacy

from spacy.gold import GoldParse, GoldCorpus

from spacy.scorer import Scorer

ru2 = spacy.load("../../ru2")

corpus = GoldCorpus('../../data/syntagrus/ru_syntagrus-ud-train.json',

                '../../data/syntagrus/ru_syntagrus-ud-test.json')

scorer = Scorer()

for doc, gold in corpus.dev_docs(ru2):

pred = ru2(doc.text)

scorer.score(pred, gold)

pd.DataFrame(scorer.scores,index=[0])

| uas | las | ents_p | ents_r | ents_f | ents_per_type | tags_acc | token_acc

88.523841 | 84.689796 | 0.0 | 0.0 | 0.0 | NaN | 0.0 | 98.161359

Почему? Заранее спасибо за ответ!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/buriy/spacy-ru/issues/29, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAFFBBH3TINX5YC2VW3RYTR6CNE7ANCNFSM4PMFHLUQ .

-- Best regards, Yuri V. Baburov, Skype: yuri.baburov

sbushmanov commented 4 years ago

Если делать так как советуют коллеги из Explosion:

spacy convert -n 5 -m ru_syntagrus-ud-test.conllu ./

вместо:

spacy convert -m ru_syntagrus-ud-test.conllu ./

точность uas/las падает на 6÷7%.

Я правильно понимаю, что:

buriy commented 4 years ago

Если ты брал пре-релиз, то он, вероятно, тренировался без деления на предложения, я забыл при тренировке добавить "-n 10". Поэтому точность на тесте и падает. Если тренировать с делением на предложения, то такого не происходит.