Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# Elasticsearch Labs
# Elasticsearch Labs

This repository contains several sample applications for demonstrating the features of Elasticsearch and Elasticsearch Relevance Engine (ESRE) to build modern conversational search experiences powered by generative AI.
Elasticsearch is a distributed RESTful search and analytics platform at the heart of our [ESRE](https://www.elastic.co/enterprise-search/generative-ai) capabilities.
This repository contains executable Python notebooks, sample apps, and resources for testing out the Elastic platform:

- Learn how to use Elasticsearch as a vector database to store embeddings, power hybrid and semantic search experiences, and more.
- Test Elastic's leading-edge, out-of-the-box capabilities like the [Elastic Learned Sparse Encoder](https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-elser.html) and [reciprocal rank fusion (RRF)](https://www.elastic.co/blog/whats-new-elastic-enterprise-search-8-9-0#hybrid-search-with-reciprocal-rank-fusion-(rrf)-combines-multiple-search-techniques-for-better-results), which produce best-in-class results without training or tuning.
- Integrate with projects like OpenAI, Hugging Face, and LangChain to use Elasticsearch as the backbone of your LLM-powered applications. For use cases like retrieval augmented generation (RAG), summarization, and question answering (QA).

# Python notebooks 📒

The [`notebooks` folder](notebooks/README.md) contains a range of executable Python notebooks, so you can test these features out for yourself. Colab provides an easy-to-use Python virtual environment in the browser.

# Example apps 💻

The [`example-apps`](example-apps/README.md) folder contains example apps that demonstrate Elasticsearch for a number of use cases, using different programming languages and frameworks.

# Support 🛟

Learn how to [get Support](docs/SUPPORT.md).

# License ⚖️

# Guides
- [Getting Support](docs/SUPPORT.md)

# License
This software is licensed under the [Apache License, version 2 ("ALv2")](https://github.com/elastic/elasticsearch-labs/blob/main/LICENSE).
Empty file removed colab-notebooks-examples/index.md
Empty file.
11 changes: 0 additions & 11 deletions esre-examples/README.md

This file was deleted.

33 changes: 33 additions & 0 deletions example-apps/ElasticDocs_GPT/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# ElasticDocs GPT

Combine the search power of Elasticsearch with the Question Answering power of GPT.

This application supports the popular Elastic blog [ChatGPT and Elasticsearch: OpenAI meets private data](https://www.elastic.co/blog/chatgpt-elasticsearch-openai-meets-private-data).

## Overview

The following diagram shows the high level architecture of the application:

![diagram](https://raw.githubusercontent.com/jeffvestal/ElasticDocs_GPT/main/images/ElasticChat%20GPT%20Diagram%20-%20No%20line%20text.jpeg)

1. A **Python interface** accepts user questions
- Generates a hybrid search request for Elasticsearch
- BM25 match on the `title` field
- kNN searches on the `title-vector` field
- Boost `kNN` search results to align scores
- Set `size=1` to return only the top scored document
2. **Search request** is sent to Elasticsearch
3. **Documentation body and original url** are returned to Python
4. **API call** is made to OpenAI ChatCompletion with the prompt:
- _"answer this question <question> using only this document <body_content from top search result>"_
5. **Generated response** is returned to Python
6. Python adds **original documentation source url** to generated response and **prints it to the screen** for the user

# Examples
![autoscale](https://raw.githubusercontent.com/jeffvestal/ElasticDocs_GPT/main/images/elasticDocs%20GPT%20-%20elastic%20cloud%20autoscaling.png)

![apm](https://raw.githubusercontent.com/jeffvestal/ElasticDocs_GPT/main/images/elasticDocs%20GPT%20-%20elastic%20jvm%20apm.png)

![inference](https://github.com/jeffvestal/ElasticDocs_GPT/blob/main/images/elasticDocs%20GPT%20-%20inference%20processor.png)

![pii](https://raw.githubusercontent.com/jeffvestal/ElasticDocs_GPT/main/images/elasticDocs%20GPT%20-%20redact%20pii.png)
19 changes: 19 additions & 0 deletions example-apps/ElasticGPT_Plugin/README.md

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could clarify how our two docs GPT example apps relate. This one is for those who want to use the ChatGPT UI, while the other is for those who want to use the GPT API with their own UI.

Copy link
Contributor Author

@leemthompo leemthompo Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I can clarify this in the individual readmes and the overall example-apps readme.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to follow-up PR

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ElasticGPT plugin

Implement a ChatGPT plugin and extend ChatGPT usage to any content indexed into Elasticsearch:

- Implement a ChatGPT plugin that allows access to Elasticsearch data for context-relevant responses.
- ChatGPT plugins are extensions developed to assist the model in completing its knowledge or executing actions.
- The plugin architecture involves making a call to the `/search` endpoint of the plugin, which sends a search request to Elasticsearch.
- The plugin then returns the document body and URL to ChatGPT, which uses this information to craft its response.
- Deployment of the plugin on Google Cloud Platform (GCP) is demonstrated using Cloud Run.
- Users can install the plugin in ChatGPT and query Elasticsearch data to enhance ChatGPT's knowledge and functionality.

For full details refer to the original Elastic Blog Post:

- [ChatGPT and Elasticsearch: A plugin to use ChatGPT with your Elastic data](https://www.elastic.co/blog/chatgpt-elasticsearch-plugin-elastic-data)


> ℹ️ **Note**:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like something we'd want to include for all READMEs or move up higher in the hierarchy to cover everything?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move up higher in the hierarchy to cover everything?

🎯

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to follow-up PR

> _This is an Elastic Labs project. Elastic Labs projects are for illustrative and experimental purposes only. This Elastic Labs project is not part of any product or services offering provided or supported under a commercial license or subscription. This project is made available as-is under the terms of the license associated with this project._
> _The release and timing of any features or functionality described in this project remain at Elastic's sole discretion. Any features or functionality not currently available may not be delivered on time or at all._
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Elastic OpenAI integration example - JavaScript
# Elastic OpenAI embeddings example - JavaScript

## Overview

Expand Down Expand Up @@ -26,7 +26,7 @@ Download the project from Github and extract the openai-integration-example-pyth

```bash
curl https://codeload.github.com/elastic/elasticsearch-labs/tar.gz/main | \
tar -xz --strip=2 elasticsearch-labs-main/esre-examples/openai-integration-example-javascript
tar -xz --strip=2 elasticsearch-labs-main/example-apps/OpenAI-embeddings/OpenAI-Py
```

### 2. Create OpenAI account and API key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Download the project from Github and extract the openai-integration-example-pyth

```bash
curl https://codeload.github.com/elastic/elasticsearch-labs/tar.gz/main | \
tar -xz --strip=2 elasticsearch-labs-main/esre-examples/openai-integration-example-python
tar -xz --strip=2 elasticsearch-labs-main/example-apps/OpenAI-embeddings/OpenAI-Py
```

### 2. Create OpenAI account and API key
Expand Down
14 changes: 14 additions & 0 deletions example-apps/OpenAI-embeddings/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Overview

Tiny example applications that integrate Elastic with [OpenAI embeddings](https://platform.openai.com/docs/guides/embeddings):

- Process JSON files
- Generate text embeddings using OpenAI [embeddings API](https://platform.openai.com/docs/api-reference/embeddings)
- Store data in Elasticsearch
- Run semantic search in web app using Elasticsearch kNN search
- Return relevant search results

## Programming languages

- [Python](./OpenAI-Py/README.md)
- [JavaScript](./OpenAI-JS/README.md)
14 changes: 14 additions & 0 deletions example-apps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Elasticsearch example apps

## Overview

The following example apps demonstrate Elasticsearch for a variety of use cases, such as semantic search and retrieval augmented generation, using different programming languages and frameworks.

Use these apps as a starting point for your own projects.

## Apps

- [ElasticDocs GPT](./ElasticDocs_GPT/README.md). Combine Elasticsearch with the question answering power of ChatGPT.
- [ElasticGPT plugin](./ElasticGPT_Plugin/README.md). Implement a ChatGPT plugin and extend ChatGPT usage to any content indexed into Elasticsearch.
- [OpenAI embeddings](./OpenAI-embeddings/README.md). Use OpenAI embeddings at index time and in Elastic kNN queries. Available in [JavaScript](./OpenAI-embeddings/OpenAI-JS/README.md) and [Python](./OpenAI-embeddings/OpenAI-Py/README.md) versions.
- [Workplace search](./Workplace-Search/README.MD). Build a semantic search experience for organizational/workplace data.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ This is a sample app that combines Elasticsearch and OpenAI to create a semantic

## 1. Download the Project

Download the project from Github and extract the python-flask-example folder.
Download the project from Github and extract the Workplace-Search folder.

```bash
curl https://codeload.github.com/elastic/elasticsearch-labs/tar.gz/main | \
tar -xz --strip=2 elasticsearch-labs-main/esre-examples/python-flask-example
tar -xz --strip=2 elasticsearch-labs-main/example-apps/Workplace-Search
```
```

## 2. Index Data
Expand Down
29 changes: 0 additions & 29 deletions gai-examples/ElasticDocs_GPT/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions gai-examples/ElasticGPT_Plugin/README.md

This file was deleted.

20 changes: 20 additions & 0 deletions notebooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Python notebooks 📒

This folder contains a range of executable Python notebooks, so you can test everything out for yourself. Use these examples as a blueprint for testing on your own data.

Run notebooks locally using [Jupyter](https://jupyter.org/install), or use the links provided in each notebook to run them in Google [Colab](https://colab.research.google.com).
Colab provides an easy-to-use Python virtual environment in the browser.

Notebooks are organized into the following folders:

- [`search`](./search/). Learn the fundamentals of Elasticsearch, so you can index embeddings, run lexical, semantic and _hybrid_ searches, and more.

- [`generative-ai`](./generative-ai/): Notebooks that demonstrate various use cases for Elasticsearch as the retrieval engine and vector store for LLM-powered applications.

- [`integrations`](./integrations/): Notebooks that demonstrate how to integrate popular services and projects with Elasticsearch:
- [OpenAI](./integrations/openai)
- [Hugging Face](./integrations/hugging-face)
- [LlamaIndex](./integrations/llama-index)

- [`langchain`](./langchain/): Notebooks that demonstrate how to integrate Elastic with [LangChain](https://langchain-langchain.vercel.app/docs/get_started/introduction.html), a framework for developing applications powered by language models.

File renamed without changes.