Quick start: Build an intelligent search service
This tutorial shows you how to build an intelligent search service using the multi-modal capabilities of Lindorm, such as hybrid full-text and vector retrieval.
Overview
Intelligent search is a new type of retrieval method powered by large models. By deeply understanding user intent, it provides precise, efficient, and conversational question-answering services.
This solution helps you quickly build intelligent search capabilities to address the following key challenges:
Efficient setup and iteration: Get started without building from scratch. This solution provides out-of-the-box infrastructure that lowers the technical barrier and saves on development and O&M costs.
Handle data growth: Supports large-scale data processing and optimizes retrieval performance, reducing hardware investment and operational pressure.
Improve retrieval accuracy and flexibility: Supports custom model deployment and fine-tuning to meet specific business needs and ensures that search results are more relevant to your use cases.
This solution allows you to focus on core business innovation while delivering a smarter and more efficient search experience.
Architecture
This document uses Python code to demonstrate how to build an intelligent search service by using Lindorm's hybrid full-text and vector retrieval capabilities. The following architecture diagram shows only the components related to Lindorm deployment and application.
Step 1: Activate Lindorm's multi-modal capabilities
Log in to the Lindorm console.
In the upper-left corner of the page, click Create.
On the Lindorm purchase page, configure the following parameters:
Parameter
Description
Product Type
Select Lindorm.
Instance configuration
Select Wide Table Engine, LTS Engine, Search Engine, Vector Engine, and AI Engine.
NoteWhen you activate the AI engine, you must also select a DashScope model.
The vector engine depends on the search engine. You must activate both at the same time.
For details about creating an instance and its parameters, see Create an instance.
You can change the specifications and nodes of the instance based on your business requirements. For more information, see Change instance specifications.
Click Buy Now and follow the instructions on the purchase page to complete the payment.
Step 2: Configure an IP address whitelist
Add your client's IP address to the Lindorm IP address whitelist. To set the whitelist, see Set an IP address whitelist.
Step 3: Download the code
Download the code sample lindorm_smart_search to configure and build your intelligent search service.
Step 4: Configure the environment
Runtime environment
Make sure that you have installed Python 3.10 or later.
Install dependencies
pip3 install -r requirements.txt Configure Lindorm endpoints
Configure the connection endpoints for Lindorm engines in the env script of the downloaded code. For information about how to obtain the connection endpoints, see View connection endpoints.
# AI host (Configure the AI engine endpoint)
AI_HOST="ld-bp17j28j2y7pm****-proxy-ai-pub.lindorm.aliyuncs.com"
AI_PORT="9002"
# Row host (Configure the MySQL-compatible endpoint for the wide-column engine)
ROW_HOST="ld-bp17j28j2y7pm****-proxy-lindorm-pub.lindorm.aliyuncs.com"
ROW_PORT="33060"
# Search host (Configure the search engine endpoint)
SEARCH_HOST="ld-bp17j28j2y7pm****-proxy-search-pub.lindorm.aliyuncs.com"
SEARCH_PORT="30070"
# Lindorm user password (Configure the Lindorm user password)
LD_USER="root"
LD_PASSWORD="test****"
# Location of the training dataset
LOAD_FILE_PATH="data/cmrc2018_train.json"
# Maximum number of results to return
SEARCH_TOP_K="5"Install Jupyter Notebook
Install Jupyter.
pip3 install jupyterGenerate the configuration file
~/.jupyter/jupyter_notebook_config.py.jupyter notebook --generate-configGenerate a password hash for Jupyter access.
from passlib.hash import argon2 print(argon2.hash('Vector123'))The output is the password hash for the Jupyter Notebook configuration. The following is a sample output:
$argon2id$v=19$m=65536,t=3,p=4$4TyndM75H8N4b+291xqjdA$n0QSxlv/uCLjGR0TX/jbD/XFlEu9BzQGI1b2Mcu6gxgRun the
vim ~/.jupyter/jupyter_notebook_config.pycommand to open and edit the configuration file.# Add the following configurations at the end of the file. c.NotebookApp.ip = '*' # Specify the default directory for the notebook. # Whether to open a browser upon notebook startup. Set to False. c.NotebookApp.open_browser = False # The default access port. You can change this. c.NotebookApp.port = 9000 # Replace the content after argon2 with the Jupyter password hash obtained in the previous step. c.NotebookApp.password = 'argon2:$argon2id$v=19$m=65536,t=3,p=4$4TyndM75H8N4b+291xqjdA$n0QSxlv/uCLjGR0TX/jbD/XFlEu9BzQGI1b2Mcu6gxg' # Important: Files accessed in Jupyter must be in this directory. c.NotebookApp.notebook_dir = u'/data/lindorm/LindormDemo' # Set the desired display location when you open Jupyter Notebook. You can set it to a frequently used path.Start the Jupyter service. Start it in the foreground to check for any startup errors. To stop the service, press
Ctrl+Cto terminate the process.jupyter notebookNoteIn a production environment, run the Jupyter service in the background. This prevents interruptions if the terminal is closed and simplifies process management. To start in the background, run the following command:
nohup jupyter notebook --allow-root >/tmp/jupyter.log 2>&1 &.
Step 5: Run the .ipynb script
In Jupyter, follow the instructions in lindorm_demo.ipynb and execute the code cells sequentially.
The following sections describe the main deployment steps in detail.
Deployment workflow
Deployment steps
Step | Description | Engines involved |
Create a parent table (knowledge base) | Create a parent table to store the original text of the knowledge base. | wide-column engine |
Create a child table (split knowledge base) | Create a child table to store the text chunks after splitting the original text. You can split the text by length or by a combination of length and punctuation. | wide-column engine |
Create a search pipeline | Create an ingest pipeline and a search pipeline for the child table. During ingestion, the child table content is automatically synced to the search engine. The search engine generates embeddings and then writes the results to the vector engine. During a query, the text is automatically embedded, and vector retrieval is performed through the vector engine. | wide-column engine search engine vector engine |
Create search and vector indexes | Create search and vector indexes to improve retrieval efficiency. This example uses an IVFBQ index. If your dataset is small, you can use an HNSW index. | wide-column engine search engine vector engine |
Configure pipelines for the search index | Configure the default ingest and search pipelines for the search index. | search engine vector engine |
Build a vector index | For IVFPQ and IVFBQ indexes, you must manually trigger an index build after writing a sufficient amount of data. Once the build is complete, you can write and query data without needing to rebuild. For more information, see Build an index. | full-text index vector index |
Retrieval methods
Retrieval options: Full-text retrieval, vector retrieval, or hybrid full-text and vector retrieval.
Reranking: With or without reranking.
Prompt context: Use the original parent document or the retrieved text chunks.
Retrieval method | Description | Workflow |
Hybrid full-text and vector retrieval | Combines results from both full-text and vector retrieval. | |
Hybrid full-text and vector retrieval + reranking | Performs a hybrid retrieval and then reranks the results. | |
Hybrid full-text and vector retrieval + reranking + prompt |
| |
Hybrid full-text and vector retrieval + reranking + Context Prompt |
|