Skip to content

Commit d303541

Browse files
authored
LLM functions for intelligent query (#402)
1 parent 61e7925 commit d303541

File tree

2 files changed

+1179
-0
lines changed

2 files changed

+1179
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
# Unifying Elastic Vector Database and LLMs for Intelligent Retrieval
3+
4+
## Overview
5+
This notebook demonstrates how to integrate Elasticsearch as a vector database (VectorDB) with search templates and LLM functions to build an intelligent query layer. By leveraging vector search, dynamic query templates, and natural language processing, this approach enhances search precision, adaptability, and efficiency.
6+
7+
## Features
8+
- **Elasticsearch as a VectorDB**: Efficiently stores and retrieves dense vector embeddings for advanced search capabilities.
9+
- **Search Templates**: Dynamically structure queries by mapping user inputs to the appropriate index parameters.
10+
- **LLM Functions**: Extract key search parameters from natural language queries and inject them into search templates.
11+
- **Hybrid Search**: Combines structured filtering with semantic search to improve search accuracy and relevance.
12+
13+
## Components
14+
- **Geocode Location Function**: Converts location names into latitude and longitude for geospatial queries.
15+
- **Handle Extract Hotel Search Parameters Function**: Processes extracted search parameters, ensuring essential values like distance are correctly assigned.
16+
- **Call Elasticsearch Function**: Executes structured search queries using dynamically populated search templates.
17+
- **Format and Print Messages Functions**: Enhances query debugging by formatting and displaying responses in a structured format.
18+
- **Run Conversation Function**: Orchestrates interactions between user queries, LLM functions, and Elasticsearch search execution.
19+
- **Search Template Management Functions**: Defines, creates, and deletes search templates to optimize query processing.
20+
21+
22+
## Usage
23+
1. Set up an Elasticsearch cluster and ensure vector search capabilities are enabled.
24+
2. Define search templates to map query parameters to the index schema.
25+
3. Use LLM functions to extract and refine search parameters from user queries.
26+
4. Run queries using the intelligent query layer to retrieve more relevant and accurate results.
27+
28+
29+
### Prerequisites
30+
- Elastic Cloud instance
31+
- With ML nodes
32+
- Azure OpenAI
33+
- Completions endpoint such as GPT-4o
34+
- For more information on getting started with Azure OpenAI, check out the official [Azure OpenAI ChatGPT Quickstart](https://learn.microsoft.com/en-us/azure/ai-services/openai/chatgpt-quickstart?tabs=command-line%2Ctypescript%2Cpython-new&pivots=programming-language-studio).
35+
- Azure OpenAI Key
36+
- Google Maps API Key
37+
- https://developers.google.com/maps/documentation/embed/get-api-key
38+

supporting-blog-content/unifying-elastic-vector-database-and-llms-for-intelligent-query/Unifying_Elastic_Vector_Database_and_LLMs_for_Intelligent_Query.ipynb

+1,141
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)