Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clojure BERT finetuning example: fix CSV parsing #5

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions contrib/clojure-package/examples/bert/fine-tune-bert.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@
],
"source": [
"(def model-path-prefix \"data/static_bert_base_net\")\n",
";; epoch number of the model\n",
"(def epoch 0)\n",
";; the vocabulary used in the model\n",
"(def vocab (bert-util/get-vocab))\n",
";; the input question\n",
Expand Down Expand Up @@ -217,28 +215,30 @@
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"He said the foodservice pie business doesn 't fit the company 's long-term growth strategy .\n",
" 100 percent behind George Bush \" and looked forward to using his years of training in the war .\n",
" The foodservice pie business does not fit our long-term growth strategy .\n",
"1\n"
]
}
],
"source": [
"(def raw-file (csv/parse-csv (slurp \"data/dev.tsv\") :delimiter \\tab))\n",
"(def raw-file \n",
" (csv/parse-csv (string/replace (slurp \"data/dev.tsv\") \"\\\"\" \"\")\n",
" :delimiter \\tab\n",
" :strict true))\n",
"\n",
"(def data-train-raw (->> raw-file\n",
" (mapv #(vals (select-keys % [3 4 0])))\n",
" (rest) ;;drop header\n",
" (into [])\n",
" ))\n",
" (mapv #(vals (select-keys % [3 4 0])))\n",
" (rest) ; drop header\n",
" (into [])))\n",
"\n",
"(def sample (first data-train-raw))\n",
"(println (nth sample 0)) ;;;sentence a\n",
"(println (nth sample 1)) ;; sentence b\n",
Expand Down