Skip to content

Instantly share code, notes, and snippets.

@jobergum
Created January 31, 2020 18:45
Show Gist options
  • Save jobergum/91b96231b695d1d8c9675f19f46ef283 to your computer and use it in GitHub Desktop.
Save jobergum/91b96231b695d1d8c9675f19f46ef283 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Now fetch features from Vespa for all our query,document pairs "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"with open('features.txt') as fp:\n",
" features = [line.strip() for line in fp]\n",
"\n",
"all['query_embedding'] = all['search_term'].apply(\n",
" lambda x: session.run(sentence_embeddings, feed_dict={sentence: [x]})[0])\n",
"all['features'] = all.apply(lambda x: get_features_from_vespa(x), axis=1)\n",
"for feature in features:\n",
" all[feature] = all['features'].apply(lambda x: x.get(feature))\n",
"\n",
"all = all.drop(['features', 'product_title', \n",
" 'product_description', 'query_embedding'],axis=1)\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment