All Products
Search
Document Center

Platform For AI:Use LangStudio and RAG to create an intent recognition application flow

Last Updated:May 09, 2025

This topic describes how to use LangStudio to create an Intent Recognition Customer Service application flow. This application flow integrates intent recognition with Retrieval-Augmented Generation (RAG) to enable the model service to accurately identify user intents, quickly understand and categorize user needs, and deliver efficient customer services. Developers can use this application flow as a template to extend or customize it for specific business requirements.

Background information

In the modern customer service field, the Intent Recognition Customer Service application flow combines advanced natural language processing (NLP) techniques with deep learning models to deliver intelligent and efficient customer services. This solution also integrates intent recognition and RAG capabilities to accurately understand user needs and questions, retrieve standard responses from predefined knowledge bases, and quickly return relevant answers. Developers can use Python to create the application flow and fine-tune response strategies based on actual business requirements. This enhances the accuracy of customer service and improves user experience. The application flow excels in fields that require efficient customer service, such as e-commerce, banking, and telecommunications. Developers can use this application flow as a template to extend or customize it for specific business requirements, enhancing customer experience and improving service quality.

Prerequisites

  • LangStudio supports Faiss or Milvus as its vector database. If you want to use Milvus, you must first create a Milvus database.

    Note

    In most cases, Faiss is used in test environments without the need to create an additional database. In production environments, we recommend that you use Milvus, which can process larger volumes of data.

  • The data required for the RAG knowledge base has been uploaded to OSS.

1. (Optional) Deploy LLM and embedding model

The intent recognition application flow requires both Large language model (LLM) and embedding model. This section describes how to quickly deploy the required model services through Model Gallery. If the deployed model service meets your business requirements and supports OpenAI APIs, you can skip this step and use it directly.

Choose QuickStart > Model Gallery and deploy the models for the following two scenarios.

  • Select large-language-model in the Scenarios section and deploy DeepSeek-R1. For more information, see One-click deployment of DeepSeek-V3 and DeepSeek-R1.

    Note

    For demonstration purposes, the Intent Recognition, Question Rewrite, and Answer User Questions nodes in the application flow created in this topic share the same model connection. Therefore, you only need to deploy DeepSeek-R1 once. In production environments, you can deploy different models for each node based on your business requirements and create the related connections to ensure accuracy and efficient of the application flow.

    image

  • Select embedding in the Scenarios section and deploy bge-m3 embedding model.

    image

2. Create a connection

2.1 Create an LLM connection

The LLM connection created in this topic is based on the Elastic Algorithm Service (EAS) model services deployed in QuickStart > Model Gallery. For information about other connection types, see Create a connection.

Go to LangStudio, select a workspace, and then choose Connection > Model Service. On the tab that appears, click New Connection to create a general LLM model service connection.

image

The following table describes the key parameters.

Parameter

Description

Name

If you deploy a model through Model Gallery, you can obtain the model name on the model details page. To go to the model details page, click the related model card on the Model Gallery page. For more information, see the "Model service" section of Create a connection.

Service Provider

  • PAI-EAS Model Service: In this example, PAI-EAS model services are used. You can select the LLM service deployed in 1. (Optional) Deploy LLM and embedding model for EAS Service. After you select the service, base_url and api_key are automatically filled in. base_url is set to the VPC endpoint of the deployed LLM and api_key is set to the token.

  • Third-party Model Service: You can use a third-party model service. For example, if you are using a DeepSeek model service, you must set base_url to https://api.deepseek.com, and enter the value of api_key obtained from the DeepSeek official website.

2.2 Create an embedding connection

You can create an embedding connection by referring to 2.1 Create an LLM connection.

image

3. Create a knowledge base index

You must create a knowledge base index to parse, chunk, vectorize, and store the corpus in the vector database. The following table describes the key parameters. For information about other configurations, see Create a knowledge base index.

Parameter

Description

Basic Configurations

Data Source OSS Path

Set the value to the OSS path of the RAG knowledge base in Prerequisites.

Output OSS Path

Set the value to the path for storing intermediate results and index information generated during document parsing.

Important

If you use FAISS as the vector database, the application flow saves the generated index files to OSS. If you use a default role of PAI (set Instance RAM Role to Default Roles of PAI on the Start Runtime page), the application flow can access the default storage bucket of your workspace. Therefore, we recommend that you set this parameter to a directory of the OSS bucket where the storage path for the workspace resides. If you use a custom role, you must grant OSS access permissions to the custom role. We recommend that you attach the AliyunOSSFullAccess policy to the role.

Embedding Model and Databases

Embedding Type

Select General Embedding Model.

Embedding Connection

Select the embedding connection created in 2.2 Create an embedding connection.

Vector Database Type

Select FAISS.

4. Create and run an application flow

  1. Go to LangStudio, select a workspace, and then click the Application Flow tab. On the tab that appears, click Create Application Flow to create an Intent Recognition Customer Service application flow.

    image

  2. On the application flow details page, click Create Runtime to create a runtime and start it. Note: Make sure that the runtime is started before the system parses a Python node or you can view More Tools.

    image

    Key parameter:

    VPC: If you use a Milvus vector database in 3. Create a knowledge base index, select the same VPC as that of the Milvus instance or a VPC that is connected to the VPC where the Milvus instance resides. If you use a Faiss vector database, you do not need to configure a VPC. In this example, a Faiss vector database is selected.

  3. Develop the application flow.

    image

    Retain the default settings for the nodes or configure them based on your business requirements. Use the following settings for the key nodes:

    • Intent Recognition: recognizes the user intent by using a LLM and executes branch nodes based on the recognition results.

      • Multi-intention Configuration: Add intents based on your business requirements. Make sure that each intent has a clear description and that different intents do not have semantic overlap. In this example, the default intent "About AliCloud PAI Issues" is used.

      • Model Configuration: Select the connection created in 2.1 Create an LLM connection.

      • Chat History: If you turn on this switch, the chat history feature is enabled, and previous conversations are used as input variables.

    • Question Rewrite: calls a LLM to rewrite the matched intents.

      • Model Configuration: Select the connection created in 2.1 Create an LLM connection.

      • Chat History: Make sure that the setting of this switch is consistent with that of the Intent Recognition node.

    • Knowledge Retrieval: retrieves text relevant to user questions from the knowledge base. For more information, see Use a knowledge base index.

    • Answer User Questions: calls a LLM to provide answers to user questions.

      • Model Configuration: Select the connection created in 2.1 Create an LLM connection.

      • Chat History: Make sure that the setting of this switch is consistent with that of the Intent Recognition node.

    • Other Intent: allows you to use custom Python code to implement more complex data processing logic.

    • Variable Merge: integrates specified intents with other intents to ensure that, regardless of which branch is executed, the results can be referenced through a unified variable.

    For more information about each component, see Develop an application flow.

  4. Debug or run the application flow. Click Run in the upper-right corner of the details page to run the application flow. For common issues during application flow runtime, see FAQ.

    image

  5. View the traces. Click View Traces below the generated answer to view the trace details or topology view.

    image

5. Deploy the application flow

On the development page of the application flow, click Deploy in the upper-right corner to deploy the application flow as an EAS service. Retain the default settings for the parameters or configure them based on your business requirements. Use the following settings for the key parameters:

  • Instances in the Resource Information section: Enter the number of service instances. Set this parameter to 1 for testing purposes. In production environments, we recommend that you configure multiple instances to mitigate the risk of a single point of failure (SPOF).

  • VPC (VPC) in the VPC section: If you use a Milvus vector database in 3. Create a knowledge base index, select the same VPC as that of the Milvus instance or a VPC that is connected to the VPC where the Milvus instance resides. If you use a Faiss vector database, you do not need to configure a VPC. In this example, a Faiss vector database is selected.

For more information about deployment, see Deploy an application flow.

6. Call the service

After the deployment is successful, you are redirected to the Elastic Algorithm Service (EAS) page of PAI. On the Online Debugging tab, configure and send a request. The key in the request body must be consistent with the Chat Input field in the Start Node of the application flow. In this example, the default field question is used.

image

image

For more methods to call the service (such as API operations) and detailed instructions, see Call a service.

References