Product knowledge question and answer method and computer device

CN122985960APending Publication Date: 2026-10-27HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510535207.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-25
Publication Date
2026-10-27

AI Technical Summary

Technical Problem

由于产品知识问答的领域性和专业性,若直接利用大语言模型的生成式问答服务,往往会导致大语言模型所输出的答案的准确性较低,或者答案与对应问题的相关性也不高

Benefits of technology

[0062]本申请根据产品文档的标题层级信息构建产品文档的目录索引树的数据组块chunk,数据组块chunk基于产品文档的每一个最末层级标题下的正文的大小进行确定和构建,根据各个chunk的目录索引、稀疏索引以及稠密索引构建产品文档向量知识库,根据所选择模型的token数量限制调整chunk的划分,使得文档的各个chunk能够通过树状结构的目录索引进行索引和访问,从而能够实现高效率的检索;将用户问题的文本嵌入向量分别与产品文档向量知识库中各个chunk的目录索引、稀疏索引以及稠密索引进行匹配,检索到对应的目标召回chunk集合,采用大语言模型对目标召回chunk集合中的chunk进行语义了解,生成用户问题相应的答案,通过对产品文档向量知识库各个chunk的多路索引,即目录索引、稀疏索引以及稠密索引,实现了产品知识库的chunk的多路召回机制,实现对产品知识库的高效检索和精确检索,能够输出与产品知识问题相关性较强的答案,提高大语言模型输出答案的准确性和答案内容的可靠性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122985960A_ABST
    Figure CN122985960A_ABST
Patent Text Reader

Abstract

The application discloses a product knowledge question and answer method, and relates to the technical field of natural language processing, which comprises the following steps: obtaining title hierarchical information of a product document, constructing a data chunk of a directory index tree of the product document according to the title hierarchical information; constructing a product document vector knowledge base according to a directory index, a sparse index and a dense index of each chunk, obtaining a user question, determining a text embedding vector of the user question, matching the text embedding vector with the directory index, the sparse index and the dense index of each data chunk in the product document vector knowledge base respectively, and obtaining a target recall chunk set corresponding to the user question; and using a large language model to integrate knowledge based on the target recall chunk set and output an answer to the user question. The application can output an accurate answer related to product knowledge for a product knowledge question input by a user.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of natural language processing technology in artificial intelligence, and more particularly to a product knowledge question answering method and computer device. Background Technology

[0002] Natural Language Processing (NLP) is an important field in computer science and artificial intelligence, enabling effective communication between humans and computers using natural language. NLP techniques typically include text processing, semantic understanding, machine translation, question answering, and knowledge graphs. Retrieval Augmented Generation (RAG) is often used with large language models to improve the quality of the answers generated. However, due to the domain-specific and specialized nature of product knowledge question answering, directly utilizing generative question answering services based on large language models often results in lower accuracy or less relevance to the questions. Summary of the Invention

[0003] The purpose of this application is to provide a product knowledge question-and-answer method that can output accurate answers related to product knowledge to product knowledge questions input by users.

[0004] To achieve the above objectives, this application provides a product knowledge question-and-answer method, which includes:

[0005] Retrieve the title hierarchy information of the product documents, and construct data chunks of the product document's directory index tree based on the title hierarchy information.

[0006] For the body text under each lowest-level heading in the product document:

[0007] If the size of the main text is less than or equal to the preset chunk threshold, the main text is treated as a chunk. The chunk threshold is determined based on the maximum number of token inputs in the large language model.

[0008] If the size of the main text is greater than the preset chunk threshold, the main text is divided into paragraphs, the title of each paragraph is constructed, the title of each paragraph is used as the second to last node of the directory index tree, paragraphs not greater than the preset chunk threshold are used as a chunk, and paragraphs greater than the preset chunk threshold are summarized based on the large language model, and the summarized content is used as a chunk.

[0009] For each chunk, the directory index of the chunk is determined based on the hierarchical structure path of the chunk in the directory index tree. A sparse index of the chunk is generated using a sparse retrieval model, and a dense index of the chunk is generated using a semantic vector model. A product document vector knowledge base is constructed based on the directory index, sparse index, and dense index of each chunk.

[0010] Obtain user questions, determine the text embedding vector of user questions, and match the text embedding vector with the directory index, sparse index and dense index of each data chunk in the product document vector knowledge base to obtain the target recall chunk set corresponding to the user questions.

[0011] A large language model is used to integrate knowledge based on the target recall chunk set and output the answer to the user's question.

[0012] Furthermore, the text embedding vector is matched with the directory index, sparse index, and dense index of each data chunk in the product document vector knowledge base to obtain the target recall chunk set corresponding to the user question, including:

[0013] The text embedding vector and sparse vector of the user's question are matched with the directory index and sparse index of each chunk, respectively, to obtain the first recall chunk set.

[0014] The dense vector of user questions is matched with the dense index of each chunk to obtain the second recall chunk set;

[0015] If the number of chunks shared by the first recall chunk set and the second recall chunk set reaches a first number, then all the shared chunks are constructed into the target recall chunk set;

[0016] If the number of chunks shared by the first and second recall chunk sets is less than the first number, all chunks remaining in the first recall chunk set (excluding the shared chunks) and all chunks remaining in the second recall chunk set (excluding the shared chunks) are merged into a third recall chunk set. The similarity between the dense index of each chunk in the third recall chunk set and the dense vector of the user question is determined using a re-ranking model, and the second number of chunks with the highest similarity are obtained. The second number of chunks and the shared chunks are then used to construct the target recall chunk set.

[0017] Furthermore, the text embedding vector and sparse vector of the user question are matched with the directory index and sparse index of each chunk, respectively, to obtain the first recall chunk set; the dense vector of the user question is matched with the dense index of each chunk to obtain the second recall chunk set, including:

[0018] Determine the text embedding vector, sparse vector, and dense vector of the user question;

[0019] The first similarity between the text embedding vector of the directory index of each chunk and the text embedding vector of the user question is determined by using the re-ranking model. The N chunks with the highest first similarity are determined as the fourth recall chunk set, where N is a natural number.

[0020] The second similarity between the sparse index of each chunk and the sparse vector of the user question is determined using a sparse retrieval model. The M chunks with the highest second similarity are determined as the fifth recall chunk set, where M is a natural number.

[0021] The fourth and fifth recall chunk sets are merged into the sixth recall chunk set. The re-ranking model is used to determine the third similarity between the sparse index of each chunk in the sixth recall chunk set and the sparse vector of the user question. The K chunks with the highest third similarity are determined as the first recall chunk set, where K is a natural number.

[0022] The dense retrieval model is used to determine the fourth similarity between the dense index of each chunk and the dense vector of the user question. The L chunks with the highest fourth similarity are determined as the second recall chunk set, where L is a natural number.

[0023] Furthermore, the re-ranking model is the BGE ReRanker model. This method also includes fine-tuning the BGE ReRanker model, which includes:

[0024] The sampling level is determined based on the directory index tree in the product document vector knowledge base. W selection chunks are selected in each sampling level and below using a stratified sampling method, where W is a natural number.

[0025] For each selected chunk, a corresponding question sample is generated using the prompt words, and a training sample set corresponding to that question sample is constructed. The construction of the training sample set includes:

[0026] Modify the selected chunk using prompt words to generate the corresponding first positive sample chunk, and set the similarity of the first positive sample chunk as the first similarity;

[0027] Using prompt words, select chunks to generate corresponding second positive sample chunks, and set the similarity of the second positive sample chunks as the second similarity, which is less than the first similarity;

[0028] V third positive sample chunks are randomly selected from each sampling level and below. The text similarity between the directory index of the selected chunk and each of the V third positive sample chunks is calculated. The text similarity is normalized. The maximum value between the normalized text similarity and the first similarity threshold is selected as the third similarity corresponding to the third positive sample chunk. In this way, V third similarities are obtained for the V third positive sample chunks, where V is a natural number.

[0029] In each level above the sampling level, Q negative sample chunks are randomly selected. The text similarity between the directory index of the selected chunk and each of the Q negative sample chunks is calculated. The text similarity is normalized. The maximum value between the normalized text similarity and the second similarity threshold is selected as the fourth similarity corresponding to the negative sample chunk. In this way, Q fourth similarities are obtained for the Q negative sample chunks, where Q is a natural number.

[0030] The training sample set corresponding to the question sample is constructed using the first positive sample chunk, the second positive sample chunk, V third positive sample chunks, Q negative sample chunks, the first similarity, the second similarity, the third similarity, the fourth similarity, and the training prompt words;

[0031] Obtain the training sample sets corresponding to each problem sample, construct the fine-tuning dataset using each training sample set, and fine-tune the BGE ReRanker model using the fine-tuning dataset to obtain the fine-tuned BGE ReRanker model.

[0032] Furthermore, the method also includes:

[0033] The intent of user questions is identified to determine the type of user question, which includes value-based questions and descriptive questions;

