Skip to content

Commit

Permalink
Chore: pre-commit autoupdate
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Aug 26, 2024
1 parent 0add4fc commit a9247d8
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions demo/training_demo/train_sentence_transformer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@
" label = self.labels[idx]\n",
"\n",
" inputs = self.tokenizer(\n",
" question, context, truncation=True, padding=\"max_length\", max_length=self.max_length, return_tensors=\"pt\"\n",
" question,\n",
" context,\n",
" truncation=True,\n",
" padding=\"max_length\",\n",
" max_length=self.max_length,\n",
" return_tensors=\"pt\",\n",
" )\n",
"\n",
" input_ids = inputs[\"input_ids\"].squeeze()\n",
Expand Down Expand Up @@ -137,7 +142,9 @@
"source": [
"MODEL_NAME = \"sentence-transformers/all-MiniLM-L6-v2\"\n",
"NUM_LABELS = 2\n",
"model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME, num_labels=NUM_LABELS)\n",
"model = AutoModelForSequenceClassification.from_pretrained(\n",
" MODEL_NAME, num_labels=NUM_LABELS\n",
")\n",
"\n",
"tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)"
]
Expand All @@ -161,10 +168,14 @@
"MAX_LENGTH = 512\n",
"\n",
"# Create training dataset\n",
"train_dataset = CustomDataset(tokenizer, train_df[\"question\"], train_df[\"context\"], train_df[\"label\"], MAX_LENGTH)\n",
"train_dataset = CustomDataset(\n",
" tokenizer, train_df[\"question\"], train_df[\"context\"], train_df[\"label\"], MAX_LENGTH\n",
")\n",
"\n",
"# Create evaluation dataset\n",
"eval_dataset = CustomDataset(tokenizer, eval_df[\"question\"], eval_df[\"context\"], eval_df[\"label\"], MAX_LENGTH)"
"eval_dataset = CustomDataset(\n",
" tokenizer, eval_df[\"question\"], eval_df[\"context\"], eval_df[\"label\"], MAX_LENGTH\n",
")"
]
},
{
Expand Down

0 comments on commit a9247d8

Please sign in to comment.