Creating a vector index

You can create a vector index asset in your project or the Prompt Lab to retrieve content from documents stored in a vector data store.

Before you begin

If you signed up for watsonx.ai and you have a sandbox project, all requirements are met.

You must meet the following requirements:

Procedure

To create a vector index for your grounding documents, complete the following steps. The order of the steps might differ slightly based on the vector store you choose to use.

  1. From the project overview, click the Assets tab, and then choose New asset > Ground gen AI with vectorized documents.

    Alternatively, you can start from the Prompt Lab in chat mode by clicking the Grounding with documents icon Grounding with documents icon, and then clicking Select or create vector index.

  2. Choose the vector store that you want to use and name the vector index asset.

  3. Add grounding documents in one of the following ways:

    • Add files from a data asset that is associated with your project

    • Browse to upload files from your file system

    • For external vector stores only: You can use existing content from the connected vector store or add new content to the connected vector store.

      Select the connected data source, choose a database if applicable, and then click Next. Choose an existing index or collection in the vector store that contains files that you want to use. To add new content click New index or New collection, specify a name, and then add documents by uploading files or connecting to a data asset.

    • Optional: If applicable, choose the embedding model or vectorization settings that you want to use to vectorize your documents.

    The supported file types for grounding documents differ by vector store.

    For details about the various configuration options, see Vector index settings.

  4. For external vector stores only: Map fields from your existing index or collection to new fields that are defined in the vector index asset in watsonx.ai. For details, see Mapping fields in the vector store schema.

  5. Click Create.

    The text in the file is vectorized and the vectors are indexed and stored in a new vector index asset.

    When you add new content to a connected third-party data store, the following assets are created:

    • A notebook asset that runs in a job to vectorize the documents and build the index or collection in the third-party data store.
    • A vector index asset that can pass submitted queries to the index or collection in the third-party data store and get search results.

Testing and updating the vector index asset

After the vector index asset is created, you can test how well the vectorized documents can answer questions, and make any necessary adjustments.

  1. From the Prompt Lab in chat mode only: Click the Grounding with documents icon Grounding with documents icon, select the vector index, and then click View vector index details.

  2. From the vector index asset details page, click the Test tab and submit test queries to view the document passages that are returned from the connected vector index.

  3. If a search returns bad answers, adjust query settings to improve responses.

    • To control the number and types of search results to include in the prompt as contextual information, click Edit search settings. For details about how to customize the search results retrieval, see Vector index search settings.

    • If answers are missing or incomplete, review the chunk size and overlap settings to help ensure that the document is being indexed properly. Click Edit vector index, and then expand Advanced settings. Review the current embedding settings and make any necessary changes.

    Tip:

    You can also adjust the foundation model parameters for prompting in Prompt Lab to improve answers. Although you must clear the chat text before you can edit the foundation model parameters, any documents that were uploaded continue to be associated with the chat. For more information, see Model parameters for prompting.

  4. When a query that you enter to search the vector index returns accurate contextual information, you can click Add as sample question to save the query.

    Saved sample questions are displayed as quick start samples from chat mode in the Prompt Lab whenever this vector index asset is associated with a prompt.

    Screenshot that shows the sample question, What is the main goal of these guidelines, being displayed in Prompt Lab.

What to do next

After experimenting with retrieval-augmented generation (RAG) patterns that use your document set, save the prompt logic in a notebook so that you can use it in your generative AI application.

When you save the prompt as a notebook, select the Deployable gen AI flow option. The notebook that is generated provides Python code for the prompt template and a deployable Python function that can be consumed by REST APIs. For more information, see Saving your work.

Learn more