> For the complete documentation index, see [llms.txt](https://ai-community-iitb-organization.gitbook.io/10-days-realtime-llm-bootcamp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ai-community-iitb-organization.gitbook.io/10-days-realtime-llm-bootcamp/retrieval-augmented-generation-and-llm-architecture/llm-architecture-diagram-and-various-steps.md).

# LLM Architecture Diagram and Various Steps

\
Now that we've explored the various components that make up the architecture of Large Language Models (LLMs), let's dive into how Retrieval-Augmented Generation (RAG) can work synergistically with these components of an LLM architecture. The aim is to show you how RAG can supercharge an LLM's capabilities by seamlessly integrating real-time or static data sources into the information retrieval and generation processes.

## LLM Architecture

<figure><img src="https://2242835721-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6FUyhX0UiywvK1rz0m1N%2Fuploads%2FAuwpeLdJgPpJbXcZw4YH%2FLLM%20Architecture%20Diagram.png?alt=media&amp;token=a8c3374b-2588-4492-9b4d-c8638e3b3d06" alt="This diagram shows LLM Architecture and it&#x27;s various sources. Data Sources: Whether your starting point is cloud storage, Git repositories, or databases like PostgreSQL, the first task is to bring these varied data forms together through pre-configured connectors. Dynamic Vector Indexing: Text from these data sources is broken down into smaller segments and converted into vector representations. Models specialized for text embeddings, such as OpenAI&#x27;s text-embedding-ada-002, are employed here. These vectors are continuously indexed to facilitate rapid search later on. Query Transformation: A user’s input query is likewise transformed into a compatible vector representation, ensuring that it can be effectively matched with the indexed vectors for data retrieval. Contextual Retrieval: Algorithms like Locality-Sensitive Hashing (LSH) are applied to find the closest matches between the user query and the indexed data vectors, staying within the model&#x27;s token limitations. Text Generation: With the retrieved context, foundational LLMs like GPT-3.5 Turbo or Llama-2 employ techniques from the Transformer architecture, such as self-attention, to generate an appropriate response. User Experience: Finally, the generated text is presented to the user via interfaces like Streamlit or ChatGPT."><figcaption><p>LLM Architecture Diagram to show how RAG works with Real-time or Static Data Sources</p></figcaption></figure>

For a nuanced understanding of how Retrieval-Augmented Generation (RAG) optimizes Large Language Models, we'll delve into the essential elements and procedural steps that comprise the LLM architecture.

1. **Data Sources**: Whether your starting point is cloud storage, Git repositories, or databases like PostgreSQL, the first task is to bring these varied data forms together through pre-configured connectors.&#x20;
2. **Dynamic Vector Indexing**: Text from these data sources is broken down into smaller segments (also called "chunks") and converted into vector representations. Models specialized for text embeddings, such as OpenAI's text-embedding-ada-002, are employed here. These vectors are continuously indexed to facilitate rapid search later on.
3. **Query Transformation**: A user’s input query is likewise transformed into a compatible vector representation, ensuring that it can be effectively matched with the indexed vectors for data retrieval.
4. **Contextual Retrieval**: Algorithms like Locality-Sensitive Hashing (LSH) are applied to find the closest matches between the user query and the indexed data vectors, staying within the model's token limitations.
5. **Text Generation**: With the retrieved context, foundational LLMs like GPT-3.5 Turbo or Llama-2 employ techniques from the Transformer architecture, such as self-attention, to generate an appropriate response.
6. **User Interface**: Finally, the generated text is presented to the user via interfaces like Streamlit or ChatGPT.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://ai-community-iitb-organization.gitbook.io/10-days-realtime-llm-bootcamp/retrieval-augmented-generation-and-llm-architecture/llm-architecture-diagram-and-various-steps.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
