This program processes PDF documents in a specified location, stores them in an Cloudera Semantic Search(CSS) with vector embeddings, and enables users to query the data with a pre-trained language model, using CSS for search and retrieval and Azure OpenAI for generating responses based on the retrieved context. Embedding is generated with in CSS using Neural search pipeline feature.
- This demo needs nodes having following roles
- data
- ingest
- ml
- Python 3.8+
- **Cloudera Semantic Search server with endpoints
- Azure OpenAI credentials for query processing with the LLM
Set the following environment variables in your shell or .env
file before running the program.
- CSS Connection
CSS_HOST
: Host address of the Cloudera Semantic Search server (default:localhost
)CSS_PORT
: Port of the OpenSearch server (default:9200
)CSS_USER
: Username for OpenSearch authenticationCSS_PASSWORD
: Password for OpenSearch authenticationDATA_FILE_PATH
: PDF files to load (default:./data
)CSS_OPENAI_KEY
: Azure OpenAI keyCSS_OPENAI_VERSION
: OpenAI model versionCSS_OPENAI_MODEL
: OpenAI model for LLM ChatCSS_OPENAI_ENDPOINT
: OpenAI model servicing EndpointCSS_SSL
: True if SSL is enabled for CSS connection
- Install Dependencies:
Install the necessary packages by running:
pip3 install -r session-install-deps/requirements.txt
-
Start the OpenSearch Server: Ensure your Cloudera Semantic search server is running and accessible at the host and port specified in the environment variables.
-
Run the Script: Start the following job for loading the data:
python css_load.py
This will:
- Connect to CSS
- Process and store PDF documents from the specified directory. Currently there is one Cloudera Operationa Database document in the PDF format. One can add more to the same directory.
Start the following Application for brining up the search UI:
python search_app.py
RUn the following Application to do cleanup of index , neural pipeline and model:
python clenaup.py
This will:
- Connect to CSS
- Deletes index, neural pipeline, undeploys and deletes the embedding model.
- Querying the System:
- The Gradio UI provides an interface for users to enter a query. Upon submission, it:
- Converts the query into a vector and searches for similar document chunks in CSS through neural search feature of CSS.
- Feeds the retrieved context to Azure OpenAI to generate an answer.
- Displays the answer along with chunks of the original document chunks.
- Displays Index settings, mappings and neural pipeline definitions used.
- The Gradio UI provides an interface for users to enter a query. Upon submission, it: