Notebooks
M
Mistral AI
Ollama Mistral Llamaindex

Ollama Mistral Llamaindex

mistral-cookbookLlamaIndexthird_party

RAG Pipeline with Ollama, Mistral and LlamaIndex

In this notebook, we will demonstrate how to build a RAG pipeline using Ollama, Mistral models, and LlamaIndex. The following topics will be covered:

  1. Integrating Mistral with Ollama and LlamaIndex.
  2. Implementing RAG with Ollama and LlamaIndex using the Mistral model.
  3. Routing queries with RouterQueryEngine.
  4. Handling complex queries with SubQuestionQueryEngine.

Before running this notebook, you need to set up Ollama. Please follow the instructions here.

[1]

Setup LLM

[ ]

Querying

[3]
[4]

Setup Embedding Model

[5]
/Users/ravithejad/Desktop/llamaindex/lib/python3.9/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
/Users/ravithejad/Desktop/llamaindex/lib/python3.9/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
  warnings.warn(
[6]

Download Data

We will use Uber and Lyft 10K SEC filings for the demostration.

[7]
zsh:1: command not found: wget
zsh:1: command not found: wget

Load Data

[8]

Create Index and Query Engines

[9]

Querying

[10]
[11]

RouterQueryEngine

We will utilize the RouterQueryEngine to direct user queries to the appropriate index based on the query related to either Uber/ Lyft.

Create QueryEngine tools

[12]

Create RouterQueryEnine

[13]

Querying

[14]
Selecting query engine 1: The provided choices are summaries of financial reports for the year 2021. Investments made by a company are not typically included in a financial report. However, the financial report may provide information about investments through capital expenditures or acquisition costs. As such, to find out about Uber's investments, one would need to look at a separate report or section that discusses these topics..
[15]
Selecting query engine 0: The given choices do not provide information about investments made by Lyft in 2021. They only provide information about the financials of Lyft and Uber for the year 2021..
[16]

SubQuestionQueryEngine

We will explore how the SubQuestionQueryEngine can be leveraged to tackle complex queries by generating and addressing sub-queries.

Create SubQuestionQueryEngine

[17]

Querying

[22]
Generated 2 sub questions.
[vector_uber_10k] Q: What is the revenue of Uber for year 2021
[vector_lyft_10k] Q: What is the revenue of Lyft for year 2021
[vector_lyft_10k] A:  In the provided context, the revenue for Lyft in the year 2021 is $3,208,323 thousand. This can be found on page 79 (file_path: lyft_2021.pdf).
[vector_uber_10k] A:  The revenue for Uber in the year 2021, as per the provided context, was $17,455 million.
[19]
Generated 2 sub questions.
[vector_uber_10k] Q: What investments were made by Uber in year 2021
[vector_lyft_10k] Q: What investments were made by Lyft in year 2021
[vector_uber_10k] A:  In year 2021, Uber made purchases of non-marketable equity securities for 982 million dollars as per the provided cash flow statement. However, it is important to note that the information does not specify the details or names of the specific investments made.
[vector_lyft_10k] A:  Based on the provided context, it appears that in the year 2021, Lyft made significant investments in several areas. These include developing and launching new offerings and platform features, expanding in existing and new markets, investing in their platform and customer engagement, investing in environmental programs such as their commitment to 100% EVs on their platform by the end of 2030, and expanding support services for drivers through Driver Hubs, Driver Centers, Mobile Services, Lyft AutoCare, and the Express Drive vehicle rental program. Additionally, they have invested in asset-intensive offerings like their network of Light Vehicles, Flexdrive, Lyft Rentals, and Lyft Auto Care. Furthermore, they have incurred and will continue to incur costs associated with Proposition 22 in California and the COVID-19 pandemic.