[0034] If the question type is a deterministic value type, retrieve the search results that match the user's question from the pre-built product graph knowledge base, use a large language model and a preset first prompt word template to integrate the search results and output the answer to the user's question. The first prompt word template is learned using a few-shot method.

[0035] If the question type is descriptive, determine the text embedding vector of the user question, retrieve the target recall chunk set based on the text embedding vector in the product document vector knowledge base, and integrate the target recall chunk set using a large language model and first prompt word template to output the answer to the user question.

[0036] Furthermore, intent recognition is performed on user questions to determine the type of user question, including:

[0037] Add user questions to a preset second prompt word template. The second prompt word template includes multiple preset user intents and descriptions for each preset user intent. The preset user intents include product parameter queries, product description requirements, and other intents. Other intents are intents other than product parameter queries and product description requirements.

[0038] The second prompt word template for the user's question is incorporated into the large language model, so that the large language model can determine the intent of the user's question under the guidance of the second prompt word template;

[0039] The type of user question is determined based on the intent of the user question.

[0040] If the user's question is intended to query product parameters, the user's question type is a definite value question.

[0041] If the intent of a user's question is to describe a product requirement, the type of user question is a descriptive question.

[0042] If the intent of the user's question is otherwise, the intent of the user's question is determined through a multi-turn dialogue, and the type of user question is determined based on the determined intent of the user's question.

[0043] Furthermore, the method also includes the construction of a product graph knowledge base, the steps of which include:

[0044] Retrieve the product parameter description data table for any product model;

[0045] The large language model and the preset third prompt word template are used to extract the parameter information in the product parameter description data table to obtain each parameter key-value pair. Each parameter key-value pair includes the parameter name and the corresponding parameter value. The product attribute knowledge table is constructed with the product model and the corresponding parameter key-value pairs. Each row of the product attribute knowledge table includes the product model, parameter name and parameter value.

[0046] Parse the multimedia data in the product document to obtain the product model, data type and storage path of the multimedia data, so as to construct the product multimedia data table. Each row of the product multimedia data table includes the product model, data type and storage path.

[0047] The product graph knowledge base is constructed based on the product attribute knowledge table and the product multimedia data table. The triple data includes an entity, an attribute, and an attribute value. The entity is the product model, the attribute includes the parameter name and data type, and the attribute value includes the parameter value and storage path.

[0048] Furthermore, if the question type is a deterministic value question, search results matching the user's question are retrieved from the pre-built product graph knowledge base, including:

[0049] Based on the preset fourth prompt word template, the user's question is converted into language to generate a structured query statement;

[0050] The target triple data is obtained by querying the product graph knowledge base using structured query statements.

[0051] The target triple data is converted into natural language using a preset language conversion template to obtain the search results.

[0052] For the purposes described above, this application provides a computer device, including an input device, a processor, and a display screen.

[0053] Input device for receiving user input of user questions;

[0054] The processor is used to obtain the title level information of the product document, and construct a data chunk of the directory index tree of the product document based on the title level information.

[0055] For the body text under each lowest-level heading in the product document:

[0056] If the size of the main text is less than or equal to the preset chunk threshold, the main text is treated as a chunk. The chunk threshold is determined based on the maximum number of token inputs in the large language model.

[0057] If the size of the main text is greater than the preset chunk threshold, the main text is divided into paragraphs, the title of each paragraph is constructed, the title of each paragraph is used as the second to last node of the directory index tree, paragraphs not greater than the preset chunk threshold are used as a chunk, and paragraphs greater than the preset chunk threshold are summarized based on the large language model, and the summarized content is used as a chunk.

[0058] For each chunk, the directory index of the chunk is determined based on the hierarchical structure path of the chunk in the directory index tree. A sparse index of the chunk is generated using a sparse retrieval model, and a dense index of the chunk is generated using a semantic vector model. A product document vector knowledge base is constructed based on the directory index, sparse index, and dense index of each chunk.

[0059] The text embedding vector of the user question is determined, and then matched with the directory index, sparse index, and dense index of each chunk in the product document vector knowledge base to obtain the target recall chunk set corresponding to the user question. A large language model is used to integrate knowledge based on the target recall chunk set and output the answer to the user question.

[0060] A display screen is used to show the answers to user questions.

[0061] For the purposes described above, this application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the product knowledge question-and-answer method described above.

[0062] This application constructs data chunks of a directory index tree for product documents based on their title hierarchy information. The data chunks are determined and constructed based on the size of the main text under each lowest-level title in the product document. A product document vector knowledge base is built based on the directory index, sparse index, and dense index of each chunk. The chunk division is adjusted according to the token limit of the selected model, enabling each chunk of the document to be indexed and accessed through the tree-structured directory index, thus achieving high-efficiency retrieval. The text embedding vector of the user question is then mapped to each element in the product document vector knowledge base. The system matches the directory index, sparse index, and dense index of a chunk to retrieve the corresponding target recall chunk set. A large language model is then used to semantically understand the chunks in the target recall chunk set and generate answers to user questions. By using multi-way indexing (directory index, sparse index, and dense index) of each chunk in the product document vector knowledge base, a multi-way recall mechanism for product knowledge base chunks is implemented. This enables efficient and accurate retrieval of the product knowledge base, outputting answers highly relevant to product knowledge questions and improving the accuracy and reliability of the answers output by the large language model. Attached Figure Description

[0063] Figure 1 This is a first flowchart illustrating the product knowledge question-and-answer method provided according to an embodiment of this application;

[0064] Figure 2This is a schematic diagram of the infrared temperature measurement technology document structure provided according to the embodiments of this application;

[0065] Figure 3 This is a schematic diagram of a directory index tree provided according to an embodiment of this application;

[0066] Figure 4 This is a schematic diagram of the second process of the product knowledge question-and-answer method provided in the embodiments of this application;

[0067] Figure 5 This is a schematic diagram of the third process of the product knowledge question-and-answer method provided according to the embodiments of this application;

[0068] Figure 6 This is a schematic diagram of the fourth process of the product knowledge question-and-answer method provided in the embodiments of this application;

[0069] Figure 7 This is a schematic diagram of the fifth process of the product knowledge question-and-answer method provided in the embodiments of this application;

[0070] Figure 8 This is a schematic diagram of the sixth process of the product knowledge question-and-answer method provided in the embodiments of this application;

[0071] Figure 9 This is a schematic diagram of the seventh process of the product knowledge question-and-answer method provided in the embodiments of this application;

[0072] Figure 10 This is a schematic diagram of the eighth process of the product knowledge question-and-answer method provided in the embodiments of this application;

[0073] Figure 11 This is a schematic diagram of the structure of a computer device provided according to an embodiment of this application. Detailed Implementation

[0074] The present application will be described in detail below with reference to the specific embodiments shown in the accompanying drawings. However, these embodiments do not limit the present application. Any structural, methodological, or functional modifications made by those skilled in the art based on these embodiments are included within the protection scope of the present application.

[0075] The executing entity of the product knowledge question-and-answer method in this application embodiment can be an electronic device. For example, the electronic device can be a terminal or other device, including but not limited to mobile terminals and fixed terminals. Mobile terminals include, but are not limited to, smartphones, smartwatches, tablets, and laptops, while fixed terminals include, but are not limited to, desktop computers and smart TVs. For example, the electronic device can also be a server or other device. This server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms, but is not limited to these.

[0076] Please refer to Figure 1 This application provides a product knowledge question-and-answer method, which includes steps S101-S104.

[0077] Step S101: Obtain the title level information of the product document, and construct data chunks of the product document's directory index tree based on the title level information.

[0078] Specifically, for the body text under each bottom-level heading in the product document: if the size of the body text is less than or equal to a preset chunk threshold, the body text is treated as a single chunk, where the chunk threshold is determined based on the maximum number of token inputs in the large language model; if the size of the body text is greater than the preset chunk threshold, the body text is divided into paragraphs, and the headings of each paragraph are constructed. Each paragraph heading is used as the second-to-last node of the directory index tree. Paragraphs not exceeding the preset chunk threshold are treated as a single chunk, and paragraphs exceeding the preset chunk threshold are summarized based on the large language model, with the summarized content used as a single chunk.

[0079] For example, product documents are acquired and parsed. This parsing typically includes identifying the document type and format, extracting text content, identifying structural elements such as headings, paragraphs, lists, and tables, extracting image information if necessary, and performing data cleaning on the parsed information. By parsing the product document, the document's heading hierarchy information and the body text under each heading level are obtained, such as "Heading 1," "Heading 2," etc. The parsed heading hierarchy information can then be stored in tabular form.

[0080] For example, for a product Word document, the unstructure library can be used to parse the document, extract the heading hierarchy structure, and the body text under each level.

[0081] For example, a directory index tree for the product documentation is constructed, with the document title of the product document as the root node, and the next level title of the document title as the next child node of the root node. For example... Figure 2 The diagram illustrates the document structure of infrared temperature measurement technology. The root node represents the infrared temperature measurement technology document itself. First-level headings such as "1. Introduction," "2. Technical Introduction," and "3. Solutions" serve as the next child node of the root node. Second-level headings under each first-level heading are linked back to the first-level heading, becoming the next child node, and so on. This hierarchical structure builds the table of contents tree, with each child node corresponding to a specific heading level, up to the main text under the final heading level. The main text then becomes the final node of the table of contents tree. Figure 3 The diagram shown illustrates the directory index tree. Based on this target index tree, the directory hierarchy path of the main text can be obtained.

