This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Подбор сырья для формирования датасета для тренировки валидатора синтаксиса. | |
Берем фразы с правильным синтаксисом и заменяем в них предлоги на рандомные, | |
при необходимости пересогласуя подчиненные существительные и прилагательные. | |
""" | |
from __future__ import division # for python2 compatibility | |
from __future__ import print_function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import collections | |
import re | |
import ruword2tags | |
regex1 = re.compile(u'[%s ]+' % re.escape(u'"«».,:;!?=()\t\u00a0\u202F\u2060\u200A\s')) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
''' | |
Тренировка модели, которая посимвольно в режиме teacher forcing учится генерировать | |
ответ для заданной предпосылки и вопроса. | |
В качестве классификационного движка для выбора символов используется нейросетка | |
За один запуск модели выбирается один новый символ, который добавляется к ранее сгенерированной | |
цепочке символов ответа (см. функцию generate_answer). Генерация через повторные запуски продолжается | |
до появления специального маркера конца цепочки END_CHAR. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
""" | |
Тренер классификатора интентов для чатбота - нейросетка поверх BERT. | |
13.07.2019 первая реализация | |
13.07.2019 сделан gridsearch для подбора параметров сетки | |
20.07.2019 переделка для прямого использования nlu.md | |
26.07.2019 в кач-ве метрики кроссвалидации используется f1_weighted | |
""" | |
from __future__ import print_function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
""" | |
Тренер классификатора интентов для чатбота - нейросетка поверх ELMO. | |
05.09.2019 первая реализация, за основу взят код train_intent_classifier_bert.py | |
""" | |
from __future__ import print_function | |
import numpy as np | |
import argparse | |
import platform |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Тренировка модели детектора синонимичности двух фраз (сиамская рекуррентная сетка) на PyTorch """ | |
import io | |
import pandas as pd | |
import numpy as np | |
import itertools | |
import random | |
import tqdm | |
from sklearn.model_selection import train_test_split |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Тренировка модели детектора синонимичности двух фраз с использованием претренированной модели BERT на PyTorch | |
09.03.2020 Добавлен расчет метрики MRR (mean reciprocal rank) | |
""" | |
import pandas as pd | |
import numpy as np | |
import random |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import pandas as pd | |
import os | |
import numpy as np | |
import logging | |
import gc | |
from sklearn.metrics import f1_score, accuracy_score, precision_score, recall_score |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
B: День добрый | |
H: кто ты? | |
B: я чатбот | |
B: Скажи, пожалуйста, кто ты? | |
H: ты чатбот? | |
B: ведь , честно говоря , я тоже являюсь чатботом ! | |
H: ты человек? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
========== dialog_id=1 ========== | |
B: Привет, давай поболтаем? | |
H: горячо приветствую | |
B: что будем обсуждать? | |
H: давай тебя | |
B: Я готова отвечать на вопросы о себе. | |
H: ты кто? | |
B: я чатбот | |
B: Скажи, пожалуйста, кто ты? |