Use a private or external model

Updated at:
Copy as MD

Milvus knowledge base lets you add your own OpenAI-compatible model service as the embedding model, whether the service is deployed in a VPC or accessed on the Internet. Add the model first, and then bind it when you create a knowledge base.

Scenarios

  • Model service deployed in a VPC — Use an embedding model deployed in your VPC as the embedding model of a knowledge base.

  • Model service on the Internet — Allow the knowledge base to access a model service on the Internet.

Limits

  • Protocol — Only model services that use the OpenAI-compatible protocol can be added.

  • Model type — When you create a knowledge base, you can bind only models whose Model type is embedding. Models added with the chat type do not appear in the embedding model list.

  • Visibility — Added models are visible only within the current Alibaba Cloud account and are not shared across accounts.

  • Model binding — The Embedding model of a knowledge base cannot be changed after creation. Add the model before you create the knowledge base.

Billing

Fees for calling the model service are charged by the model service provider and are not included in knowledge base fees.

Information to prepare

Before you add a model, prepare the following information.

Configuration itemDescription
Access typeOnly OpenAI compatible is supported.
EndpointThe address of the model service. The service must support the OpenAI-compatible protocol. The endpoint must match the address that the model service actually provides.
Model nameThe name used to call the model. It must match the name that the model service actually provides.
Model typeTo use the model for knowledge base vectorization, select Embedding. The default value of the form is Chat. Change it as needed.
API KeyThe authentication key used to call the model service.
Network settingsThe VPC ID, Zone, vSwitch ID, and Security group ID from which the model service can be accessed.

Choose the network settings based on where the model service is deployed:

  • Model service deployed in a VPC — Specify the network where the model deployment resides. Make sure that the security group allows Knowledge Base Service to access the model service, and that the vSwitch belongs to the selected zone.

  • Model service on the Internet — Specify a network that has public network access.

Note

If the selected VPC does not have Internet access, create an Internet NAT gateway first. For more information, see Use an Internet NAT gateway to access the Internet.

Step 1: Add a model

  1. Log on to the Alibaba Cloud Milvus console. In the region drop-down list at the top, select the target region, and then click Knowledge Base Service in the left-side navigation pane.

  2. In the upper-right corner of the knowledge base list, click the More icon, and then click Private/External model.

    Note

    This entry is available only under the More icon in the upper-right corner of the knowledge base list page. It is not in the left-side navigation pane, and it is not on the knowledge base creation page or details page.

  3. In the Private/External model provisioning panel, click Add model.

  4. Enter the model information, and then click OK.

    • Access type: Select OpenAI compatible.

    • Endpoint: Enter the address of the model service.

    • Model name: Enter the name of the model to call.

    • Model type: Select Embedding.

    • API Key: Enter the authentication key of the model service.

    • VPC ID, Zone, vSwitch ID, and Security group ID: Enter the network settings from which the model service can be accessed.

    Note

    You must select a VPC ID before you can select a Zone, a vSwitch ID, and a Security group ID. Otherwise, all three fields display Select a VPC first.

    Warning

    The API Key is sensitive information. Do not write it into tickets, logs, or public documents.

  5. After the model is added, verify that its Status in the Private/External model provisioning panel is Available.

Important

A status of Available only means that the configuration is saved. It does not mean that the connection to the model service is established. Before you create a knowledge base, manually make an embedding call with the same endpoint and API key from the same network environment as the model to confirm that the model service is reachable.

Step 2: Create a knowledge base and bind the model

  1. On the knowledge base list page, click Create Knowledge Base.

  2. Enter a Name and select a Data type.

  3. In the Embedding model section, switch to Private/External model, and then select the model added in Step 1 from the drop-down list.

    Note

    The drop-down list shows only models whose Model type is embedding. After you select Private/External model, Vector dimensions shows - and cannot be edited. This does not affect creation.

  4. Select a Specification and Network settings, and then click Create Knowledge Base.

  5. Wait until the knowledge base Status changes from Creating to Running.

    After the knowledge base is created, both data vectorization and retrieval use the bound model. The system automatically delivers the network settings required for the knowledge base to access the model service.

Step 3: Verify that the model works

Import data into the knowledge base and run a search to verify that the bound model works.

  1. Import a document. For import methods, see Build a personal knowledge Q&A application.

  2. On the knowledge base details page, confirm that Documents and Chunks both increased. A chunk count greater than 0 means that the data is parsed and vectorized, which means the model call succeeded.

  3. On the Search validation tab, or by calling SearchKnowledgeBase, run a query and confirm that the expected chunks are returned. The query is also vectorized by the same model during retrieval.

Important

If the data stays in processing for a long time or the chunk count remains 0, the model call failed. For troubleshooting, see FAQ.

FAQ

The model is added, but knowledge base data fails to be parsed or the chunk count is 0. How do I troubleshoot?

A status of Available in the Private/External model provisioning panel only means that the configuration is saved. It does not mean that the connection is established. Troubleshoot in the following order:

  1. From the same network environment as the model, manually make an embedding call with the same endpoint and API key to confirm that the model service itself is available.

  2. Confirm that the endpoint is reachable and that the model service is compatible with the OpenAI embedding API protocol.

  3. Confirm that the API key is valid and has not expired.

  4. Confirm that the security group allows Knowledge Base Service to access the model service.

  5. Confirm that the Zone and vSwitch ID are selected correctly. The vSwitch must belong to the selected zone.

  6. If you call a model service on the Internet, confirm that the selected VPC has Internet access.

Why does the added model not appear when I create a knowledge base?

Confirm that the Model type of the model is embedding. The Embedding model drop-down list automatically filters out models of the chat type. The Model type cannot be changed after the model is added. Add another model of the embedding type.

Can I change the embedding model of an existing knowledge base?

No. The Embedding model is determined when the knowledge base is created and cannot be changed. To use a different model, create a new knowledge base and import the data again.