Skip to content

Instantly share code, notes, and snippets.

Task Metric ChatGPT Baseline [2] DeepPavlov [3]
from deeppavlov import build_model, configs
model = build_model(configs.squad.squad_bert, download=True)
model(['In meteorology, precipitation is any product of the condensation of atmospheric water vapor that falls under gravity. The main forms of precipitation include drizzle, rain, sleet, snow, graupel and hail… Precipitation forms as smaller droplets coalesce via collision with other rain drops or ice crystals within a cloud. Short, intense periods of rain in scattered locations are called “showers”.'],['Where do water droplets collide with ice crystals to form precipitation?'])
[['within a cloud'], [305], [1.0]]
from deeppavlov import build_model, configs
ner_caseagnostic = build_model(configs.ner.ner_case_agnostic_mdistilbert, download=True)
ner_caseagnostic(['elon musk founded tesla in 2003'])
#[[['elon', 'musk', 'founded', 'tesla', 'in', '2003']], [['B-PER', 'I-PER', 'O', 'B-ORG', 'O', 'O']]]
ner_mult = build_model(configs.ner.ner_ontonotes_bert_mult, download=True)
ner_mult(['Curling World Championship will be held in Antananarivo', 'Чемпионат мира по кёрлингу пройдёт в Антананариву'])
#[[['Curling', 'World', 'Championship', 'will', 'be', 'held', 'in','Antananarivo'], ['Чемпионат', 'мира', 'по', 'кёрлингу', 'пройдёт', 'в', 'Антананариву']], [['B-EVENT', 'I-EVENT', 'I-EVENT', 'O', 'O', 'O', 'O', 'B-GPE'], ['B-EVENT', 'I-EVENT', 'I-EVENT', 'I-EVENT', 'O', 'O', 'B-GPE']]]
from deeppavlov import build_model, configs
ner = build_model(configs.ner.ner_ontonotes_bert, download=True)
ner(["Elon Musk founded Tesla in 2003", "Pichai was selected to become the next CEO of Google on August 10, 2015"])
#[[['Elon', 'Musk', 'founded', 'Tesla', 'in', '2003'], ['Pichai', 'was', 'selected', 'to', 'become','the', 'next', 'CEO', 'of', 'Google', 'on', 'August', '10', ',', '2015']], [['B-PERSON', 'I-PERSON', 'O', 'B-ORG', 'O', 'B-DATE'], ['B-PERSON', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'B-ORG', 'O', 'B-DATE', 'I-DATE', 'I-DATE', 'I-DATE']]]
@vaskonov
vaskonov / 10-1.py
Last active November 16, 2022 09:04
from deeppavlov import build_model, configs, evaluate_model
model = build_model(configs.classifiers.topics_distilbert_base_uncased, download=True)
model(['What do you think about the Arrival movie?', 'Do you like listening to Sting!'])
#[['Movies&Tv'], ['Music']]
from deeppavlov import build_model
model = build_model("squad_torch_bert", download=True)
model(['In meteorology, precipitation is any product of the condensation of atmospheric water vapor that falls under gravity. The main forms of precipitation include drizzle, rain, sleet, snow, graupel and hail… Precipitation forms as smaller droplets coalesce via collision with other rain drops or ice crystals within a cloud. Short, intense periods of rain in scattered locations are called "showers".'],
['Where do water droplets collide with ice crystals to form precipitation?'])
from deeppavlov import build_model
ner_mult = build_model("ner_ontonotes_bert_mult_torch", download=True)
ner_mult(["Curling World Championship will be held in Antananarivo",
"Чемпионат мира по кёрлингу пройдёт в Антананариву"])
from deeppavlov import build_model
ner = build_model("ner_ontonotes_bert_torch", download=True)
ner(["Computer Sciences Corp . , El Segundo , Calif . , said it is close to making final an agreement to buy Cleveland Consulting Associates from Saatchi & Saatchi"])
from deeppavlov import train_model
from deeppavlov.core.common.file import read_json, find_config
config = read_json(find_config('insults_kaggle_bert_torch'))
config['metadata']['variables']['MODEL_PATH'] = "{MODELS_PATH}/classifiers/insults_kaggle_torch_bert/{TRANSFORMER}"
config['metadata']['variables']['TRANSFORMER'] = "distilbert-base-uncased"
model = train_model(config)
evaluate_model(config)