|
238 | 238 | "\n", |
239 | 239 | "If you want to make use of LLMs to answer questions based on private data, you have to provide the relevant documents as context alongside your prompt. This approach is called Retrieval Augmented Generation (RAG).\n", |
240 | 240 | "\n", |
241 | | - "You will use this approach to create a question-answering assistant using the Gemini text model integrated through LangChain. The assistant is expected to answer questions about AI and climate change. To make this possible you will add more context to the assistant using data from a website.\n", |
| 241 | + "You will use this approach to create a question-answering assistant using the Gemini text model integrated through LangChain. The assistant is expected to answer questions about the Gemini model. To make this possible you will add more context to the assistant using data from a website.\n", |
242 | 242 | "\n", |
243 | 243 | "In this tutorial, you'll implement the two main components in an RAG-based architecture:\n", |
244 | 244 | "\n", |
|
327 | 327 | }, |
328 | 328 | "outputs": [], |
329 | 329 | "source": [ |
330 | | - "loader = WebBaseLoader(\"https://blog.google/outreach-initiatives/sustainability/report-ai-sustainability-google-cop28/\")\n", |
| 330 | + "loader = WebBaseLoader(\"https://blog.google/technology/ai/google-gemini-ai/\")\n", |
331 | 331 | "docs = loader.load()" |
332 | 332 | ] |
333 | 333 | }, |
|
353 | 353 | "# Extract the text from the website data document\n", |
354 | 354 | "text_content = docs[0].page_content\n", |
355 | 355 | "\n", |
356 | | - "# The text content between the substrings \"Later this month at COP28\" to\n", |
357 | | - "# \"POSTED IN:\" is relevant for this tutorial. You can use Python's `split()`\n", |
| 356 | + "# The text content between the substrings \"code, audio, image and video.\" to\n", |
| 357 | + "# \"Cloud TPU v5p\" is relevant for this tutorial. You can use Python's `split()`\n", |
358 | 358 | "# to select the required content.\n", |
359 | | - "text_content_1 = text_content.split(\"Later this month at COP28\",1)[1]\n", |
360 | | - "final_text = text_content_1.split(\"POSTED IN:\",1)[0]\n", |
| 359 | + "text_content_1 = text_content.split(\"code, audio, image and video.\",1)[1]\n", |
| 360 | + "final_text = text_content_1.split(\"Cloud TPU v5p\",1)[0]\n", |
361 | 361 | "\n", |
362 | 362 | "# Convert the text to LangChain's `Document` format\n", |
363 | 363 | "docs = [Document(page_content=final_text, metadata={\"source\": \"local\"})]" |
|
470 | 470 | "retriever = vectorstore_disk.as_retriever(search_kwargs={\"k\": 1})\n", |
471 | 471 | "\n", |
472 | 472 | "# Check if the retriever is working by trying to fetch the relevant docs related\n", |
473 | | - "# to the word 'climate'. If the length is greater than zero, it means that\n", |
| 473 | + "# to the word 'MMLU' (Massive Multitask Language Understanding). If the length is greater than zero, it means that\n", |
474 | 474 | "# the retriever is functioning well.\n", |
475 | | - "print(len(retriever.get_relevant_documents(\"climate\")))" |
| 475 | + "print(len(retriever.get_relevant_documents(\"MMLU\")))" |
476 | 476 | ] |
477 | 477 | }, |
478 | 478 | { |
|
645 | 645 | "type": "string" |
646 | 646 | }, |
647 | 647 | "text/plain": [ |
648 | | - "'AI can address climate challenges by providing better information for sustainable choices, delivering improved predictions for climate adaptation, finding recommendations for optimizing climate action, predicting climate-related events, and managing the environmental impact of AI.'" |
| 648 | + "\"Gemini is Google's largest and most capable AI model, designed to efficiently run on various platforms, from data centers to mobile devices. It excels in understanding and reasoning about text, images, audio, and code. Gemini's sophisticated multimodal reasoning capabilities enable it to uncover knowledge from vast amounts of data and explain reasoning in complex subjects like math and physics. It can also generate high-quality code in multiple programming languages.\"" |
649 | 649 | ] |
650 | 650 | }, |
651 | | - "execution_count": 14, |
| 651 | + "execution_count": 15, |
652 | 652 | "metadata": {}, |
653 | 653 | "output_type": "execute_result" |
654 | 654 | } |
655 | 655 | ], |
656 | 656 | "source": [ |
657 | | - "rag_chain.invoke(\"How can AI address climate challenges?\")" |
| 657 | + "rag_chain.invoke(\"What is Gemini?\")" |
658 | 658 | ] |
659 | 659 | }, |
660 | 660 | { |
|
0 commit comments