[0082] Considering the constraints imposed by large language models on tokens, where a token is the smallest unit in text, these constraints will vary depending on the model. It's necessary to determine if the size of the main text meets the token constraints. If the size of the main text is less than or equal to a preset chunk threshold, then the main text is treated as a single chunk.

[0083] For example, the chunk threshold can be set to 30% of the maximum number of tokens input to a large language model. For instance, if the large language model Qwen1.5-32B is selected, which can handle 32K tokens, approximately 32,000 characters, the chunk threshold can be set to 10,000 characters.

[0084] If the size of the main text is less than or equal to a preset chunk threshold, the main text is treated as a single chunk. If the size of the main text is greater than the chunk threshold, the main text is divided into paragraphs, and titles for each paragraph are constructed. Each paragraph title is then used as the second-to-last node in the directory index tree. For example, if the main text under a Q-level directory exceeds the chunk threshold, the main text under the Q-level directory is divided into paragraphs. Assuming there are three paragraphs ①②③ under the Q-level directory, Q-level titles are constructed as Q_1, Q_2, and Q_3. If the size of the main text in paragraphs ①②③ is less than or equal to the chunk threshold, the corresponding main text in paragraphs ①②③ is used as individual chunks. If the size of the main text in any paragraph exceeds the chunk threshold, the content of that paragraph is summarized based on the large language model, and the summarized content is used as a single chunk. Based on the obtained directory index tree, the directory index for each chunk can be obtained.

[0085] Step S102: For each chunk, determine the directory index of the chunk based on the hierarchical structure path of the chunk in the directory index tree, generate a sparse index of the chunk using a sparse retrieval model, and generate a dense index of the chunk using a semantic vector model; construct a product document vector knowledge base based on the directory index, sparse index, and dense index of each chunk.

[0086] For each chunk, its directory index is determined based on its hierarchical path within the directory index tree. For example... Figure 3 As shown, the directory index of the chunk under the technical route is: Infrared Thermometry Technology Documentation - Introduction - Technical Route.

[0087] For example, a sparse index refers to a vector in which most elements have values ​​of 0, and only a few elements have values ​​of non-zero. A chunk's sparse index is a sparse vector extracted from a chunk, which can capture display information such as word frequency and importance of words in the chunk. A chunk's sparse index contains element values ​​corresponding to each word in a defined vocabulary. These element values ​​represent the word's frequency, importance, etc., in the text. If a word does not appear in the text, its corresponding element value can be a defined element value, such as 0.

[0088] For example, a dense index refers to a vector in which most or all elements are non-zero. A chunk's dense index is the dense vector extracted from the chunk; by converting text into a continuous vector representation in a high-dimensional space, it can capture display information such as word order and contextual semantics. The dimension of the dense index can be flexibly set according to actual needs, for example, it can be 512, 768, 1024, etc. Dense indices can be obtained, for example, through methods such as BERT, GPT, and BGE Embedding.

[0089] A product document vector knowledge base is constructed based on the directory index, sparse index, and dense index of each chunk. This knowledge base stores vectorized documents and provides efficient vector retrieval capabilities. Each chunk has a directory index, a sparse index, and a dense index, which improves the accuracy and efficiency of subsequent product document vector library retrieval.

[0090] Step S103: Obtain the user question, determine the text embedding vector of the user question, and match the text embedding vector with the directory index, sparse index and dense index of each data chunk in the product document vector knowledge base to obtain the target recall chunk set corresponding to the user question.

[0091] The solution provided in this application enhances the reasoning ability of a large language model based on a retrieval-enhanced generative model. The retrieval-enhanced generative model can be a large model combining information retrieval technology and generative models. This large retrieval-enhanced generative model can retrieve relevant information from an external knowledge base and input it as a prompt to the large language model. The large language model then generates an answer based on the question and the relevant retrieval information, thereby enhancing its ability to handle knowledge-intensive tasks, such as question information response, text summarization, and content generation. The external knowledge base can be a pre-constructed multi-source knowledge base, including a product document vector knowledge base and a product graph knowledge base. Retrieval results related to the user's question are retrieved from the multi-source knowledge base, and the answer to the product knowledge question is generated by the large language model based on the retrieval results.

[0092] The process involves acquiring user input questions and determining their text embedding vectors. Text embedding is a technique that converts text content (such as words, sentences, or paragraphs) into fixed-length dense vectors. It captures the semantic and contextual information of the text, ensuring that semantically related words are close together in the embedding space, while unrelated words are far apart. The semantic relationship between words can be represented by the distance between vectors. For example, an embedding model can be used to represent user questions as vectors. For instance, a BGE Embedding model can be used to represent user questions as vectors, resulting in the text embedding vectors for those questions.

[0093] The text embedding vector of the user question is matched with the directory index, sparse index, and dense index of each data chunk in the product document vector knowledge base to obtain the target recall chunk set corresponding to the user question. For example, the similarity between the text embedding vector of the user question and the directory index of each data chunk is calculated to obtain the similarity between the directory index of each chunk and the user question; the similarity between the text embedding vector of the user question and the sparse index of each chunk is calculated to obtain the similarity between the sparse index of each chunk and the user question; the similarity between the text embedding vector of the user question and the dense index of each chunk is calculated to obtain the similarity between the dense index of each chunk and the user question. Based on these similarities, the chunk corresponding to the user question is determined, thus obtaining the target recall chunk set.

[0094] A vector knowledge base is a database used to store, index, and manage large-scale embedding vectors generated by deep neural networks or other machine learning models. Embedding vectors are representations of text data in a high-dimensional space, capturing the semantic content of the data. In retrieval-enhanced generative models, the vector database stores the vectorized knowledge base and provides efficient vector retrieval capabilities, further enhancing the accuracy of large language model generation. In this implementation, the product vector knowledge base primarily stores vectorized information from descriptive documents such as product-related technical documents and solution documents.

[0095] Step S104: Use a large language model to integrate knowledge based on the target recall chunk set and output the answer to the user's question.

[0096] Based on the target recall chunk set retrieved from the product vector knowledge base, the contextual semantic understanding capability of the large language model is used to perform knowledge fusion and integration on each chunk in the target recall chunk set, and output the answer to the user's question. For example, the constructed prompt words, the user question, and the retrieved chunks can be input into the large language model. The user question is combined with each chunk, and the prompt words guide the large language model to generate the answer to the user question.

[0097] Large language models refer to natural language processing models trained on massive amounts of data, possessing hundreds of millions or even trillions of parameters. These models, through deep learning and machine learning techniques, are capable of understanding and generating natural language text, such as the common ChatGPT model, llama2, and Qwen7B.

[0098] In this embodiment, data chunks are constructed based on the title hierarchy information of the product document to form a directory index tree. The data chunks are determined and constructed based on the size of the main text under each lowest-level title of the product document. A product document vector knowledge base is built based on the directory index, sparse index, and dense index of each chunk. The chunk division is adjusted according to the token quantity limit of the selected model, enabling each chunk of the document to be indexed and accessed through the tree-structured directory index, thereby achieving high-efficiency retrieval. The text embedding vector of the user question is then embedded into the product document vector knowledge base. The system matches the directory index, sparse index, and dense index of each chunk in the product document vector knowledge base to retrieve the corresponding target recall chunk set. A large language model is then used to semantically understand the chunks in the target recall chunk set and generate answers to user questions. By using multi-way indexing (directory index, sparse index, and dense index) for each chunk in the product knowledge base, a multi-way recall mechanism for product knowledge base chunks is implemented. This enables efficient retrieval of the product knowledge base, outputs answers highly relevant to product knowledge questions, and improves the accuracy and reliability of the answers output by the large language model.

[0099] In some embodiments of this application, such as Figure 4 As shown, the method includes steps S401-S403.

[0100] Step S401: Perform intent recognition on the user question to determine the type of the user question, including value-based questions and descriptive questions.

[0101] Intent recognition refers to identifying the user's intent or purpose from the natural language input of the user's question. Accurately identifying the user's intent and categorizing the user's question into descriptive or deterministic questions allows for the selection of appropriate retrieval strategies based on the type of user question, thereby further improving the accuracy and efficiency of retrieval.

[0102] For example, by preprocessing user questions, extracting keywords and contextual information, and comparing the identified information with predefined intent categories, the specific intent of the user question can be determined.

[0103] For example, the cue word technique of large language models can be used to guide the model to recognize intent by designing cue words, so that the model can understand the user's question more clearly and thus determine the type of the user's question.

[0104] For example, if a user question involves multiple sub-questions, the user question is broken down into multiple sub-questions, and intent recognition is performed on each sub-question to determine the question type of each sub-question.

[0105] For example, deterministic value questions can be understood as questions from users asking for specific, explicit information. These questions typically require the system to provide a definite answer or a set of definite values, such as precise numerical values, model numbers, and parameters. For example, user questions such as "What is the pixel value of product model A?", "Which has a higher resolution, product A or product B?", and "What does product A look like in an image?" can be identified as deterministic value questions.

[0106] For example, descriptive questions can be understood as questions that require a detailed description or explanation of an object. They typically require the system to explain or describe a concept, event, technical principle, or phenomenon, rather than providing a simple, definitive value. For instance, user questions such as "Describe the principle of the photothermal effect?" or "What are the principles and hardware requirements of infrared thermometry?" can be classified as descriptive questions.

[0107] Step S402: If the type is a definite value question, retrieve the search results that match the user's question from the pre-built product graph knowledge base, use a large language model and a preset first prompt word template to integrate the search results and output the answer to the user's question. The first prompt word template is learned using a few-shot method.

[0108] In large language models, cue words are natural language text input to the model to guide it in completing specific tasks. A cue word can be a simple question, such as "What is a large language model?", or a more complex instruction, such as "Write a poem about autumn." Cue word data used for LLM fine-tuning typically consists of instructions, input, and output. Instructions tell the model the task or command to complete; input is the specific content expected to be understood by the large language model; and output is the correct answer expected from the large language model. By designing cue words appropriately, the generation quality and accuracy of large language models can be improved.

[0109] If the user's question is determined to be a deterministic question, the retrieval method uses the product graph knowledge base to obtain the corresponding search results. Using a preset first prompt word template, the search results are combined with the user's question to generate model prompt words. These model prompt words guide the large language model to generate the answer to the user's question.

[0110] For example, the first prompt word template employs a few-shot learning approach. In few-shot learning, the model adapts to a new task using only a small number of samples. In prompt word engineering, few-shot learning refers to guiding a large language model to generate more expected output by providing a limited number of examples. This approach provides the model with context and concrete examples, making it suitable for handling complex tasks and helping the model understand the user's needs.

[0111] For example, the first prompt template is designed as follows: Based on the [Question Type], summarize the text in [Knowledge] that can answer the [User Question]. The answer must conform to the original description of the [Knowledge]. The summary should be fluent and concise. Please directly output the content of the [Answer], and do not output content unrelated to [Knowledge] or new content. The content in the [Answer] should be in Chinese as much as possible. [Knowledge] can be understood as search results or retrieved chunks.

[0112] Example 1:

[0113] [Question] What is the difference in pixel parameters between product model 1 and product model 2?

[0114] [Problem Type] Problem involving deterministic values.

[0115] [Knowledge] 1. Product model 1 has 14 million pixels; 2. Product model 2 has 16 million pixels.

[0116]

Answer

[0117] Step S403: If the type is a descriptive question, determine the text embedding vector of the user question, retrieve the target recall chunk set based on the text embedding vector in the product document vector knowledge base, use a large language model and the first prompt word template to integrate the target recall chunk set, and output the answer to the user question.

[0118] If the user's question is determined to be a descriptive question, the retrieval method involves searching the product document vector knowledge base to obtain a set of target recall chunks, i.e., multiple chunks are retrieved. Using a first prompt word template, the target recall chunk set is combined with the user's question to generate model prompt words. These prompt words guide the large language model to generate the answer to the user's question.

[0119] Based on the first prompt word template in the example above, here is an example of a descriptive question:

[0120] [Question] Briefly describe the working principle of infrared temperature measurement equipment.

[0121] [Question Type] Descriptive question.

[0122] [Knowledge] 1. The working principle of infrared thermometers is based on the characteristic of objects radiating electromagnetic waves. When the temperature of an object is above absolute zero, it continuously radiates electromagnetic waves in all directions, including infrared rays in the 0.75–100 μm band. Infrared thermometers measure the temperature of objects by detecting these infrared rays; 2. Infrared thermal imagers can detect problems such as missing insulation materials, leaks, moisture, and thermal bridging; 3. Infrared thermometers typically consist of the following parts: Optical system: gathers the infrared radiation energy of the target object; the size of the field of view is determined by the optical components and their positions; Photodetector: converts the gathered infrared energy into corresponding electrical signals; Signal amplifier and signal processing: amplifies and processes the electrical signals, corrects them according to built-in algorithms and target emissivity, and finally displays the temperature value.

[0123]

Answer

[0124] In this embodiment, by performing intent analysis on the user's question, the type of the user's question is determined, and the user's question is located as a descriptive question or a deterministic value question. This allows for the selection of different retrieval strategies based on the type of user's question, which can further improve the accuracy and efficiency of the retrieval. For the obtained retrieval results, guided by prompt words, the large language model can output the accurate answer to the user's question.

[0125] In some embodiments of this application, such as Figure 5 As shown, intent recognition is performed on user questions to determine the type of user questions, including steps S501-S503.

[0126] Step S501: Add the user question to the preset second prompt word template. The second prompt word template includes multiple preset user intents and descriptions for each preset user intent. The preset user intents include product parameter query, product description requirements, and other intents. Other intents are intents other than product parameter query and product description requirements.

[0127] For example, the second prompt word template can be:

[0128] Task: Classify product Q&A intent;

[0129] Instructions: The goal is to categorize user questions about the product into three types. Based on the questions provided by users, please determine which of the following categories their intent belongs to:

[0130] 1. Product Parameter Inquiry: Users inquire about the specific parameters, model, attribute values, or type of a particular product and expect to receive a precise answer;

[0131] 2. Product Description Requirements: Users are interested in the product's underlying technology, operation and management regulations, after-sales service, or application scenarios, and hope to receive a detailed description;

[0132] 3. Other Intents: If the user's question does not fall into the above two categories, i.e., the user cannot accurately locate the need for product parameter query or product description, then the user should be guided to further clarify the question.

[0133] Example 1:

[0134] User question: What is the processor model of this laptop?

[0135] Intent: Product parameter query.

[0136] Example 2:

[0137] User question: I would like to understand the working principle of infrared technology in ABCDE model cameras?

[0138] Intent: Product description requirements.

[0139] Example 3:

[0140] User Question: I encountered some problems while using the ABCDE software. Can you help me solve them?

[0141] Intention: Other intentions.

[0142] Step S502: The second prompt word template added to the user question is passed through the large language model so that the large language model can determine the intent of the user question under the guidance of the second prompt word template.

[0143] By combining user questions and second prompt word templates to generate prompt words, the large language model can determine the intent of the user question under the guidance of these prompt words. That is, the intent is to query product parameters, product description requirements, or other intents.

[0144] Step S503: Determine the type of user question based on the intent of the user question. If the intent of the user question is to query product parameters, the type of user question is a definite value question; if the intent of the user question is to describe product requirements, the type of user question is a descriptive question; if the intent of the user question is other, determine the intent of the user question based on a multi-turn dialogue, and determine the type of user question based on the determined intent of the user question.

[0145] In this embodiment, the intent of the user's question is analyzed by using a second prompt word template and a large language model to determine the intent of the user's question, thereby determining the type of the user's question and enabling a faster and more accurate question-and-answer service for the user.

[0146] In some embodiments of this application, such as Figure 6 As shown, the method also includes the construction of a product graph knowledge base, and the steps for constructing the product graph knowledge base include S601-S604.

[0147] Step S601: Obtain the product parameter description data table for any product model.

[0148] For example, the product parameter description data table is shown in the table below:

[0149]

[0150] Step S602: Use a large language model and a preset third prompt word template to extract parameter information from the product parameter description data table to obtain each parameter key-value pair. Each parameter key-value pair includes a parameter name and a corresponding parameter value. Construct a product attribute knowledge table with the product model and the corresponding parameter key-value pairs. Each row of the product attribute knowledge table includes the product model, parameter name, and parameter value.

[0151] For example, the third prompt word template can be:

[0152] Task: Extract key-value pairs from a given product parameter description;

[0153] Instructions: Please carefully read the following product parameter description and extract the key information to form key-value pairs. Each key-value pair should contain a parameter name (key) and a corresponding parameter value (value), output in JSON format.

[0154] The parameter descriptions and third-party prompt word templates are combined to generate prompt words. Guided by these prompt words, the large language model extracts information to obtain key-value pairs for each parameter. For example, the key-value pairs extracted from the parameter description section of the table above are as follows:

[0155]

[0156] Based on each extracted parameter key value, a product attribute knowledge table is constructed using the product model and its corresponding parameter key value pairs. The product attribute knowledge table is as follows:

[0157] Product Model Parameter name Parameter value Model 1 resolution 3840x 2160 Model 1 Infrared lights Dual LED Model 1 storage microSD card up to 256GB Model 1 Wireless connection Wi-Fi and Ethernet Model 1 power supply 12V DC power adapter

[0158] Step S603: Parse the multimedia data in the product document to obtain the product model, data type, and storage path of the multimedia data, so as to construct a product multimedia data table. Each row of the product multimedia data table includes the product model, data type, and storage path.

[0159] Multimedia materials can be understood as image information in unstructured product documents, such as product illustrations and installation step pictures in user manuals, circuit diagrams in technical documents, and product appearance pictures in product introduction materials.

[0160] For example, when parsing multimedia materials in product documents, text can be extracted from images using OCR (Optical Character Recognition) to recognize the information in the images.

[0161] For example, based on the image information in the product documentation, the image data is assigned to the corresponding document type using an image classification model, such as an appearance description or installation instructions.

[0162] Product documents are typically stored locally or on cloud servers. The storage path (URL) of the product documents can be obtained. Based on the product model, data type, and storage path of the obtained multimedia materials, a product multimedia data table is constructed, as shown in the table below:

[0163] Product Model Data type Storage path Model 2 Appearance Introduction / server1 / xxx.png Model 2 Installation Instructions / server2 / xxx.png

[0164] Step S604: Construct triplet data for the product graph knowledge base based on the product attribute knowledge table and the product multimedia data table. The triplet data includes an entity, an attribute, and an attribute value. The entity is the product model, the attribute includes the parameter name and the data type, and the attribute value includes the parameter value and the physical address.

[0165] A knowledge graph is a knowledge base that represents knowledge such as entities, relationships, and attributes in a graphical form. By representing knowledge in a structured way, it enables computers to better understand and process human language. A knowledge graph is typically a large, semi-structured, topic-oriented, multimodal knowledge base containing various entities, relationships, and attributes. This information is processed and reasoned about through a series of algorithms and models, enabling computers to automatically acquire, reason, and generate new knowledge. The triple in a knowledge graph is the basic building block, consisting of three elements: an entity, a relationship, and another entity. A triple includes not only the relationship between entities but also the entity's attributes and attribute values, i.e., the form ENTITY-ATTRIBUTE-VALUE.

[0166] In this embodiment, the product knowledge base adopts an entity-attribute-attribute value format. The product model is used as the entity to reflect the core content of the product. Product parameter names, functional points, and data types are used as attributes to represent the product's characteristics and functions. Specific parameter values, function descriptions, and data paths are used as attribute values ​​to provide detailed information about the product. For example, entity-attribute-attribute value can be represented as "Product Model 1", "Resolution", "3840x2160", and entity-attribute-attribute value can be represented as "Product Model 2", "Appearance Description", " / server1 / xxx.png".

[0167] For example, the storage of the product graph knowledge base can be based on the actual amount of product data and the query method for the product graph knowledge base, selecting an appropriate relational database or graph database. The refresh frequency of the product graph knowledge base can be determined according to the update frequency of product information, updating the product graph knowledge base with updated product parameters and multimedia materials.

[0168] For example, the graph table structure of the product graph knowledge base is as follows:

[0169] Entity Attribute Attribute value (VALUE) Product Model 1 resolution 3840x 2160 Product Model 1 Infrared lights Dual LED Product Model 1 storage microSD card up to 256GB Product Model 2 Appearance Introduction / server1 / xxx.png

[0170] In this embodiment, a relational data table is constructed using product information with key-value pair relationships, such as attributes, parameters, specifications, and types. For multimedia information such as images in product documents, information is extracted and recognized using technologies such as OCR, and the original information is stored in physical space. The data type and storage path are recorded in the relational data table. Based on the above relational table, triplet data is constructed to obtain a product graph knowledge base. Using the product graph knowledge base method can effectively organize and represent product-related information, enabling large models to better understand and process this information, which helps to achieve more efficient knowledge retrieval.

[0171] In this embodiment, by constructing a multi-source, multi-modal product knowledge base, namely a product graph knowledge base and a product document vector knowledge base, the original information of the documents is basically preserved completely, avoiding semantic inconsistencies or information loss caused by text embedding. Based on different question types, different knowledge bases are used for retrieval. For deterministic value questions, efficient querying can be achieved through the product graph knowledge base, while for descriptive questions, retrieval of text content can be achieved through the product document vector knowledge base. This greatly improves the performance of the question-answering system, significantly enhances the performance and accuracy of the model when handling knowledge-intensive tasks, and solves the problems of information updating and retrieval relevance.

[0172] In some embodiments of this application, such as Figure 7 As shown, if the question type is a deterministic value type, the steps to retrieve search results matching the user's question from the pre-built product graph knowledge base include:

[0173] S701, based on a preset fourth prompt word template, performs language conversion on the user's question and generates a structured query statement;

[0174] S702, based on structured query statements, perform a query in the product graph knowledge base to obtain the target triplet data;

[0175] S703 uses a preset language conversion template to convert the target triplet data into natural language to obtain the search results.

[0176] This approach utilizes prompts to transform user-input definite value questions into structured query statements, converting natural language statements into structured query languages. For example, structured query statements can be SQL queries, and Text2SQL can be used to convert user-input natural language text into SQL.

[0177] For example, the fourth prompt word template can be represented as follows:

[0178] Task: You are an SQL database technology expert. Convert users' natural language descriptions into SQL query statements to query the product map attribute table.

[0179] Instructions: Please generate an SQL query based on the structure of the following product attribute table. The product attribute table contains three columns.

[0180] - Entity;

[0181] - Attribute;

[0182] - Attribute value;

[0183] Please generate the corresponding SQL query statement based on the description provided by the user.

[0184] Example:

[0185] User input: Find all models of "infrared camera devices" with more than 3 million pixels.

[0186] The generated SQL query:

[0187] SELECT distinct entity FROM product_attributes WHERE entity rlike'%infraredcam%' and attribute='pixels' and value>='300'.

[0188] The generated structured query statement is used to query the product graph knowledge base to obtain the target triplet data. For example, the query results of the product graph knowledge base are:

[0189] Entity Attribute Attribute value (VALUE) Product Model 1 Pixels 14 million Product Model 2 Pixels 16 million

[0190] The target triplet data is converted into natural language using a preset language conversion template to obtain the search results. For example, the language conversion template can be represented as:

[0191] {ENTITY} has {ATTRIBUTE} which is {VALUE}.

[0192] The query results from the above product knowledge base are represented in natural language as follows:

[0193] Product model 1 has 14 megapixels. Product model 2 has 16 megapixels.

[0194] Using a preset first prompt word template, the search results are combined with the user's question to generate model prompt words. These prompt words guide the large language model to generate an answer to the user's question. As mentioned above, the generated answer is: [Answer] Model 1 has a pixel parameter of 14 million, while Model 2 has a pixel parameter of 16 million. The difference between the two is that Model 2 has 2 million more pixels than Model 1.

[0195] In some embodiments of this application, such as Figure 8 As shown, the text embedding vector and sparse vector of the user question are matched with the directory index and sparse index of each chunk respectively to obtain the first recall chunk set; the dense vector of the user question is matched with the dense index of each chunk to obtain the second recall chunk set, including steps S801-S805.

[0196] Step S801: Determine the text embedding vector, sparse vector, and dense vector of the user question.

[0197] For example, the BGE Embedding model is used to represent the user question as a vector, resulting in a text embedding vector for the user question. Sparse vectors of the user question can be obtained using methods such as the bag-of-words model, TF-IDF, BM25 algorithm, and sparse coding. Dense vectors of the user question can be obtained using methods such as BERT, GPT, and BGE Embedding.

[0198] Step S802: Use the reordering model to determine the first similarity between the text embedding vector of the directory index of each chunk and the text embedding vector of the user question, and determine the N chunks with the highest first similarity as the fourth recall chunk set, where N is a natural number.

[0199] If the user's question is determined to be a descriptive question, the retrieval method used is to search the product document vector knowledge base. An embedding model can be employed, where the index of each chunk is represented as a vector of text. For example, the embedding model could be a BGE Embedding model, which uses vector representation to obtain the text embedding vector of each chunk's index.

[0200] Using a re-ranking model, the first similarity between the text embedding vector of the directory index of each chunk and the text embedding vector of the user question is calculated. Based on the calculated first similarity, the chunks are sorted from high to low, and the N chunks with the highest first similarity are determined as the fourth recall chunk set. For example, N can be set to 10.

[0201] For example, the re-ranking model could be the BGE ReRanker model, a deep learning-based language model that re-ranks the input text based on the similarity between the input user question and each chunk. The re-ranking results typically arrange candidate chunks in descending order of relevance, and the top N chunks from the re-ranking results are selected to form the fourth recall chunk set.

[0202] Step S803: Use the sparse retrieval model to determine the second similarity between the sparse index of each chunk and the sparse vector of the user question, and determine the M chunks with the highest second similarity as the fifth recall chunk set, where M is a natural number.

[0203] Using a sparse retrieval model, a second similarity is calculated between the sparse index of each chunk and the sparse vector of the user question. Based on the calculated second similarity, the chunks are sorted from highest to lowest, and the M chunks with the highest second similarity are determined as the fifth recall chunk set. The second similarity is calculated based on the sparse vector of the chunk and the user question, and is used to characterize the correlation between the two. The second similarity can be calculated using a correlation function, such as dot product similarity or cosine similarity. For example, M can be set to 10.

