mirror of
https://github.com/james-m-jordan/openai-cookbook.git
synced 2025-05-09 19:32:38 +00:00
rename image file
This commit is contained in:
parent
8893ba94dd
commit
af7239bfda
@ -18,7 +18,7 @@
|
||||
"\n",
|
||||
"By combining these approaches, and drawing inspiration from [re-ranking](https://www.sbert.net/examples/applications/retrieve_rerank/README.html) methods, we identify an approach that sits in the middle. **This approach can be implemented on top of any existing search system, like the Slack search API, or an internal ElasticSearch instance with private data**. Here’s how it works:\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"**Step 1: Search**\n",
|
||||
"\n",
|
||||
@ -93,7 +93,7 @@
|
||||
"\n",
|
||||
"def embeddings(input: list[str]) -> list[list[str]]:\n",
|
||||
" response = openai.Embedding.create(model=\"text-embedding-ada-002\", input=input)\n",
|
||||
" return [data.embedding for data in response.data]\n"
|
||||
" return [data.embedding for data in response.data]"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -113,7 +113,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# User asks a question\n",
|
||||
"USER_QUESTION = \"Who won the NBA championship? And who was the MVP? Tell me a bit about the last game.\"\n"
|
||||
"USER_QUESTION = \"Who won the NBA championship? And who was the MVP? Tell me a bit about the last game.\""
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -179,7 +179,7 @@
|
||||
"# Let's include the original question as well for good measure\n",
|
||||
"queries.append(USER_QUESTION)\n",
|
||||
"\n",
|
||||
"queries\n"
|
||||
"queries"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -282,7 +282,7 @@
|
||||
" print(\"Title:\", article[\"title\"])\n",
|
||||
" print(\"Description:\", article[\"description\"])\n",
|
||||
" print(\"Content:\", article[\"content\"][0:100] + \"...\")\n",
|
||||
" print()"
|
||||
" print()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -326,7 +326,7 @@
|
||||
"\n",
|
||||
"hypothetical_answer = json_gpt(HA_INPUT)[\"hypotheticalAnswer\"]\n",
|
||||
"\n",
|
||||
"hypothetical_answer"
|
||||
"hypothetical_answer\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -376,7 +376,7 @@
|
||||
"for article_embedding in article_embeddings:\n",
|
||||
" cosine_similarities.append(dot(hypothetical_answer_embedding, article_embedding))\n",
|
||||
"\n",
|
||||
"cosine_similarities[0:10]"
|
||||
"cosine_similarities[0:10]\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -440,7 +440,7 @@
|
||||
" print(\"Description:\", article[\"description\"])\n",
|
||||
" print(\"Content:\", article[\"content\"][0:100] + \"...\")\n",
|
||||
" print(\"Score:\", score)\n",
|
||||
" print()"
|
||||
" print()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -500,7 +500,7 @@
|
||||
"for chunk in completion:\n",
|
||||
" text += chunk.choices[0].delta.get(\"content\", \"\")\n",
|
||||
" display.clear_output(wait=True)\n",
|
||||
" display.display(display.Markdown(text))\n"
|
||||
" display.display(display.Markdown(text))"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 122 KiB |
Loading…
x
Reference in New Issue
Block a user