Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify wikipedia note in reranking guide #288

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions site/en/docs/search_reranking_using_embeddings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
"id": "739f0bb73f05"
},
"source": [
"> Note: This library was designed for ease of use and simplicity, not for advanced use. If you plan on doing serious scraping or automated requests, please use [Pywikipediabot](http://www.mediawiki.org/wiki/Manual:Pywikipediabot) or one of the other more advanced [Python MediaWiki API wrappers](http://en.wikipedia.org/wiki/Wikipedia:Creating_a_bot#Python), which has a larger API, rate limiting, and other features so you can be considerate of the MediaWiki infrastructure."
"Note: The [`wikipedia` package](https://pypi.org/project/wikipedia/) notes that it was \"designed for ease of use and simplicity, not for advanced use\", and that production or heavy use should instead \"use [Pywikipediabot](http://www.mediawiki.org/wiki/Manual:Pywikipediabot) or one of the other more advanced [Python MediaWiki API wrappers](http://en.wikipedia.org/wiki/Wikipedia:Creating_a_bot#Python)\"."
]
},
{
Expand Down 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
Loading