[0204] For example, sparse retrieval models can be TF-IDF (term frequency–inverse document frequency), BM25 (best match 25), etc. By inputting the sparse index of each chunk and the sparse vector of the user's question into the sparse retrieval model, a second similarity can be output.

[0205] Step S804: Merge the fourth and fifth recall chunk sets into a sixth recall chunk set. Use the re-ranking model to determine the third similarity between the sparse index of each chunk in the sixth recall chunk set and the sparse vector of the user question. Select the K chunks with the highest third similarity as the first recall chunk set, where K is a natural number.

[0206] The N chunks from the fourth recall chunk set and the M chunks from the fifth recall chunk set are merged to obtain the sixth recall chunk set. A re-ranking model is used to determine the third similarity between the sparse index of each chunk in the sixth recall chunk set and the sparse vector of the user's question. Based on the calculated third similarity, the chunks are sorted from highest to lowest, and the K chunks with the highest third similarity are determined as the first recall chunk set. For example, K can be set to 3.

[0207] For example, the reranking model could be the BGE ReRanker model.

[0208] Step S805: Use the dense retrieval model to determine the fourth similarity between the dense index of each chunk and the dense vector of the user question, and determine the L chunks with the highest fourth similarity as the second recall chunk set, where L is a natural number.

[0209] Using a dense retrieval model, a fourth similarity is calculated between the dense index of each chunk and the dense vector of the user question. Based on the calculated fourth similarity, the chunks are sorted from highest to lowest, and the L chunks with the highest fourth similarity are determined as the second recall chunk set. The fourth similarity is calculated based on the dense vector of the chunk and the user question, and is used to characterize the correlation between the chunk and the dense vector of the user question. The fourth similarity can be calculated using a correlation function, such as dot product similarity or cosine similarity. For example, L can be set to 5.

[0210] For example, dense indexing models can be ANCE models, BGE Embedding, etc.

[0211] In this embodiment, by calculating the similarity between the user question and the directory index, sparse index, and dense index of the chunk, multi-path retrieval of the product document vector knowledge base can be achieved. Chunks related to the user question can be retrieved based on different index paths, thereby improving the accuracy of the retrieval and further ensuring the accuracy and relevance of the answer to the user question.

[0212] In some embodiments of this application, such as Figure 9 As shown, the text embedding vector is matched with the directory index, sparse index and dense index of each data chunk in the pre-built product document vector knowledge base to obtain the target recall chunk set corresponding to the user question, including steps S901-S904.

[0213] Step S901: Match the text embedding vector and sparse vector of the user question with the directory index and sparse index of each chunk respectively to obtain the first recall chunk set.

[0214] Step S902: Match the dense vector of the user question with the dense index of each chunk to obtain the second recall chunk set;

[0215] Step S903: If the number of chunks shared by the first recall chunk set and the second recall chunk set reaches a first number, construct all the shared chunks into a target recall chunk set.

[0216] Step S904: If the number of chunks shared by the first recall chunk set and the second recall chunk set is less than the first number, merge all the remaining chunks in the first recall chunk set (excluding the shared chunks) and all the remaining chunks in the second recall chunk set (excluding the shared chunks) into a third recall chunk set; use the re-ranking model to determine the similarity between the dense index of each chunk in the third recall chunk set and the dense vector of the user question, and obtain the second number of chunks with the highest similarity; construct the target recall chunk set by combining the second number of chunks and the shared chunks.

[0217] In this embodiment, to further ensure higher accuracy of the retrieved chunks, the chunks in the first and second retrieved chunk sets need to be reordered, and the target retrieved chunk set is determined based on the reordered result.

[0218] For example, the first quantity is set to 3. The second recall chunk set contains 5 chunks. If the number of chunks shared by the first and second recall chunk sets reaches 3, these 3 shared chunks are used to construct a target recall chunk set, which serves as the retrieval result of the user question in the product document vector knowledge base.

[0219] If the number of chunks shared between the first and second recall chunk sets is less than 3 (assuming a shared number of 2), these 2 shared chunks are added to the target recall chunk set. The remaining 1 chunk in the first recall chunk set and the remaining 3 chunks in the second recall chunk set are merged into a third recall chunk set. A re-ranking model is used to determine the similarity between the dense index of each chunk in the third recall chunk set and the dense vector of the user question. The chunk with the highest similarity is selected, and this chunk, along with the 2 shared chunks, forms the target recall chunk set. Using a large language model and the first prompt word template, the 3 chunks in the target recall chunk set are integrated to output the answer to the user question.

[0220] In this example, by reordering the retrieved chunks, we can further ensure that the accuracy and relevance of the retrieved chunks are higher, and make the output answer to the user's question more relevant.

[0221] In some embodiments of this application, the re-ranking model is the BGE ReRanker model. Since the BGE ReRanker model is an open-source model and belongs to the general domain model, while the product knowledge base belongs to private domain information, directly using the ranking score obtained from the open-source model may be inaccurate, leading to inaccurate chunk recall. Therefore, this embodiment fine-tunes the BGE ReRanker model by constructing a fine-tuning dataset, such as... Figure 10 As shown, the steps for fine-tuning the BGE ReRanker model include S1001-S1003.

[0222] S1001, Based on the structure of the directory index tree in the product document vector knowledge base, determine the sampling level, and use the stratified sampling method to select W selection chunks in each sampling level and below, where W is a natural number.

[0223] The sampling level is determined based on the structure of the directory index tree in the product document vector knowledge base to select positive samples of higher quality. For example, assuming the directory index tree has a five-level hierarchical structure, the third level can be used as the sampling level, and sample chunks can be selected from each third level as well as the fourth and fifth levels below it.

[0224] A stratified sampling method is used to select W selection chunks in each sampling stratum and below, aiming to select a uniform number of selection chunks in each sampling stratum. The number of selection chunks in each sampling stratum can be determined based on the number of sampling strata, the number of selection chunks, and the number of chunks below that sampling stratum.

[0225] For example, if there are P third-level chunks, w is extracted from all chunks corresponding to the i-th third-level chunk. i One chunk, w i The value can be:

[0226] w i =min(W / / P+1,count({x k} i ));

