Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
markmcd committed Mar 6, 2024
1 parent c0dccd6 commit 2de3afc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions site/en/docs/search_reranking_using_embeddings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@
"import wikipedia\n",
"from wikipedia.exceptions import DisambiguationError, PageError\n",
"\n",
"\n",
"\n",
"import numpy as np\n",
"\n",
"from IPython.display import Markdown\n",
Expand Down Expand Up @@ -323,12 +321,15 @@
" for query in search_queries:\n",
" print(f'Searching for \"{query}\"')\n",
" search_terms = wikipedia.search(query)\n",
"\n",
" print(f\"Related search terms: {search_terms[:n_topics]}\")\n",
" for search_term in search_terms[:n_topics]: # select first `n_topics` candidates\n",
" if search_term in search_history: # check if the topic is already covered\n",
" continue\n",
"\n",
" print(f'Fetching page: \"{search_term}\"')\n",
" search_history.add(search_term) # add to search history\n",
"\n",
" try:\n",
" # extract the relevant data by using `gemini-pro` model\n",
" page = wikipedia.page(search_term, auto_suggest=False)\n",
Expand All @@ -345,6 +346,7 @@
"\n",
" Note: Do not summarize. Only Extract and return the relevant information\n",
" \"\"\"))\n",
"\n",
" urls = [url]\n",
" if response.candidates[0].citation_metadata:\n",
" extra_citations = response.candidates[0].citation_metadata.citation_sources\n",
Expand Down Expand Up @@ -724,7 +726,9 @@
"outputs": [
{
"data": {
"text/plain": []
"text/plain": [
"'No citations found'"
]
},
"execution_count": 49,
"metadata": {},
Expand Down Expand Up @@ -1092,7 +1096,7 @@
"id": "tip8ArqJf_ep"
},
"source": [
"Please refer to the [embeddings_guide](https://ai.google.dev/docs/embeddings_guide) for more information on embeddings."
"Please refer to the [embeddings guide](https://ai.google.dev/docs/embeddings_guide) for more information on embeddings."
]
},
{
Expand Down

0 comments on commit 2de3afc

Please sign in to comment.