Skip to content

Commit

Permalink
Parametrize slice and threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
mc-cat-tty committed Jan 29, 2024
1 parent 1b2d198 commit 91f74d2
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions query_expansion.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,9 @@
},
{
"cell_type": "code",
"execution_count": 195,
"execution_count": 199,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['house', 'property', 'is', 'building', 'residence']\n"
]
}
],
"outputs": [],
"source": [
"from transformers import BertModel\n",
"import torch\n",
Expand Down Expand Up @@ -135,13 +127,17 @@
" .value()\n",
")\n",
"\n",
"THRESHOLD = 0.8\n",
"SLICE = 5\n",
"\n",
"synonyms = (\n",
" pydash.chain(candidates)\n",
" .map(itemgetter('token_str'))\n",
" .zip(similarities)\n",
" .filter(lambda t: t[1] > THRESHOLD)\n",
" .sort(key = itemgetter(1), reverse = True)\n",
" .map(itemgetter(0))\n",
" .take(5)\n",
" .take(SLICE)\n",
" .value()\n",
")\n",
"\n",
Expand Down

0 comments on commit 91f74d2

Please sign in to comment.