<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title><![CDATA[Tomás Murúa - Elasticsearch Labs]]></title>
    <description><![CDATA[Articles and tutorials from the Search team at Elastic]]></description>
    <copyright><![CDATA[© 2026. Elasticsearch B.V. All Rights Reserved]]></copyright>
    <image>
      <title><![CDATA[Tomás Murúa - Elasticsearch Labs]]></title>
      <url>https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1121c0bf0e8a6e65/6a88da6340a1841030ef456f/search-labs-thumbnail.png</url>
      <link>https://www.elastic.co/search-labs/author/tomas-murua</link>
    </image>
    <link>https://www.elastic.co/search-labs/author/tomas-murua</link>
    <atom:link href="https://www.elastic.co/search-labs/rss/author/tomas-murua.xml" rel="self" type="application/rss+xml"/>
    <language><![CDATA[en]]></language>
    <lastBuildDate>Thu, 10 Sep 2026 23:19:51 GMT</lastBuildDate>
  <item>
    <title><![CDATA[Building an AI agent for HR with Elastic Agent Builder and GPT-OSS]]></title>
    <description><![CDATA[Discover how to build an AI agent that can answer natural language queries about your employee HR data using Elastic Agent Builder and GPT-OSS.]]></description>
    <content:encoded><![CDATA[<h2>Introduction</h2><p>This article will show you how to build an AI agent for HR using <a href="https://openai.com/index/introducing-gpt-oss/">GPT-OSS</a> and Elastic Agent Builder. The agent can answer your questions without sending data to OpenAI, Anthropic, or any external service.</p><p>We’ll use LM Studio to serve GPT-OSS locally and connect it to Elastic Agent Builder.</p><p>By the end of this article, you’ll have a custom AI agent that can answer natural language questions about your employee data while maintaining full control over your information and model.</p><h2>Prerequisites</h2><p>For this article, you need:</p><ul><li><p><a href="https://www.elastic.co/cloud">Elastic Cloud</a> hosted 9.2, serverless or <a href="https://www.elastic.co/docs/deploy-manage/deploy/self-managed/local-development-installation-quickstart">local</a> deployment</p></li><li><p>Machine with 32GB RAM recommended (minimum 16GB for GPT-OSS 20B)</p></li><li><p><a href="https://lmstudio.ai/">LM Studio</a> installed</p></li><li><p><a href="https://www.docker.com/products/docker-desktop/">Docker Desktop</a> Installed</p></li></ul><h2>Why use GPT-OSS?</h2><p>With a local LLM you have the control to deploy it in your own infrastructure and fine-tune it to fit your own needs. All this while maintaining control over the data that you share with the model, and of course, you don’t have to pay a license fee to an external provider.</p><p>OpenAI <a href="https://openai.com/index/introducing-gpt-oss/">released GPT-OSS</a> on August 5, 2025, as part of their commitment to the open model ecosystem.</p><p>The 20B parameter model offers:</p><ul><li><p><strong>Tool use capabilities</strong></p></li><li><p><strong>Efficient inference</strong></p></li><li><p><strong>OpenAI SDK compatible</strong></p></li><li><p><strong>Compatible with agentic workflows</strong></p></li></ul><p>Benchmark comparison:</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt58fab956edb40412/6a170cfcb0367da43a72bd80/29160e3345352088e8213297630882f252b00c47-1600x680.png" alt="" /><h2>Solution architecture</h2><p>The architecture runs entirely on your local machine. Elastic (running in Docker) communicates directly with your local LLM through LM Studio, and the Elastic Agent Builder uses this connection to create custom AI agents that can query your employee data.</p><p>For more details, refer to this <a href="https://www.elastic.co/docs/solutions/observability/connect-to-own-local-llm">documentation</a>.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt80db5bb0a797f51b/6a170cfd0e2e492f2c41a16f/a4a886750ff25fa8bb7aefc7448161e52cf73ed3-1600x896.png" alt="" /><h2>Building an AI agent for HR: Steps</h2><p>We’ll divide the implementation into 5 steps:</p><ol><li><p>Configure LM studio with a local model</p></li><li><p>Deploy Local Elastic with Docker</p></li><li><p>Create the OpenAI connector in Elastic</p></li><li><p>Upload employee data to Elasticsearch</p></li><li><p>Build and test your AI Agent</p></li></ol><h2>Step 1: Configure LM Studio with GPT-OSS 20B</h2><p>LM Studio is a user-friendly application that allows you to run large language models locally on your computer. It provides an OpenAI-compatible API server, making it easy to integrate with tools like Elastic without a complex setup process. For more details, refer to the <a href="https://lmstudio.ai/docs/app">LM Studio Docs</a>.</p><p>First, download and install <a href="https://lmstudio.ai/">LM Studio</a> from the official website. Once installed, open the application.</p><h3>In the LM Studio interface:</h3><ol><li><p>Go to the search tab and search for “GPT-OSS”</p></li><li><p>Select the <code>openai/gpt-oss-20b</code> from OpenAI</p></li><li><p>Click download</p></li></ol><p>The size of this model should be approximately <strong>12.10GB</strong>. The download may take a few minutes, depending on your internet connection.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt2dc341a6625e34b7/6a170cff839dfa2eb4dcff44/5d01bc4dcb377b5259fc6b521fe2425a31b90ca4-1312x872.png" alt="" /><h4>Once the model is downloaded:</h4><ol><li><p>Go to the local server tab</p></li><li><p>Select the openai/gpt-oss-20b</p></li><li><p>Use the default port 1234</p></li><li><p>On the right panel, go to <strong>Load </strong>and set the Context Length to <strong>40K</strong> or higher</p></li></ol><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt3704ca1b28465cc4/6a170d00d7c022ed8fde64ef/e546033f916381647b876815b2c1f1ae2a08365f-326x337.png" alt="" /><p>5. Click start server</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7b9170a4945ff857/6a170d0266c4f9ffadf8c0a6/28ee78a3caa84d14e04db3d42f30acbe4d4d005a-1312x872.png" alt="" /><p>You should see this if the server is running.</p>[LM STUDIO SERVER] Success! HTTP server listening on port 1234
[LM STUDIO SERVER] Supported endpoints:
[LM STUDIO SERVER] -&gt;	GET  http://localhost:1234/v1/models
[LM STUDIO SERVER] -&gt;	POST http://localhost:1234/v1/responses
[LM STUDIO SERVER] -&gt;	POST http://localhost:1234/v1/chat/completions
[LM STUDIO SERVER] -&gt;	POST http://localhost:1234/v1/completions
[LM STUDIO SERVER] -&gt;	POST http://localhost:1234/v1/embeddings
Server started.<h2>Step 2: Deploy Local Elastic with Docker</h2><p>Now we’ll set up Elasticsearch and Kibana locally using Docker. Elastic provides a convenient script that handles the entire setup process. For more details refer to the <a href="https://www.elastic.co/docs/deploy-manage/deploy/self-managed/local-development-installation-quickstart">official documentation</a>.</p><h3>Run the start-local script</h3><p>Execute the following command in your terminal:</p>curl -fsSL https://elastic.co/start-local | sh<p>This script will:</p><ul><li><p>Download and configure Elasticsearch and Kibana</p></li><li><p>Start both services using Docker Compose</p></li><li><p>Automatically activate a 30-day Platinum trial license</p></li></ul><h3>Expected output</h3><p>Just wait for the following message and save the password and API key shown; you’ll need them to access Kibana:</p>🎉 Congrats, Elasticsearch and Kibana are installed and running in Docker!
🌐 Open your browser at http://localhost:5601
   Username: elastic
   Password: KSUlOMNr
🔌 Elasticsearch API endpoint: http://localhost:9200
🔑 API key: cnJGX0pwb0JhOG00cmNJVklUNXg6cnNJdXZWMnM4bncwMllpQlFlUTlWdw==
Learn more at https://github.com/elastic/start-local<h3>Access Kibana</h3><p>Open your browser and navigate to:</p>http://localhost:5601<p>Log in using the credentials obtained in the terminal output.</p><h3>Enable Agent Builder</h3><p>Once logged in to Kibana, navigate to <strong>Management </strong>&gt;<strong> AI </strong>&gt;<strong> Agent Builder </strong>and activate the Agent Builder.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt0a934bd99fa6a0ce/6a170d046234e019c3db1a5a/92e104cb846c20d875865ded8a3d37f5c7daae9b-1491x1528.png" alt="" /><h2>Step 3: Create the OpenAI connector in Elastic</h2><p>Now we’ll configure Elastic to use your local LLM.</p><h3>Access Connectors</h3><ol><li><p>In Kibana</p></li><li><p>Go to <strong>Project Settings</strong> &gt; <strong>Management</strong></p></li><li><p>Under <strong>Alerts and Insights</strong>, select <strong>Connectors</strong></p></li><li><p>Click Create Connector</p></li></ol><h3>Configure the connector</h3><p>Select <strong>OpenAI</strong> from the list of connectors. LM Studio uses the OpenAI SDK, making it compatible.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt762023c39781eb78/6a170d06a29299a59ed01087/5ac87042e086c7a2bd47a8039e646ec831f0dcc6-923x974.png" alt="" /><p>Fill in the fields with these values:</p><ul><li><p><strong>Connector name: </strong>LM Studio - GPT-OSS 20B</p></li><li><p><strong>Select an OpenAI provider: </strong>Other (OpenAI Compatible Service)</p></li><li><p><strong>URL: </strong><code>http://host.docker.internal:1234/v1/chat/completions</code></p></li><li><p><strong>Default model: </strong>openai/gpt-oss-20b</p></li><li><p><strong>API Key:</strong> testkey-123 (any text works, because LM Studio Server doesn't require authentication.)</p></li></ul><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt980e595f80e2be2e/6a170d086f7f0468a19148cc/2084ac32fcf1fb810c8b54ecab1c85a1e3e8905b-672x1302.png" alt="" /><p>To finish the configuration, click <strong>Save &amp; test</strong>.</p><p><strong>Important:</strong> Toggle ON the “<strong>Enable native function calling</strong>”; this is required for the Agent Builder to work properly. If you don’t enable this, you’ll get a <strong><code>No tool calls found in the response</code></strong> error.</p><h3>Test the connection</h3><p>Elastic should automatically test the connection. If everything is configured correctly, you’ll see a success message like this:</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4d2e815dd558f881/6a170d090e2e49076541a177/f567d767f1969c4730c1daa92f651789dc3742ac-1042x812.png" alt="" /><p>Response:</p>{
  "status": "ok",
  "data": {
    "id": "chatcmpl-flj9h0hy4wcx4bfson00an",
    "object": "chat.completion",
    "created": 1761189456,
    "model": "openai/gpt-oss-20b",
    "choices": [
      {
        "index": 0,
        "message": {
          "role": "assistant",
          "content": "Hello! 👋 How can I assist you today?",
          "reasoning": "Just greet.",
          "tool_calls": []
        },
        "logprobs": null,
        "finish_reason": "stop"
      }
    ],
    "usage": {
      "prompt_tokens": 69,
      "completion_tokens": 23,
      "total_tokens": 92
    },
    "stats": {},
    "system_fingerprint": "openai/gpt-oss-20b"
  },
  "actionId": "ee1c3aaf-bad0-4ada-8149-118f52dad757"
}<h2>Step 4: Upload employee data to Elasticsearch</h2><p>Now we’ll upload the <a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/gpt-oss-with-elasticsearch/hr-employees-bulk.json">HR employee dataset</a> to demonstrate how the agent works with sensitive data. I generated a fictional dataset with this structure.</p><h3>Dataset structure</h3>{
  "employee_id": "0f4dce68-2a09-4cb1-b2af-6bcb4821539b",
  "full_name": "Daffi Stiebler",
  "email": "lscutchings0@huffingtonpost.com",
  "date_of_birth": "1975-06-20T15:39:36Z",
  "hire_date": "2025-07-28T00:10:45Z",
  "job_title": "Physical Therapy Assistant",
  "department": "HR",
  "salary": "108455",
  "performance_rating": "Needs Improvement",
  "years_of_experience": 2,
  "skills": "Java",
  "education_level": "Master's Degree",
  "manager": "Carl MacGibbon",
  "emergency_contact": "Leigha Scutchings",
  "home_address": "5571 6th Park"
}<h3>Create the index with mappings</h3><p>First, create the index with proper mappings. Note that we’re using <a href="https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/semantic-text">semantic_text</a> fields for some key fields; this enables semantic search capabilities for our index.</p>​​PUT hr-employees
{
  "mappings": {
    "properties": {
      "@timestamp": {
        "type": "date"
      },
      "employee_id": {
        "type": "keyword"
      },
      "full_name": {
        "type": "text",
        "copy_to": "employee_semantic"
      },
      "email": {
        "type": "keyword"
      },
      "date_of_birth": {
        "type": "date",
        "format": "iso8601"
      },
      "hire_date": {
        "type": "date",
        "format": "iso8601"
      },
      "job_title": {
        "type": "text",
        "copy_to": "employee_semantic"
      },
      "department": {
        "type": "text",
        "copy_to": "employee_semantic"
      },
      "salary": {
        "type": "double"
      },
      "performance_rating": {
        "type": "text",
        "copy_to": "employee_semantic"
      },
      "years_of_experience": {
        "type": "long"
      },
      "skills": {
        "type": "text",
        "copy_to": "employee_semantic"
      },
      "education_level": {
        "type": "text",
        "copy_to": "employee_semantic"
      },
      "manager": {
        "type": "text",
        "copy_to": "employee_semantic"
      },
      "emergency_contact": {
        "type": "keyword"
      },
      "home_address": {
        "type": "keyword"
      },
      "employee_semantic": {
        "type": "semantic_text"
      }
    }
  }
}<h3>Index with Bulk API</h3><p>Copy and paste the <a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/gpt-oss-with-elasticsearch/hr-employees-bulk.json">dataset</a> into your Dev Tools in Kibana and execute it:</p>POST hr-employees/_bulk
{"index": {}}
{"employee_id": "57728b91-e5d7-4fa8-954a-2384040d3886", "full_name": "Filide Gane", "email": "vhallahan1@booking.com", "job_title": "Business Systems Development Analyst", "department": "Marketing", "salary": "$52330.27", "performance_rating": "Meets Expectations", "years_of_experience": 12, "skills": "Java", "education_level": "Bachelor's Degree", "date_of_birth": "2000-02-07T16:49:32Z", "hire_date": "2023-11-07T13:03:16Z", "manager": "Freedman Kings", "emergency_contact": "Vilhelmina Hallahan", "home_address": "75 Dennis Junction"}
{"index": {}}
{"employee_id": "...", ...}<h3>Verify the data</h3><p>Run a query to verify:</p>GET hr-employees/_search<h2>Step 5: Build and test your AI agent</h2><p>With everything configured, it’s time to build a custom AI agent using Elastic Agent Builder. For more details refer to the <a href="https://www.elastic.co/docs/solutions/search/agent-builder/get-started">Elastic documentation</a>.</p><h3>Add the connector</h3><p>Before we can create our new agent, we have to set our Agent builder to use our custom connector called <code>LM Studio - GPT-OSS 20B</code> because the default one is the <a href="https://www.elastic.co/docs/reference/kibana/connectors-kibana/elastic-managed-llm">Elastic Managed LLM</a>. For that, we need to go to <strong>Project Setting</strong> &gt; <strong>Management</strong> &gt; <strong>GenAI Settings</strong>; now we select the one we created and click <strong>Save</strong>.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc42f079c5e756057/6a170d0acf4f2501d9b2d1c7/11e830c3e2fb4c298b020c928fa5422f3397ba08-1600x1152.png" alt="" /><h3>Access Agent Builder</h3><ol><li><p>Go to <strong>Agents</strong></p></li><li><p>Click on <strong>Create a new agent</strong></p></li></ol><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb8e734817c5a7c6a/6a170d0ca929cf867cae0a34/c1e60541563650163f972ac9088dc1ed1de759a7-1600x1054.png" alt="" /><h3>Configure the agent</h3><p>To create a new agent, the required fields are the <strong>Agent ID</strong>, <strong>Display Name</strong>, and <strong>Display Instructions</strong>.</p><p>But there are more customization options, like the Custom Instructions that guide how your agent is going to behave and interact with your tools, similar to a system prompt, but for our custom agent. Labels help organize your agents, avatar color, and avatar symbol.</p><p>The ones that I chose for our agent based on the dataset are:

