Skip to content

Commit

Permalink
Update components.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
lfunderburk committed Nov 17, 2023
1 parent f305785 commit 7e05015
Showing 1 changed file with 13 additions and 103 deletions.
116 changes: 13 additions & 103 deletions ch3/jupyter-notebooks/components.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,39 +44,9 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Calculating embeddings: 0%| | 0/1 [00:00<?, ?it/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Calculating embeddings: 100%|██████████| 1/1 [00:00<00:00, 1.86it/s]"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0.0015798426466062665, 0.0059846313670277596]\n",
"[0.017629027366638184, -0.022774461656808853]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n"
]
}
],
"outputs": [],
"source": [
"from haystack.preview import Document\n",
"from haystack.preview.components.embedders import OpenAIDocumentEmbedder\n",
Expand Down Expand Up @@ -111,23 +81,9 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'documents': [Document(id='2e3218009b01cfc57f865bbf81fa70de81b5ebae02c4cc7092e46ffde03f3c49', content='The quick brown fox jumps over the lazy dog.', dataframe=None, blob=None, meta={}, score=None),\n",
" Document(id='63a06e3e867cb70e52a99c00b2de17fe531431c98e7d851268be01d341ea9f20', content='To be or not to be, that is the question.', dataframe=None, blob=None, meta={}, score=None)],\n",
" 'metadata': {'model': 'text-embedding-ada-002-v2',\n",
" 'usage': {'prompt_tokens': 22, 'total_tokens': 22}}}"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"result"
]
Expand All @@ -141,21 +97,9 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'model': 'text-embedding-ada-002-v2',\n",
" 'usage': {'prompt_tokens': 22, 'total_tokens': 22}}"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"result['metadata']"
]
Expand All @@ -176,7 +120,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -199,20 +143,9 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dict_keys(['embedding', 'metadata'])"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"result_text.keys()"
]
Expand All @@ -226,41 +159,18 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[0.017020374536514282, -0.023255806416273117]"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"result_text['embedding'][0:2]"
]
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'model': 'text-embedding-ada-002-v2',\n",
" 'usage': {'prompt_tokens': 4, 'total_tokens': 4}}"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"result_text['metadata']"
]
Expand Down

0 comments on commit 7e05015

Please sign in to comment.