<jupyter_start><jupyter_text>Train text model<jupyter_code>import sys
sys.path.insert(0,'../input/shopee-competition-utils')

from config import CFG
from run_training import run_bert_training
from run_test import run_bert_test<jupyter_output><empty_output><jupyter_text>TrainParameters in `CFG`:+ `CFG.DEVICE` can be set to one of the availiable cuda, `['cuda:0','cuda:1','cuda:2','cuda:3']`+ `CFG.BERT_MARGINS = [0.5,0.6,0.7,0.8]`+ `CFG.BERT_MODEL_NAMES = ['bert-base-multilingual-uncased',                           'cahya/bert-base-indonesian-1.5G',                           'cahya/distilbert-base-indonesian',                           'sentence-transformers/paraphrase-xlm-r-multilingual-v1',                           'sentence-transformers/paraphrase-distilroberta-base-v1']`<jupyter_code># choose which cuda to train model on
CFG.DEVICE = 'cuda:0'
CFG.BATCH_SIZE = 16
# choose which model with what hyperparameters to train
CFG.BERT_MODEL_NAME = CFG.BERT_MODEL_NAMES[3]
CFG.MARGIN = CFG.BERT_MARGINS[3]
CFG.MODEL_PATH_BERT = f"{CFG.BERT_MODEL_NAME.rsplit('/', 1)[-1]}_epoch8-bs16x1_margin_{CFG.MARGIN}.pt"

# start training
run_bert_training()
run_bert_test()<jupyter_output>Building Model Backbone for sentence-transformers/paraphrase-xlm-r-multilingual-v1 model, margin = 0.8
paraphrase-xlm-r-multilingual-v1_epoch8-bs16x1_margin_0.8.pt
get_bert_embeddings: 100%|████████████████████| 216/216 [00:04<00:00, 53.00it/s]
Searching best threshold...
threshold = 0.01 -> f1 score = 0.5043079609507127, recall = 0.3705569079686218, precision = 0.9982965883097289
threshold = 0.02 -> f1 score = 0.5221985775132593, recall = 0.3904053620942551, precision = 0.9972015379374117
threshold = 0.03 -> f1 score = 0.5364176878539656, recall = 0.40718974835347266, precision = 0.9969971285345792
threshold = 0.04 -> f1 score = 0.5493804316529174, recall = 0.4226959014617234, precision = 0.996058861564775
threshold = 0.05 -> f1 score = 0.5609129187284428, recall = 0.43637580972483175, precision = 0.9953818423266519
threshold = 0.06 -> f1 score = 0.5727563397591395, recall = 0.45070187858379923, precision = 0.9945953180512972
threshold = 0.07 -> f1 score = 0.5820083336170618, recall =[...]
StarcoderdataJupyterStructuredCleanDedup