<strong>Agent ID:</strong> <code>hr_assistant</code></p><p><strong>Custom instructions:</strong></p>You are an HR Analytics Assistant that helps answer questions about employee data.
When responding to queries:
- Provide clear, concise answers
- Include relevant employee details (name, department, salary, skills)
- Format monetary values with currency symbols
- Be professional and maintain data confidentiality<p>
Labels: <code>Human Resources</code> and <code>GPT-OSS</code></p><p>Display name: <code>HR Analytics Assistant</code></p><p>Display description:</p>A specialized AI assistant for Human Resources that helps analyze employee data, compensation, performance metrics, and talent management. Ask questions about employees, departments, salaries, or performance analytics.<img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt23fb011e5b4f4d49/6a170d0e7d8d67f47a70e77f/f94bb2bf08497e5e756ca76b30a3a51f42927756-1424x1217.png" alt="" /><p>With all the data in there, we can click on <strong>Save</strong> our new agent.</p><h3>Test the agent</h3><p>Now you can ask natural language questions about your employee data, and GPT-OSS 20B will understand the intent and generate an appropriate response.</p><h4>Prompt:</h4>Which employee is the one with the highest salary in the hr-employees index?<h4>Answer:</h4><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc0c52faacf63b583/6a170d0f0e2e497bfd41a17b/94ad19f80b96304028a59f60beca51dfc9aecc8a-899x631.png" alt="" /><p>The Agent process was:</p><p>1. Understand your question using the GPT-OSS connector</p><p>2. Generate the appropriate Elasticsearch query (using the built-in tools or custom <a href="https://www.elastic.co/docs/reference/query-languages/esql">ES|QL</a>)</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte32a8a7e6363c7f2/6a170d115091680077e1bb44/6f2961d0d1b97475f6dda300acee84da540938e6-844x466.png" alt="" /><p>3. Retrieve matching employee records</p><p>4. Present results in natural language with proper formatting</p><p>Unlike traditional lexical search, the agent powered by GPT-OSS understands intent and context, making it easier to find information without knowing exact field names or query syntax. For more details on the agent's thinking process, refer to this <a href="https://www.elastic.co/search-labs/blog/ai-agent-builder-experiments-performance">article</a>.</p><h2>Conclusion</h2><p>In this article, we built a custom AI agent using Elastic’s Agent Builder to connect to the OpenAI GPT-OSS model running locally. By deploying both Elastic and the LLM on your local machine, this architecture allows you to leverage generative AI capabilities while maintaining full control over your data, all without sending information to external services.</p><p>We used GPT-OSS 20B as an experiment, but the officially recommended models for Elastic Agent Builder are referenced <a href="https://www.elastic.co/docs/solutions/search/agent-builder/models#recommended-models">here</a>. If you need more advanced reasoning capabilities, there's also the <a href="https://huggingface.co/openai/gpt-oss-120b">120B parameter variant</a> that performs better for complex scenarios, though it requires a higher-spec machine to run locally. For more details, refer to the <a href="https://openai.com/open-models/">official OpenAI documentation</a>.</p>]]></content:encoded>
    <link>https://www.elastic.co/search-labs/blog/build-an-ai-agent-hr-elastic-agent-builder-gpt-oss</link>
    <guid isPermaLink="true">https://www.elastic.co/search-labs/blog/build-an-ai-agent-hr-elastic-agent-builder-gpt-oss</guid>
    <category><![CDATA[Agentic AI]]></category>
    <category><![CDATA[AI]]></category>
    <dc:creator><![CDATA[Tomás Murúa]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt664f490053e46e6b/6a170d13b0367d2d7e72bd84/05d2d0513fff67d975f9223d75108aa9f50646bc-1600x914.png" length="0" type="image/png"/>
    <pubDate>Wed, 26 Nov 2025 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[RAG and the value of grounding in Elasticsearch]]></title>
    <description><![CDATA[Learn about RAG, grounding, and how to reduce hallucinations by connecting an LLM to your documents.]]></description>
    <content:encoded><![CDATA[<p>Large language models (<a href="https://www.elastic.co/what-is/large-language-models">LLMs</a>) are able to generate coherent answers, but when you need real and updated information, they might hallucinate (make up data) and give unreliable answers. To prevent this, we use grounding to provide the models with specialized, use-case-specific, and context-relevant information that goes beyond the LLM’s training.</p><p><em><strong>Grounding</strong></em> is the process by which you connect specific data sources to a model to “ground” it to truthful content instead of only relying on the patterns learned during the model’s training, thus giving more reliable and accurate answers.</p><p>Grounding helps reduce model hallucinations, generate responses based on your data sources, and allows you to examine the answers by providing citations for them.</p><p><a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/_retrieval_augmented_generation.html"><em>Retrieval Augmented Generation</em></a>(RAG) is a <em><strong>grounding</strong></em> technique where you use search algorithms to retrieve relevant information from external sources, then you use that information as context for the LLM, and finally the model uses the augmented context together with their original training data to generate an answer.</p><p>Flow diagram of how RAG works:</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4f44f3376a784119/6a170b718b73cb357818a04f/b542f2e6e2af19e59c8877aa5dfbe3b85c78651b-564x311.png" alt="Flow diagram of how RAG works" /><p>RAG allows you to easily scale by updating or expanding the external data sources the model has access to. It is also a cost-effective <a href="https://www.elastic.co/search-labs/blog/rag-vs-fine-tuning">alternative to fine-tuning</a> LLMs since you can just add data without extensive customization.</p><p>And since RAG can access and utilize up-to-date information, it is ideal for use cases when the latest information is key.</p><h2>Hallucination example</h2><p>For this example, we’ll use DeepSeek and ask, <em><strong>“Who is the author who won the Chilean National Literature Prize in 1932?”</strong></em> This is a tricky question since the prize was created in 1942. Let’s see how the model answers:</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte368ecbb808e84a1/6a170b735091682d2ee1bafa/60f86813a36f7521efce94c55124c3423e3d35ab-1600x699.png" alt="RAG hallucination example" /><p>As you can see, since the AI did not have all the information, it hallucinated and provided a made-up answer. Though the information is real in the sense that both the author and work exist, the other parts of the answer are wrong.</p><p>Now, let’s see how the model does when we ground it using RAG. For this, we will upload the Wikipedia page about the Chilean National Prize for Literature:</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7abceb12479d7a59/6a170b7550916832b7e1bafe/86f8a8cb1e838650bfe946098d595bca0ae56340-1151x1600.png" alt="Grounding a model using RAG based on this document." /><p>Now, let’s ask the same question and check the answer:</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1bfa5bf9368b6a3a/6a170b770c4857204401aaa5/d9907035f53f6270796e88ce32205b907c2b9592-1600x865.png" alt="Asking the model questions to test RAG grounding." /><p>As you can see, with RAG we got the right answer. It says there was no prize in 1932 and asks for clarification from the user.</p><h2>Using RAG in Playground</h2><p>By using Elasticsearch, you can easily scale with only having your cluster capacity as a limit. You can use different data sources and <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/es-connectors.html">connectors</a> to get access to the data you need. Additionally, you have total ownership of your data since it stays in your infrastructure and is not uploaded to a 3rd party service; if you run a local LLM, your data won’t even leave your network. Finally, you have control over search by designing the queries and how to filter data based on access control (<a href="https://www.elastic.co/search-labs/blog/rag-and-rbac-integration">RBAC</a>).</p><p>We will use <a href="https://www.elastic.co/guide/en/kibana/current/playground.html">Playground</a>, our low-code platform that allows you to quickly and simply create a RAG application using your Elasticsearch content.</p><p>Here’s a step-by-step guide on <a href="https://www.elastic.co/search-labs/blog/chat-with-pdf-elastic-playground">how to upload your PDFs or other documents into Playground</a>. You can also read more about it here and try Playground <a href="https://www.elastic.co/demo-gallery/ai-playground">here</a>.</p><h3>Upload the PDF</h3><p>We’ll index into Kibana the <a href="https://en.wikipedia.org/w/index.php?title=Special:DownloadAsPdf&amp;page=National_Prize_for_Literature_%28Chile%29&amp;action=show-download-screen">same PDF file</a> we provided to DeepSeek. If you followed the instructions in <a href="https://www.elastic.co/search-labs/blog/chat-with-pdf-elastic-playground">the article above</a> and created the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/semantic-search-semantic-text.html">semantic_text</a> field, you’ll be creating a <a href="https://www.elastic.co/what-is/vector-database">vector database</a> with its corresponding <a href="https://www.elastic.co/what-is/vector-embedding">embeddings</a>, ready to be used.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7b8b8fd1584e8f45/6a170b79a929cf0c49ae09e6/8776e1b83e3e042dd3150f706de3cd15af65dcd5-1600x1002.png" alt="Uploading the sample PDF for RAG to Elasticsearch Playground." /><h3>Ask the question</h3><p>Ask the following question:</p><p><em><strong>“Who is the author who won the Chilean National Literature Prize in 1932?”</strong></em></p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd2824a121c0c0416/6a170b7aacf0881ccebe9b7c/382655b7858c525a36ce540c6b28bfc725703e00-765x1125.png" alt="Asking a RAG question in Elasticsearch Playground." /><p>Playground sends this query to Elasticsearch, which in turn, runs a <a href="https://www.elastic.co/what-is/semantic-search">semantic search</a> and localizes the fragments with information that is relevant to the question. Then, these fragments are included as context in the prompt sent to the LLM to ground the answer to the information source we provided.</p><p>Finally, Playground generated an answer saying that <strong>there was no prize</strong> in 1932 and provides citations for the relevant fragments as evidence.</p><p>Playground also offers two very useful features to understand the RAG system underlying components:</p><h3>Query</h3><p>You can see the query Elasticsearch is running to retrieve the relevant documents, and you can enable/disable fields based on your needs.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blta24ee951f7df3924/6a170b7c4a531b153336a979/ec02d879a850d3d5519cf68391a39f0e0cd992ac-1440x534.png" alt="How Elasticsearch runs a query to retrieve relevant documents for RAG." /><h3>View code</h3><p>If you can deploy your RAG application, Playground got you covered. Under the View Code tab, you can see the code used under the hood to create the entire RAG workflow. You can choose between two Python alternatives: Elasticsearch Client with <em><strong>OpenAI</strong></em>, or a <em><strong>Langchain</strong></em> based implementation.</p><p>If you want to customize the experience and deploy the code elsewhere, you can use this snippet as a starting point.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt5055df7029dee861/6a170b7ea929cffc90ae09ec/04b092ef3b75f97efffce96daecfccdce36d9e06-1439x954.png" alt="Deploying a RAG application in Elasticsearch Playground." /><h2>Conclusion</h2><p>Grounding is a process that connects LLMs to external data sources so they can go beyond their training to provide more accurate and trustworthy answers. Retrieval Augmented Generation (RAG) is a grounding method that is scalable, cost-effective, and ensures access to up-to-date information.</p><p>Tools like Playground simplify RAG implementation by enabling large-scale indexing, customized searches, and responses with citations, which allow you to easily verify an answer and make sure you’re getting accurate and trustworthy results.</p><p>If you want to read more in-depth articles about RAG features, you can start with this one to get a <a href="https://www.elastic.co/search-labs/blog/retrieval-augmented-generation-rag">more technical definition of RAG</a>. You can also check <a href="https://www.elastic.co/search-labs/blog/rag-vs-fine-tuning">Rag vs. fine-tuning: When RAG is the best decision</a>, <a href="https://www.elastic.co/search-labs/blog/sharepoint-federated-searches-azure">How to leverage document security using RAG</a> and <a href="https://www.elastic.co/search-labs/blog/advanced-rag-techniques-part-2">RAG systems in production</a>.</p>]]></content:encoded>
    <link>https://www.elastic.co/search-labs/blog/grounding-rag</link>
    <guid isPermaLink="true">https://www.elastic.co/search-labs/blog/grounding-rag</guid>
    <category><![CDATA[AI]]></category>
    <dc:creator><![CDATA[Tomás Murúa]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt54210f630536d9bf/6a170b806234e080a5db1a01/8f02b6b264d8a26be3ae983a8f6d2013a21835a2-1324x742.png" length="0" type="image/png"/>
    <pubDate>Thu, 01 May 2025 00:00:00 GMT</pubDate>
  </item>
  </channel>
</rss>