[0227] In the above formula, W / / P represents rounding, which represents the average number of chunks extracted in the third level, {x k} i This represents the extracted chunk, count({x k} i This represents the count value of the number of chunks extracted, and the minimum value between the two is selected as the number of chunks extracted in this third level, w. i Based on this method, samples can be drawn evenly across all third-level tiers.

[0228] S1002, for each selected chunk, generate a corresponding question sample using the prompt words, and construct the training sample set corresponding to the question sample.

[0229] For each selected chunk, a corresponding question sample is generated using a large language model and prompt word templates. A corresponding training sample set is constructed based on each question sample, and the construction of the training sample set includes steps S10021-S10025.

[0230] For example, the prompt word template is shown below:

[0231] You are a professional question-asking assistant. Please generate a relevant and in-depth question based on the following text.

[0232] The main text is as follows: {}.

[0233] S10021, Modify the selected chunk using the prompt words to generate the corresponding first positive sample chunk, and set the similarity corresponding to the first positive sample chunk as the first similarity.

[0234] The selected chunk is modified using a large language model and prompt words to generate a corresponding first positive sample chunk. The similarity score of the first positive sample chunk is set as the first similarity score. This selected chunk is the selected chunk corresponding to the question sample. For example, the first similarity score is 0.99.

[0235] S10022, use prompt words to summarize and select chunks to generate corresponding second positive sample chunks, set the similarity of the second positive sample chunks as the second similarity, and the second similarity is less than the first similarity.

[0236] The selected chunk is summarized using a large language model and prompt words to generate a corresponding second positive sample chunk. The similarity score of the second positive sample chunk is set as the second similarity score. This selected chunk is the selected chunk corresponding to the question sample. For example, the second similarity score is 0.95.

[0237] S10023, randomly select V third positive sample chunks in each sampling level and below, calculate the text similarity between the directory index of the selected chunk and the text similarity between each of the V third positive sample chunks, normalize the text similarity, and select the maximum value between the normalized text similarity and the first similarity threshold as the third similarity corresponding to the third positive sample chunk, thus obtaining V third similarities corresponding to the V third positive sample chunks, where V is a natural number.

[0238] V third positive sample chunks are randomly selected from each sampling level and below. Each third positive sample chunk has a corresponding directory index, and the selected chunks have corresponding directory indexes. The text similarity between the two directory indices is calculated.

[0239] For example, text similarity is represented using Jaccard similarity, which is expressed as follows:

[0240]

[0241] Where, represents the vocabulary set of the directory index of chunkA, represents the vocabulary set of the directory index of chunkB, and set A ∩set B This represents the size of the intersection of two sets, chunkA and chunkB, which can be understood as the number of identical directories in the two sets. A ∪set B This represents the size of the union of two sets, chunkA and chunkB, which can be understood as the number of directories in both sets.

[0242] For example, the calculated Jaccard similarity is normalized using the softmax function, and the maximum value between the normalized Jaccard similarity and the first similarity threshold is selected as the third similarity corresponding to the third positive sample chunk. The first similarity threshold can be set to 0.5.

[0243] Based on the above implementation method, V third similarities can be obtained for V third positive sample chunks.

[0244] S10024, randomly select Q negative sample chunks from each level above the sampling level, calculate the text similarity between the directory index of the selected chunk and the text of each of the Q negative sample chunks, normalize the text similarity, and select the maximum value between the normalized text similarity and the second similarity threshold as the fourth similarity corresponding to the negative sample chunk, thus obtaining the Q fourth similarities corresponding to the Q negative sample chunks, where Q is a natural number.

[0245] Q negative sample chunks are randomly selected from each level above the sampling level. For example, if the sampling level is the third level, negative samples are selected from the first and second levels. From the chunk index, selecting negative samples from levels farther away from the chunk and selecting positive and negative samples from levels closer to the chunk can obtain good quality positive samples and difficult negative samples.

[0246] For example, the selection principle for negative sample chunks is: the closer the level is to the sampling level, the more negative sample chunks are selected; the farther the level is from the sampling level, the fewer negative sample chunks are selected.

[0247] For example, suppose there are S levels above the sampling level, and the number of negative sample chunks (num) selected in any of the S levels is... q Represented as:

[0248]

[0249] Where V represents the number of the third positive sample chunks, I represents the sampling level, and q represents the q-th level out of S levels. For example, if the sampling level is the third level, the value of q can be 1 or 2.

[0250] As described above, the Jaccard similarity between the directory index of the selected chunk and each negative sample chunk can be calculated. The calculated Jaccard similarity is normalized using the softmax function. The maximum value between the normalized Jaccard similarity and the second similarity threshold is selected as the fourth similarity corresponding to the negative sample chunk, thereby obtaining the Q fourth similarities corresponding to the Q negative sample chunks.

[0251] For example, the second similarity threshold can be set to 0.5. I-q+1 Here, I represents the sampling level, and q represents the q-th level out of S levels. It is understandable that the second similarity threshold is a variable threshold.

[0252] S10025, the training sample set corresponding to the problem sample is constructed using the first positive sample chunk, the second positive sample chunk, V third positive sample chunks, Q negative sample chunks, the first similarity, the second similarity, the third similarity, the fourth similarity, and the training prompt words.

[0253] For example, the training prompt could be: determine whether the target text contains content for answering the question.

[0254] S1003, obtain the training sample sets corresponding to each problem sample, construct the fine-tuning dataset with each training sample set, and use the fine-tuning dataset to fine-tune the BGE ReRanker model to obtain the fine-tuned BGEReRanker model.

[0255] According to steps S10021-S10025, obtain the training sample sets corresponding to each question sample, construct a fine-tuned dataset, and use the fine-tuned dataset to fine-tune the BGE ReRanker model to obtain the fine-tuned BGEReRanker model. Based on the fine-tuned BGE ReRanker model, determine the similarity between the dense index of each chunk in the third recall chunk set and the dense vector of the user question, obtain the second number of chunks with the highest similarity, and construct the target recall chunk set by combining the second number of chunks and the common chunks.

[0256] In this embodiment, the BGE ReRanker model is fine-tuned and trained by constructing a fine-tuning dataset. During the construction of the fine-tuning dataset, samples are obtained through stratified sampling based on the directory hierarchy, and the similarity of corresponding samples is calculated. This not only yields high-quality positive samples but also provides reasonable and reliable similarity scores based on the directory hierarchy information. A stratified, differentiated negative sampling strategy—sampling fewer chunks from distant directory levels and more chunks from closer directory levels—effectively improves the quality of negative sample sampling, obtaining more challenging negative samples and thus enhancing the performance and effectiveness of fine-tuning. The positive-to-negative sample ratio can be set at approximately 1:10 to increase the model's ability to distinguish negative samples and improve model performance.

[0257] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the above-described product knowledge question-and-answer methods.

[0258] Figure 11This is a schematic diagram of the hardware structure of a computer device provided in an embodiment of this application. The computer device includes: an input device 1101, a processor 1102, a memory 1103, a communication interface 1104, and a display screen 1105. The input device 1101 receives user input questions. The processor 1102 obtains the title level information of the product document, and constructs data chunks of the directory index tree of the product document based on the title level information. Specifically, for the body text under each last-level title of the product document: if the size of the body text is less than or equal to a preset chunk threshold, the body text is treated as a chunk, where the chunk threshold is determined based on the maximum number of token inputs in the large language model; if the size of the body text is greater than the preset chunk threshold, the body text is divided into paragraphs, and titles for each paragraph are constructed. Each paragraph title is used as the second-to-last node of the directory index tree. Paragraphs not exceeding the preset chunk threshold are treated as a chunk. Paragraphs exceeding the preset chunk threshold are summarized based on the large language model to summarize... The subsequent content is treated as a chunk. For each chunk, its directory index is determined based on its hierarchical path in the directory index tree. A sparse index is generated using a sparse retrieval model, and a dense index is generated using a semantic vector model. A product document vector knowledge base is constructed based on the directory index, sparse index, and dense index of each chunk. The text embedding vector of the user question is determined, and it is matched with the directory index, sparse index, and dense index of each chunk in the product document vector knowledge base to obtain the target recall chunk set corresponding to the user question. A large language model is used to integrate knowledge based on the target recall chunk set and output the answer to the user question. Display screen 1105 is used to display the answer to the user question.

[0259] The input device 1101, processor 1102, memory 1103, communication interface 1104, and display screen 1105 communicate with each other via a communication bus. Figure 11 The connection method between the input device 1101, processor 1102, memory 1103, communication interface 1104, and display screen 1105 shown is merely exemplary. In the implementation process, other connection methods besides the communication bus can also be used to communicate with each other.

[0260] The memory 1103 can be used to store computer programs, which may include instructions and data to implement the steps of any of the product knowledge question-and-answer methods described above. In this embodiment, the memory 1103 can be various types of storage media, such as random access memory (RAM), read-only memory (ROM), non-volatile RAM (NVRAM), programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), flash memory, optical storage, and registers. The memory 1103 may include a hard disk and / or RAM.

[0261] Processor 1102 can be a general-purpose processor, which can be a processor that performs specific steps and / or operations by reading and executing a computer program (e.g., a computer program) stored in memory (e.g., memory 1103). The general-purpose processor may use data stored in memory (e.g., memory 1103) during the execution of said steps and / or operations. The general-purpose processor can be, for example, but not limited to, a central processing unit (CPU). Furthermore, processor 1102 can also be a dedicated processor, which can be a processor specifically designed to perform specific steps and / or operations. Dedicated processors can be, for example, but not limited to, ASICs and FPGAs. Additionally, processor 1102 can also be a combination of multiple processors, such as a multi-core processor.

[0262] The input device 1101 can be a touch layer covering the display screen, or a button, trackball, or touchpad set on the casing of the computer device, or an external keyboard, touchpad, or mouse, etc.

[0263] The display screen 1105 can be an LCD screen or an e-ink screen.

[0264] The communication interface 1104 can be used to communicate with external terminals via wired or wireless means. Wireless communication can be achieved through WIFI, mobile cellular networks, NFC (Near Field Communication) or other technologies.

[0265] In implementation, each step of the above method can be completed by the integrated logic circuitry of the hardware in processor 1102 or by instructions in software form. The method disclosed in the embodiments of this application can be directly implemented by a hardware processor, or by a combination of hardware and software modules in the processor. The software modules can reside in random access memory (RAM), read-only memory (ROM), programmable read-only memory (ROM), electrically erasable programmable memory (EPR), registers, or other mature storage media in the art. This storage medium is located in memory 1103, and processor 1102 reads information from memory 1103 and, in conjunction with its hardware, completes the steps of the above method. To avoid repetition, detailed descriptions are omitted here.

[0266] Although preferred embodiments of the present application have been disclosed for illustrative purposes, those skilled in the art will recognize that various modifications, additions, and substitutions are possible without departing from the scope and spirit of the present application as disclosed in the appended claims.

Claims

1. A product knowledge question-and-answer method, characterized in that, The method includes: Obtain the title level information of the product document, and construct a data chunk of the product document's directory index tree based on the title level information, wherein... For the body text under each lowest-level heading in the product document: If the size of the main text is less than or equal to a preset chunk threshold, the main text is treated as a chunk, wherein the chunk threshold is determined based on the maximum number of token inputs of the large language model; If the size of the main text is greater than the preset chunk threshold, the main text is divided into paragraphs, the title of each paragraph is constructed, the title of each paragraph is used as the second to last node of the directory index tree, paragraphs not greater than the preset chunk threshold are used as a chunk, and paragraphs greater than the preset chunk threshold are summarized based on the large language model, and the summarized content is used as a chunk. For each chunk, the directory index of the chunk is determined based on the hierarchical structure path of the chunk in the directory index tree. A sparse index of the chunk is generated using a sparse retrieval model, and a dense index of the chunk is generated using a semantic vector model. A product document vector knowledge base is constructed based on the directory index, sparse index, and dense index of each chunk. Obtain user questions, determine the text embedding vector of the user questions, and match the text embedding vector with the directory index, sparse index, and dense index of each chunk in the product document vector knowledge base to obtain the target recall chunk set corresponding to the user questions; A large language model is used to integrate knowledge based on the target recall chunk set and output the answer to the user's question.

