{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from sentence_transformers import CrossEncoder" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2023-08-20 23:39:32.598364: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT\n" ] } ], "source": [ "model = CrossEncoder('cross-encoder/mmarco-mMiniLMv2-L12-H384-v1')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([-4.4115596, -3.8891914], dtype=float32)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.predict(\n", " [\n", " ('как исправить ошибку', 'как убрать ошибку'),\n", " ('добрый день', 'привет'),\n", " ]\n", ")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "from sentence_transformers import InputExample\n", "train_samples = [\n", " InputExample(texts=['как настроить модуль', 'как настроить модуль'], label=1.0),\n", " InputExample(texts=['как настроить модуль яндекс доставка', 'как настроить модуль почта россии'], label=0.0),\n", "]" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "from torch.utils.data import DataLoader\n", "train_dataloader = DataLoader(train_samples)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "e8062b9c6b4b47619bccaa0d18beec23", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Epoch: 0%| | 0/10 [00:00