Llammaindex

1. RAG Concepts

1.1. Loading Stage

1.1.1. Connector (aka Reader)

  • ingests data from different sources into Documents and Nodes

1.1.2. Documents

  • container around any data source

1.1.3. Nodes

  • atomic unit of data : a chunk of the source doc

1.2. Indexing Stage

1.2.1. Indexes

  • once ingested, llamaindex will help you index data into a structure that is easy to retrieve.
  • The index is actually a managed map between the node metadata and the vector embeddings

1.2.2. Embeddings

  • vector representations of data for similarity searches

1.3. Querying Stage

1.3.1. Retrievers

  • A retriever defines to how to efficiently retrieve relevant context from an index when given a query
  • the retrieval strategy dictates the relevancy of data and the efficiency of doing so.

1.3.2. Routers

  • a router determines which retriever will be used to retrieve relevant context from the knowledge base.

1.3.3. Node PostProcessors

  • A node postprocessor takes in a set of retrieved nodes and applies transformatoins, filtering or re-ranking logic to them.

1.3.4. Response Synthesizers

  • A response synthesizer generates a respone from an LLM, using a user query and a given set of retrieved text chunks.

2. Index Types

  • SummaryIndex: This is very similar to a box for recipes – it keeps your Nodes in order, so you can access them one by one. It takes in a set of documents, chunks them up into Nodes, and then concatenates them into a list. It’s great for reading through a big Document.
  • DocumentSummaryIndex: This constructs a concise summary for each document, mapping these summaries back to their respective nodes. It facilitates efficient information retrieval by using these summaries to quickly identify relevant documents.
  • VectorStoreIndex: This is one of the more sophisticated types of indexes and probably the workhorse in most RAG applications. It converts text into vector embeddings and uses math to group similar Nodes, helping locate Nodes that are alike.
  • TreeIndex: The perfect solution for those who love order. This index behaves similarly to putting smaller boxes inside bigger ones, organizing Nodes by levels in a tree-like structure. Inside, each parent node stores summaries of the children nodes. These are generated by the LLM, using a general summarization prompt. This particular index can be very useful for summarization.
  • KeywordTableIndex: Imagine you need to find a dish by the ingredients you have. The keyword index connects important words to the Nodes they’re in. It makes finding any node easy by looking up keywords.
  • KnowledgeGraphIndex: This is useful when you need to link facts in a big network of data stored as a knowledge graph. This one is good for answering tricky questions about lots of connected information.
  • ComposableGraph: This allows you to create complex index structures in which Document- level indexes are indexed in higher-level collections. That’s right: you can even build an index of indexes if you want

3. Relevant Nodes

3.2. Ragas

3.3. DeepEval

3.5. Ollama

3.6. LocalAI

Tags::ai:tool: