Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 9, 2024
1 parent 6a2ef33 commit 36d4e28
Show file tree
Hide file tree
Showing 17 changed files with 2,354 additions and 2,318 deletions.
3,335 changes: 1,668 additions & 1,667 deletions examples/DVCLive-Evidently.ipynb

Large diffs are not rendered by default.

635 changes: 327 additions & 308 deletions examples/DVCLive-Fabric.ipynb

Large diffs are not rendered by default.

29 changes: 22 additions & 7 deletions examples/DVCLive-HuggingFace.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,23 @@
"source": [
"tokenizer = AutoTokenizer.from_pretrained(\"distilbert-base-cased\")\n",
"\n",
"\n",
"def tokenize_function(examples):\n",
" return tokenizer(examples[\"text\"], padding=\"max_length\", truncation=True)\n",
"\n",
"small_train_dataset = dataset[\"train\"].shuffle(seed=42).select(range(2000)).map(tokenize_function, batched=True)\n",
"small_eval_dataset = dataset[\"test\"].shuffle(seed=42).select(range(200)).map(tokenize_function, batched=True)"
"\n",
"small_train_dataset = (\n",
" dataset[\"train\"]\n",
" .shuffle(seed=42)\n",
" .select(range(2000))\n",
" .map(tokenize_function, batched=True)\n",
")\n",
"small_eval_dataset = (\n",
" dataset[\"test\"]\n",
" .shuffle(seed=42)\n",
" .select(range(200))\n",
" .map(tokenize_function, batched=True)\n",
")"
]
},
{
Expand Down Expand Up @@ -138,6 +150,7 @@
"\n",
"metric = evaluate.load(\"f1\")\n",
"\n",
"\n",
"def compute_metrics(eval_pred):\n",
" logits, labels = eval_pred\n",
" predictions = np.argmax(logits, axis=-1)\n",
Expand Down Expand Up @@ -178,7 +191,9 @@
"from transformers.integrations import DVCLiveCallback\n",
"from transformers import AutoModelForSequenceClassification, TrainingArguments, Trainer\n",
"\n",
"model = AutoModelForSequenceClassification.from_pretrained(\"distilbert-base-cased\", num_labels=2)\n",
"model = AutoModelForSequenceClassification.from_pretrained(\n",
" \"distilbert-base-cased\", num_labels=2\n",
")\n",
"for param in model.base_model.parameters():\n",
" param.requires_grad = False\n",
"\n",
Expand Down Expand Up @@ -224,7 +239,6 @@
"outputs": [],
"source": [
"from dvclive import Live\n",
"from transformers.integrations import DVCLiveCallback\n",
"\n",
"lr = 1e-4\n",
"\n",
Expand Down Expand Up @@ -273,13 +287,13 @@
"import dvc.api\n",
"import pandas as pd\n",
"\n",
"columns = [\"Experiment\", \"epoch\", \"eval.f1\"]\n",
"columns = [\"Experiment\", \"epoch\", \"eval.f1\"]\n",
"\n",
"df = pd.DataFrame(dvc.api.exp_show(), columns=columns)\n",
"\n",
"df.dropna(inplace=True)\n",
"df.reset_index(drop=True, inplace=True)\n",
"df\n"
"df"
]
},
{
Expand All @@ -302,7 +316,8 @@
"outputs": [],
"source": [
"from IPython.display import HTML\n",
"HTML(filename='./dvc_plots/index.html')"
"\n",
"HTML(filename=\"./dvc_plots/index.html\")"
]
}
],
Expand Down
Loading

0 comments on commit 36d4e28

Please sign in to comment.