2. The product knowledge question-and-answer method as described in claim 1, characterized in that, The text embedding vector is matched with the directory index, sparse index, and dense index of each data chunk in the product document vector knowledge base to obtain the target recall chunk set corresponding to the user question, including: The text embedding vector and sparse vector of the user question are matched with the directory index and sparse index of each chunk respectively to obtain the first recall chunk set; The dense vector of the user question is matched with the dense index of each chunk to obtain the second recall chunk set; If the number of chunks shared by the first recall chunk set and the second recall chunk set reaches a first number, all shared chunks are constructed into a target recall chunk set; If the number of chunks shared by the first recall chunk set and the second recall chunk set is less than the first number, all the remaining chunks in the first recall chunk set (excluding the shared chunks) and all the remaining chunks in the second recall chunk set (excluding the shared chunks) are merged into a third recall chunk set. The similarity between the dense index of each chunk in the third recall chunk set and the dense vector of the user question is determined using a re-ranking model, and the second number of chunks with the highest similarity are obtained. The second number of chunks and the shared chunks are used to construct the target recall chunk set.

3. The product knowledge question-and-answer method as described in claim 2, characterized in that, The text embedding vector and sparse vector of the user question are matched with the directory index and sparse index of each chunk respectively to obtain the first recall chunk set; The dense vector of the user question is matched with the dense index of each chunk to obtain the second recall chunk set, including: Determine the text embedding vector, sparse vector, and dense vector of the user question; The first similarity between the text embedding vector of the directory index of each chunk and the text embedding vector of the user question is determined by using the re-ranking model. The N chunks with the highest first similarity are determined as the fourth recall chunk set, where N is a natural number. The second similarity between the sparse index of each chunk and the sparse vector of the user question is determined using a sparse retrieval model. The M chunks with the highest second similarity are determined as the fifth recall chunk set, where M is a natural number. The fourth and fifth recall chunk sets are merged into a sixth recall chunk set. The third similarity between the sparse index of each chunk in the sixth recall chunk set and the sparse vector of the user question is determined using a re-ranking model. The K chunks with the highest third similarity are determined as the first recall chunk set, where K is a natural number. The dense retrieval model is used to determine the fourth similarity between the dense index of each chunk and the dense vector of the user question. The L chunks with the highest fourth similarity are determined as the second recall chunk set, where L is a natural number.

4. The product knowledge question-and-answer method as described in claim 2, characterized in that, The re-ranking model is the BGEReRanker model, and the method further includes fine-tuning the BGEReRanker model, the fine-tuning training including: The sampling level is determined based on the directory index tree in the product document vector knowledge base. W selection chunks are selected in each sampling level and below using a stratified sampling method, where W is a natural number. For each selected chunk, a corresponding question sample is generated using the prompt words, and a training sample set corresponding to that question sample is constructed. The construction of the training sample set includes: The selected chunk is modified using prompt words to generate the corresponding first positive sample chunk, and the similarity corresponding to the first positive sample chunk is set as the first similarity. Using the prompt words to summarize the selected chunk, a corresponding second positive sample chunk is generated. The similarity of the second positive sample chunk is set as the second similarity, which is less than the first similarity. V third positive sample chunks are randomly selected from each sampling level and below. The text similarity between the directory index of the selected chunk and each of the V third positive sample chunks is calculated. The text similarity is normalized. The maximum value between the normalized text similarity and the first similarity threshold is selected as the third similarity corresponding to the third positive sample chunk. In this way, V third similarities are obtained for the V third positive sample chunks, where V is a natural number. In each level above the sampling level, Q negative sample chunks are randomly selected. The directory index of the selected chunk is calculated and the text similarity between it and each of the Q negative sample chunks is calculated. The text similarity is normalized. The maximum value between the normalized text similarity and the second similarity threshold is selected as the fourth similarity corresponding to the negative sample chunk. In this way, Q fourth similarities are obtained for the Q negative sample chunks, where Q is a natural number. The training sample set corresponding to the question sample is constructed using the first positive sample chunk, the second positive sample chunk, V third positive sample chunks, Q negative sample chunks, the first similarity, the second similarity, the third similarity, the fourth similarity, and the training prompt words; Obtain the training sample sets corresponding to each problem sample, construct a fine-tuning dataset using each training sample set, and fine-tune the BGE ReRanker model using the fine-tuning dataset to obtain the fine-tuned BGE ReRanker model.

5. The product knowledge question-and-answer method as described in claim 1, characterized in that, The method further includes: The user question is subjected to intent recognition to determine the type of the user question, wherein the type includes value-determining questions and descriptive questions; If the type is a deterministic value question, retrieve the search results that match the user question from the pre-built product graph knowledge base, use a large language model and a preset first prompt word template to integrate the search results and output the answer to the user question. The first prompt word template is learned using a few-shot method. If the type is a descriptive question, determine the text embedding vector of the user question, retrieve the target recall chunk set based on the text embedding vector in the product document vector knowledge base, integrate the target recall chunk set using a large language model and the first prompt word template, and output the answer to the user question.

6. The product knowledge question-and-answer method as described in claim 5, characterized in that, Intent recognition is performed on the user question to determine the type of the user question, including: The user question is added to a preset second prompt word template, wherein the second prompt word template includes multiple preset user intents and descriptions corresponding to each preset user intent. The preset user intents include product parameter queries, product description requirements, and other intents, wherein the other intents are intents other than product parameter queries and product description requirements. The second prompt word template added to the user's question is passed through a large language model so that the large language model can determine the intent of the user's question under the guidance of the second prompt word template; The type of the user question is determined based on the intent of the user question, wherein, If the intent of the user's question is to query product parameters, the type of the user's question is a definite value question; If the intent of the user question is a product description requirement, the type of the user question is a descriptive question; If the intent of the user's question is other than the intent itself, the intent of the user's question is determined based on a multi-turn dialogue, and the type of user question is determined based on the determined intent of the user's question.

7. The product knowledge question-and-answer method as described in claim 5, characterized in that, The method also includes the construction of a product graph knowledge base, the steps of which include: Retrieve the product parameter description data table for any product model; The parameter information in the product parameter description data table is extracted using a large language model and a preset third prompt word template to obtain each parameter key-value pair. Each parameter key-value pair includes a parameter name and a corresponding parameter value. A product attribute knowledge table is constructed using the product model and the corresponding parameter key-value pairs. Each row of the product attribute knowledge table includes the product model, parameter name, and parameter value. Parse the multimedia data in the product document to obtain the product model, data type and storage path of the multimedia data, so as to construct the product multimedia data table. Each row of the product multimedia data table includes the product model, data type and storage path. The product graph knowledge base is constructed based on the product attribute knowledge table and the product multimedia data table, wherein the triple data includes an entity, an attribute, and an attribute value. The entity is the product model, the attribute includes the parameter name and the data type, and the attribute value includes the parameter value and the storage path.

8. The product knowledge question-and-answer method as described in claim 7, characterized in that, If the type is a deterministic value question, retrieve search results matching the user question from a pre-built product graph knowledge base, including: Based on the preset fourth prompt word template, the user's question is converted into language to generate a structured query statement; Based on the structured query statement, the target triplet data is obtained by querying the product graph knowledge base. The target triple data is converted into natural language using a preset language conversion template to obtain the search results.

9. A computer device, comprising an input device, a processor, and a display screen, characterized in that, The input device is used to receive user questions input by the user; The processor is configured to acquire the title level information of the product document, and construct a data chunk of the product document's directory index tree based on the title level information, wherein... For the body text under each lowest-level heading in the product document: If the size of the main text is less than or equal to a preset chunk threshold, the main text is treated as a chunk, wherein the chunk threshold is determined based on the maximum number of token inputs of the large language model; If the size of the main text is greater than the preset chunk threshold, the main text is divided into paragraphs, the title of each paragraph is constructed, the title of each paragraph is used as the second to last node of the directory index tree, paragraphs not greater than the preset chunk threshold are used as a chunk, and paragraphs greater than the preset chunk threshold are summarized based on the large language model, and the summarized content is used as a chunk. For each chunk, the directory index of the chunk is determined based on the hierarchical structure path of the chunk in the directory index tree. A sparse index of the chunk is generated using a sparse retrieval model, and a dense index of the chunk is generated using a semantic vector model. A product document vector knowledge base is constructed based on the directory index, sparse index, and dense index of each chunk. The text embedding vector of the user question is determined, and the text embedding vector is matched with the directory index, sparse index, and dense index of each chunk in the product document vector knowledge base to obtain the target recall chunk set corresponding to the user question; a large language model is used to integrate knowledge based on the target recall chunk set to output the answer to the user question; The display screen is used to display the answer to the user's question.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the product knowledge question-and-answer method according to any one of claims 1 to 8.