ESRE examples

edit

The following examples demonstrate how to implement ML- and AI-powered applications using ESRE.

The code for these applications is hosted on Elasticsearch Labs.

Knowledge base search with GPT question answering

edit

This Python Flask + React application demonstrates how to implement an internal knowledge base with a natural language interface allowing members of your organization to ask questions.

Details

When a question is submitted, the UI immediately returns semantic search results powered by the Elastic Sparse Encoder model and BM25 text search. Results are rescored using RRF to improve relevance.

Simultaneously, the UI streams an answer to the user’s question. The answer is generated by OpenAI GPT using excerpts from the search results as context for the chat completion.

example knowledge base gpt

View the source code on Elastic Labs →

Vector search using OpenAI embeddings

edit

This example demonstrates how to create and search vector embeddings using Elastic and OpenAI. The solution is available in Python and JavaScript.

Details

The Python and JavaScript examples each provide a script for indexing data, and a search application with a dev server.

The indexing script passes JSON documents to OpenAI to create embeddings, which are persisted to Elasticsearch as additional fields in the original documents.

The search application passes each user query to OpenAI to create embeddings, which Elasticsearch uses to perform kNN search.

example vector openai

View the Python source code on Elastic Labs →

View the JavaScript source code on Elastic Labs →

Documentation GPT chat UI

edit

This Python application implements a chat UI, enabling users to ask questions about a set of documentation (in this case, the Elastic docs).

Details

For each user question, the application retrieves relevant documents from Elasticsearch, providing them to Open AI GPT to generate an answer. The solution uses hybrid search (text + vector) to improve relevance.

The UI returns the generated answer and a link to the original document from which the answer was derived.

example documentation gpt

Read the blog post →

View the source code on Elastic Labs →

ChatGPT plugin using private Elastic data

edit

This ChatGPT plugin enables ChatGPT to use private data stored in Elastic to answer user questions.

Details

ChatGPT has limited access to data for chat completion. This example builds a plugin that enables an additional data source for ChatGPT: your Elastic cluster.

Use this option to access your Elastic data through the ChatGPT interface, rather than building a separate chat application.

example chatgpt plugin

Read the blog post →

View the source code on Elastic Labs →