Basic Concepts - davidmarsoni/llog GitHub Wiki

:bulb: General Information

This page is dedicated to the explanation of the basic concepts used in Llog.

:clipboard: Contents

  • LLMs
  • Generative AI
  • Agents
  • Agentic App
  • RAG approach

:brain: LLMs

LLM stands for Large Language Model, which is an AI (Artificial Intelligence) model that has been trained on large and varied datasets in order to analyze, process, and generate a corresponding answer to the intent of the user. This response will try to mimic the behavior of a real human.

The LLMs are mostly based on neural network algorithms which are a part of deep learning. A neural network is a graph-like representation of a network composed of an input layer, multiple hidden layers, and an output layer. The following diagram describes a basic neural network implementation:

Neural network

Neural networks learn by adjusting the weights of connections (determining their importance) between neurons during training to refine their predictions. Thus, it learns efficiently and thereby minimizes the errors between its predictions and actual data.

:sparkles: Generative AI

Generative AI refers to algorithms that are capable of generating new content, such as text, images, video, and more.

LLMs are increasingly multimodal, which allows the user to upload an image and receive responses in different formats. e.g., if a user uploads an image about a specific schema, the LLM will be able to understand and respond to the user.

In the context of LlamaIndex, generative AI plays a crucial role in the final step of the process.

After LlamaIndex retrieves and structures relevant external data, the AI uses this enhanced context to generate a comprehensive and accurate response.

In more complex workflows, such as those involving AI agents and chain-of-thought reasoning, generative AI can be used at multiple stages to refactor, enhance, or correct different parts of the process.

For example, it can rephrase retrieved data, summarize content, review AI-generated responses of other agents, or refine intermediate steps before producing a final output.

If you need more information about the concept behind the project, you can refer to the RAG approach section below.

:robot: Agents

An AI agent is a software system or program that takes on the role of an assistant, which performs complex tasks on behalf of a user or another system. In the context of large language models (LLMs), traditional models have three main flaws:

  1. Simple reasoning: They are limited in their reasoning by the data they are trained with, and they struggle with complex queries due to their rigid workflows.
  2. Out of touch: As time passes, their knowledge grows more and more outdated if itโ€™s not manually retrained.
  3. Limited Customization: They are limited in the role and behavior they take in regard to queries they are provided.

To address these challenges, AI agents can provide the following strengths:

  1. Extended reasoning: Agents act as another layer of intelligence on top of standard LLM prompts, an additional step in which they break down problems before tackling them, retrieve external data, and dynamically adjust the following workflow and approach based on context. This allows LLMs to go beyond static training data and engage in more complex queries.
  2. Keeping knowledge up to date: By integrating with external data sources, APIs, and real-time information retrieval systems, agents let LLMs access fresh knowledge and stay relevant even after their initial training.
  3. Memory and adaptation: Some agents can be designated with specific roles, allowing them to provide more accurate responses.

:rocket: Agentic App

An Agentic App is an application powered by combining multiple AI agents, each specialized in one task, enabling dynamic problem-solving and personalized customized interactions to handle complex workflows more easily.

Examples of AI Agents in an Agentic App:

  • Research Agent โ€“ Fetches and summarizes up-to-date information.
  • Coding Agent โ€“ Writes, debugs, and optimizes code.
  • Task Automation Agent โ€“ Automates workflows and repetitive tasks.
  • Data Analysis Agent โ€“ Processes and interprets large datasets.
  • Personal Assistant Agent โ€“ Manages schedules, reminders, and personal tasks.
  • Customer Support Agent โ€“ Handles inquiries and troubleshooting.

:mag: RAG approach

Retrieval-Augmented Generation (RAG) is an approach that solves some of the challenges of LLMs.

The first main problem of LLMs is that they donโ€™t know the user's data. Most LLMs are trained on a large variety of public data, so the resulting model can respond to many tasks or questions. Once a model is trained, many LLMs remain static as they donโ€™t have the ability to access new data beyond their training data. This can result in LLMs giving outdated information or hallucinating when asked questions about data they have not been trained on.

Another problem that LLMs face is that, most of the time, they give irrelevant results in specific domains. To be able to give relevant answers, the model needs to understand the specific domain or organization by providing it with company-related or subject-related data. For example, a company may need a chatbot that can answer specific healthcare questions. The resulting problem is how the model can retain this information without retraining it each time.

The common solution to these problems is to provide the custom data for the question as part of the AI's prompt. This is called Retrieval-Augmented Generation (RAG), as you retrieve data from your own sources to augment the capabilities of the LLMs.

The main benefits of using RAG are the following:

  • Reduced hallucinations

RAG allows for controlled information retrieval, which is finely tuned with generated content to maintain the best coherence and avoid hallucination. Hallucinations can be especially problematic in sensitive domains such as healthcare or law, where incorrect information can have serious consequences.

  • Up-to-date results

The RAG approach relies on an external knowledge base to retrieve relevant information for the user. These bases can be updated all the time rather than being limited to the specific training the LLM has received. This allows the response to no longer be limited to the model's current knowledge.

  • Better context relevance

As we can rely on external specific resources to enhance our context, it reduces the LLM's lack of context.

More information about RAG can be found with the following links:

:microscope: RAG in detail

The best way to explain the details of the RAG approach is visually. Below is a schema that explains the main steps of the RAG approach.

RAG - Diagram

  1. First, the user asks a prompt (question) to the user interface.
  2. Next, this query will be used to search for relevant information using the data it has available.
  3. After that, the relevant information (enhanced context) will be returned to the user interface.
  4. Then, this enhanced context serves as a base for the generation of the response by our LLM.
  5. Finally, the generated response is shown to the user.

The query is a version of the user prompt optimized to retrieve relevant information.

:link: sources