Content retrieval method and device, equipment, intelligent agent and storage medium
By introducing tree index information and knowledge graph technology into the search enhancement generation system, combining metadata and semantic similarity, the problems of material retrieval accuracy and efficiency in the RAG system are solved, and more efficient content retrieval and generation are achieved.
Patent Information
- Application Number
- CN202411311243.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2024-12-10
AI Technical Summary
When the existing search enhancement generation system (RAG) processes complex queries, the accuracy and efficiency of material retrieval is difficult to meet the needs, especially when processing diversified materials, which leads to inaccurate and relevant content.
Introduce tree-like index information, recall and expand candidate content blocks through metadata and parent node information, match semantic similarity and content relevance to improve recall rate, and integrate context information through knowledge graphs to improve retrieval accuracy .
It significantly improves the recall rate and accuracy of content retrieval, provides richer and more accurate knowledge services, and can effectively match user query requests in complex network structures.
Smart Images

Figure CN119106104A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the computer field, in particular to the field of artificial intelligence technology, deep learning, natural language processing and other technical fields, and can be applied to intelligent search scenarios. Specifically, it relates to a content retrieval method, device, equipment, intelligent agent and storage medium. Background Art
[0002] In this multimodal agent, the Retrieval Augmented Generation (RAG) system is one of the core components. The RAG system is an advanced technology that combines information retrieval with generative models. By integrating the resources of external knowledge bases or databases, it enhances the ability of generative models to handle complex queries, making the generated content more accurate and relevant. When dealing with diverse materials, the RAG system first uses a retrieval mechanism to find materials that are highly relevant to the query from a large-scale database, and then combines these retrieved materials with the generative model to generate content-rich and context-relevant responses. However, the accuracy and efficiency of material retrieval are still difficult to meet the needs. Summary of the invention
[0003] The present disclosure provides a content retrieval method, apparatus, device, intelligent agent and storage medium.
[0004] According to one aspect of the present disclosure, there is provided a content retrieval method, comprising:
[0005] Get the user's query request;
[0006] Determine a candidate content block from the initial content block according to the query request and the tree index information to which the initial content block belongs; wherein the tree index information includes metadata of the initial content block and metadata in a parent node to which the initial content block belongs;
[0007] The query request and the candidate content blocks are matched, and a target content block is determined from the candidate content blocks according to the matching result; wherein the candidate content blocks at least include the candidate content blocks.
[0008] According to one aspect of the present disclosure, there is provided a content retrieval device, comprising:
[0009] A query request module is used to obtain the user's query request;
[0010] A candidate content block module, configured to determine a candidate content block from the initial content block according to the query request and the tree index information to which the initial content block belongs; wherein the tree index information includes metadata of the initial content block and metadata in a parent node to which the initial content block belongs;
[0011] The target content block module is used to match the query request with the candidate content blocks, and determine the target content block from the candidate content blocks according to the matching result; wherein the candidate content blocks at least include the candidate content blocks.
[0012] According to another aspect of the present disclosure, there is provided an electronic device, the electronic device comprising:
[0013] at least one processor; and
[0014] a memory communicatively connected to the at least one processor; wherein,
[0015] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method provided by any embodiment of the present disclosure.
[0016] According to another aspect of the present disclosure, an artificial intelligence agent is provided, which is configured to execute the method provided by any embodiment of the present disclosure.
[0017] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute the method provided by any embodiment of the present disclosure.
[0018] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the method provided according to any embodiment of the present disclosure is implemented.
[0019] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 is an architecture diagram of a remote log system provided according to an embodiment of the present disclosure;
[0021] Figure 2 is a flowchart of another content retrieval method provided according to an embodiment of the present disclosure;
[0022] Figure 3 is a flowchart of another content retrieval method provided according to an embodiment of the present disclosure;
[0023] Figure 4 is a structural schematic diagram of a content retrieval device provided according to an embodiment of the present disclosure;
[0024] Figure 5It is a block diagram of an electronic device used to implement the content retrieval method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0025] Figure 1 1 is a flowchart of a content retrieval method provided according to an embodiment of the present disclosure. The method is applicable to the case of retrieving matching target content blocks for a query request. The method can be executed by a content retrieval device, which can be implemented in software and / or hardware and can be integrated into an electronic device. Figure 1 As shown, the content retrieval method of this embodiment may include:
[0026] S101, obtaining a user's query request;
[0027] S102, determining a candidate content block from the initial content block according to the query request and the tree index information to which the initial content block belongs; wherein the tree index information includes metadata of the initial content block and metadata in a parent node to which the initial content block belongs;
[0028] S103, matching the query request with candidate content blocks, and determining a target content block from the candidate content blocks according to the matching result; wherein the candidate content blocks at least include the candidate content blocks.
[0029] The tree index information can be constructed by indexing content units such as documents, document fragments, and images using a two-level tree structure. The child nodes in the tree index information are initial content blocks obtained by splitting the content units. The metadata of the initial content blocks may include the parent node to which the initial content blocks belong, and may also include the order, i.e., the position, of the initial content blocks in the parent node to which they belong. The parent node is a content unit with practical significance. For example, a parent node may correspond to a chapter, a song, or an episode of a TV series; the metadata of any parent node may include the initial content blocks belonging to the parent node and the order between the initial content blocks.
[0030] Exemplarily, in the process of storing any content unit in the RAG system, a parent node can be created for the content unit. The parent node does not store the content unit and the vector representation of the content unit, but only stores the metadata of the parent node. The metadata of the parent node may include the identifiers of each initial content block belonging to the parent node and the order between the initial content blocks. Moreover, the content unit can be divided into multiple content blocks, and the vector representation (embedding) of the content block can be calculated for each content block. The parent node to which the content block belongs and the position of the content block in the parent node can also be recorded in the metadata of the content block. The content block is a child node, and the vector representation and metadata of the content block can be stored in a vector database; the parent node is a virtual node, and the metadata of the parent node can be stored in a key-value database such as Redis. By introducing tree index information into the RAG system, that is, setting a virtual parent node for the content unit, it is convenient to trace back to the corresponding parent node through the candidate content blocks that match the user's query request in the subsequent retrieval process, and expand and recall the candidate content blocks according to the metadata of the candidate content blocks and the metadata of the corresponding parent node to obtain more candidate content blocks, thereby improving the recall rate.
[0031] In the process of using the user's query request to perform content retrieval, the user's query request can be matched with the initial content block to recall the candidate content block, and the metadata of the candidate content block can be used to trace back to the parent node to which the candidate content block belongs, and the candidate content block can be expanded and recalled according to the metadata in the parent node. Exemplarily, other initial content blocks associated with the candidate content block can be used as new candidate content blocks. In the recall stage, the recall rate of the candidate content block is improved by not only matching the user's query request with the initial content block to obtain the matching candidate content block, but also tracing back to the parent node according to the metadata of the candidate content block, and combining the metadata in the corresponding parent node to determine the new candidate content block.
[0032] The content retrieval process may include a recall phase and a refined ranking phase of content blocks. The recall phase is used to preliminarily screen out candidate content blocks that may match the query request from the initial content blocks, and then obtain candidate content blocks that at least include the candidate content blocks as input for the refined ranking phase; the refined ranking phase is used to accurately sort the candidate content blocks obtained in the recall phase. In the refined ranking phase, the relevance between the query request and the candidate content blocks can be determined, and the candidate content blocks with relatively high relevance can be used as target content blocks to obtain retrieval results.
[0033] The technical solution provided by the disclosed embodiment introduces tree index information into the RAG system. In the recall phase, not only the user's query request is matched with the initial content block to obtain the matching candidate content block, but also the parent node is traced back according to the metadata of the candidate content block, and the new candidate content block is determined in combination with the metadata in the corresponding parent node, thereby improving the recall rate of content retrieval.
[0034] Figure 2 is a flowchart of another content retrieval method provided according to an embodiment of the present disclosure. Figure 2 Based on the above embodiment, the content retrieval method of this embodiment may include:
[0035] S201, obtaining a user's query request;
[0036] S202, matching the query request with the initial content block, and determining a first content block from the initial content block according to the matching result;
[0037] S203, determining a second content block matching the first content block from the remaining initial content blocks according to the metadata of the first content block and the metadata in the first parent node to which the first content block belongs, the candidate content blocks including the first content block and the second content block;
[0038] S204, matching the query request with candidate content blocks, and determining a target content block from the candidate content blocks according to the matching result; wherein the candidate content blocks at least include candidate content blocks.
[0039] The tree index information to which the initial content block belongs includes metadata of the initial content block and metadata in the parent node to which the initial content block belongs.
[0040] In the recall phase, the user's query request and the initial content block can be preliminarily matched, and the first content block matching the query request can be selected from the initial content block; the first parent node to which the first content block belongs can also be traced back according to the metadata of the first content block, and the first content block and the remaining initial content blocks can be processed according to the metadata in the first parent node, and the second content block matching the first content block can be determined from the remaining initial content blocks according to the processing results, and the candidate content blocks include not only the first content block but also the second content block matching the first content block. By recalling the second content block matching the first content block according to the metadata in the first parent node to which the first content block belongs, and taking both the first content block and the second content block as candidate content blocks, the recall rate of the candidate content blocks is improved, thereby improving the recall rate of content retrieval. It is found through experiments that the recall rate of content retrieval can be improved by about 6% through the above processing.
[0041] In an optional implementation manner, determining the second content block matching the first content block from the remaining initial content blocks according to the metadata of the first content block and the metadata in the first parent node to which the first content block belongs includes: determining the first parent node to which the first content block belongs according to the metadata of the first content block; determining each initial content block belonging to the first parent node according to the metadata in the first parent node; if a ratio of the number of first content blocks belonging to any first parent node to the number of initial content blocks belonging to the first parent node is greater than a preset ratio threshold, then treating all the remaining initial content blocks in the first parent node as the second content blocks matching the first content block.
[0042] In the recall phase, after obtaining the first content block that matches the query request, the first parent node to which the first content block belongs can be obtained from the metadata of the first content block, and the identification list of the initial content blocks belonging to the first parent node can be obtained from the metadata of the first parent node. For each first parent node, the ratio of the number of first content blocks belonging to the first parent node to the number of initial content blocks belonging to the first parent node is determined; if the ratio value is greater than the preset ratio threshold, the remaining initial content blocks in the first parent node are all used as second content blocks; otherwise, the first parent node is not expanded and recalled. Among them, the ratio threshold is an empirical value, for example, it can be 50%. That is to say, if the user's query request is related to the initial content blocks exceeding the ratio threshold in a parent node, it is considered that the query request may require the entire parent node, and all the initial content blocks in the parent node are used as candidate content blocks. Through the above processing, the first parent node to which the first content block belongs can be expanded and recalled, that is, the brother content blocks belonging to the first parent node with the first content block can be recalled, thereby improving the recall rate.
[0043] In an optional implementation, after determining the first content block from the initial content blocks according to the matching results, the method further includes: performing entity recognition on the first content block and the remaining initial content blocks respectively to obtain a first entity included in the first content block and an initial entity included in the remaining initial content blocks; determining a third content block associated with the first content block from the remaining initial content blocks according to the first entity and the initial entity; wherein the alternative content block also includes the third content block.
[0044] In the embodiment of the present disclosure, the knowledge graph of the long text to which the initial content block belongs can also be obtained, for example, the knowledge graph of the works to which multiple content units belong can be obtained; after obtaining the first content block, the first content block can also be entity recognized based on the knowledge graph to obtain the first entity in the first content block, and the remaining initial content blocks can be entity recognized based on the knowledge graph to obtain the corresponding initial entity; the first entity in the first content block and the initial entities in the remaining initial content blocks can be combined to determine whether the first content block and the remaining initial content blocks are associated, and the remaining initial content blocks associated with the first content block are used as the third content block to obtain the candidate content blocks including the candidate content block and the third content block. Exemplarily, if the first content blocks exceeding the set proportion value (for example, 70%) all include a certain entity, the remaining initial content blocks including the entity can be used as the third content block; or, if it is determined that the first entity blocks exceeding the set proportion value are all connected to a certain initial entity block according to the first entity block in the first content block, the initial entity blocks in the remaining initial content blocks, and the connection relationship between the first entity block and the initial entity block, the initial content block is used as the third content block.
[0045] By incorporating more implicit contextual information from knowledge graph technology into the retrieval and content generation process, more comprehensive and in-depth insights can be provided when answering questions. This not only improves retrieval accuracy, but also enhances the ability to fully understand and represent knowledge, truly realizing the transition from a tree-like index structure to a complex network structure, and providing users with richer and more accurate knowledge services.
[0046] The technical solution provided by the embodiment of the present disclosure further improves the recall rate of content retrieval by recalling the second content block matching the first content block according to the metadata in the first parent node to which the first content block belongs; and by recalling the third content block matching the first content block according to the first entity in the first content block and the initial entities in the remaining initial content blocks.
[0047] In an optional implementation, matching the query request and the initial content blocks and determining the first content block from the initial content blocks according to the matching result includes: encoding the query request to obtain a query vector, and determining the semantic similarity between the query vector and the vector representation of each of the initial content blocks; determining the content relevance between the query request and the initial content blocks according to the word frequency, inverse document frequency and document length of the query words in the query request in the initial content blocks; and selecting the first content block from the initial content blocks according to the semantic similarity and the content relevance.
[0048] Exemplarily, the query request is encoded to obtain a query vector; for each initial content block, the vector similarity, i.e., semantic similarity, between the query vector and the vector representation of the initial content block is determined; query terms, such as keywords, are extracted from the query request, and the content relevance between the query request and the initial content block can be determined based on the word frequency, inverse document frequency (IDF) of the query terms in the initial content block, and the document length of the initial content block. For example, the BM25 algorithm can be used to determine the content relevance between the query request and the initial content block. The semantic similarity and content relevance of the initial content block are fused to obtain the fused relevance of the initial content block, for example, the semantic similarity and content relevance are averaged as the fused relevance, and the initial content block with relatively high fused relevance is selected as the first content block.
[0049] The questions raised by users, i.e., query requests, are often concise, abstract, and highly generalized, and usually carry strong contextual dependencies and implicit intentions. The expressions of these questions are usually highly refined and only contain the core information that users want to obtain. On the other hand, materials such as documents, images, and audio are often specific and detailed information carriers, usually containing a lot of details, background information, and extended content. The content of the materials is not only rich, but also may involve multi-level semantics, which makes the vector representation of the materials more complex and multi-dimensional. This difference in information level leads to asymmetry in the vectorization process: the user's query vector may focus more on concepts, topics, or keywords, while the vector representation of the initial content block contains a wider range of semantic background and detailed information. Even if the query request and the initial content block are mapped to the same vector space through vectorization technology, they may still show low similarity when calculating semantic similarity. This asymmetry is an inherent challenge in the RAG system, which may cause mismatches between questions and materials during retrieval, thereby affecting the quality of the final generated content.
[0050] Therefore, if only semantic similarity is used to match the query request and the initial content block, in some cases, the sensitivity to the keywords in the query request will be lost. For example, when querying "How is 'odd and regular' defined in Sun Tzu's Art of War?", the semantic similarity search may return content related to "odd and regular", but cannot accurately identify and return content containing the definition of "odd and regular". It should be noted that the disclosed embodiment can use text form to retrieve audio or images, and the content unit and initial content block corresponding to the audio can be lyrics; the content unit and initial content block corresponding to the image can be the subtitles, description information, main content, etc. of the image. The download address of the target audio or target image matching the query request is obtained through the matching processing in text form, and the target audio data or target image data is obtained using the download address. The importance of keywords is highlighted by inverse document frequency, and the sensitivity to low-frequency keywords is enhanced by nonlinear word frequency calculation, that is, by introducing content relevance, the keyword information in the initial content block can be accurately captured, while maintaining sensitivity to keywords, it also avoids the deviation caused by simple word frequency statistics.
[0051] In an optional implementation, the selecting the first content block from the initial content blocks according to the semantic similarity and the content relevance includes: determining a first range of semantic similarity according to the semantic similarity of each initial content block, and using the first range to process each semantic similarity to obtain a processed semantic similarity; determining a second range of content similarity according to the content similarity of each initial content block, and using the second range to process each content similarity to obtain a processed content similarity; and selecting the first content block from the initial content blocks according to the processed semantic similarity and the processed content similarity of each initial content block.
[0052] Exemplarily, the maximum semantic similarity and the minimum semantic similarity can be obtained from the semantic similarities of each initial content block, and the first range is obtained by subtracting the minimum semantic similarity from the maximum semantic similarity; for each initial content block, the semantic similarity of the initial content block is divided by the first range to obtain a semantic similarity with a value in [0,1], that is, a normalized semantic similarity; the maximum content relevance and the minimum content relevance can be obtained from the content relevance of each initial content block, and the second range is obtained by subtracting the minimum content relevance from the maximum content relevance; for each initial content block, the content relevance of the initial content block is divided by the second range to obtain a normalized content relevance; the normalized semantic similarity and the normalized content relevance of the initial content block can be averaged to obtain the fused relevance of the initial content block; the initial content block with a relatively high fused relevance is selected as the first content block. By normalizing the semantic similarity and content relevance of each initial content block respectively and fusing the normalized results to obtain the fused relevance of the initial content block, a balance can be achieved between the semantic similarity and the content relevance, further improving the quality of the first content block.
[0053] In an optional implementation, the initial content block is stored in an Elasticsearch database.
[0054] In the disclosed embodiment, Elasticsearch is used as the underlying database in the RAG system. Elasticsearch has a powerful distributed architecture, which improves data availability by distributing index data to multiple nodes and using a replica mechanism. Even if some nodes fail, the system can automatically restore services through replicas to ensure continuous data availability and uninterrupted queries. This distributed storage method significantly enhances the fault tolerance of the system. As the amount of data grows, Elasticsearch supports horizontal expansion of the cluster capacity by simply adding nodes to handle more data and query requests. This expansion method does not require downtime and can be dynamically adjusted according to business needs to ensure that system performance always remains at a high level. Because our business is in a stage of rapid growth, we need to continuously add nodes and adjust the node structure, and Elasticsearch meets our growth needs.
[0055] Elasticsearch's high concurrency and real-time performance are very prominent. Its distributed architecture enables it to process a large number of query and data operation requests in parallel, and still maintain high performance in high-concurrency scenarios. This is especially important for processing large-scale data sets and real-time data analysis tasks. In addition, Elasticsearch can automatically balance the distribution of data and query loads among cluster nodes, avoid single-point overload, and improve overall performance. Through intelligent shard allocation and replication mechanisms, the system can efficiently utilize cluster resources to ensure rapid response to queries and data processing. Since our video agent needs to access the RAG system a lot for retrieval and hopes to return content in a timely manner, the mature architecture of Elasticsearch can better solve our problems than ChromaDB.
[0056] Moreover, Elasticsearch has a more powerful ecosystem and functions. The Elasticsearch community has always been very active, with a rich ecosystem, providing a large number of plug-ins and tools, making the development and maintenance of each ES-based system more efficient. Although ChromaDB has certain advantages in processing vector data, our system will process a large amount of multimodal data in the future, including audio, images, etc. Through the plug-ins and custom indexing strategies provided by Elasticsearch, efficient vectorized processing and retrieval can also be achieved. In addition, Elasticsearch's plug-in mechanism allows us to flexibly expand the functionality of the system to ensure that it can cope with complex data processing and retrieval needs.
[0057] We chose Elasticsearch over ChromaDB mainly because of its outstanding performance in processing large-scale text data and providing real-time search and analysis capabilities. At the same time, Elasticsearch's scalability and mature ecosystem make it an indispensable component of our system. This choice not only meets current business needs, but also provides a solid foundation for future expansion and optimization of the system.
[0058] Figure 3 is a flowchart of another content retrieval method provided according to an embodiment of the present disclosure. Figure 3 The content retrieval method of this embodiment may include:
[0059] S301, obtaining a user's query request;
[0060] S302, determining a filtering condition of metadata according to the query request; wherein the filtering condition includes a filtering field and a value of the filtering field;
[0061] S303, matching the attribute information in the metadata of the parent node with the filtering condition to obtain a preliminarily screened parent node that meets the filtering condition; wherein the attribute information includes at least one of the following: chapter name, work name, author, and publishing information;
[0062] S304, matching the query request with the initial content block in the pre-screened parent node to obtain the candidate content block;
[0063] S305, matching the query request with candidate content blocks, and determining a target content block from the candidate content blocks according to the matching result; wherein the candidate content blocks at least include the candidate content blocks.
[0064] The tree index information to which the initial content block belongs includes metadata of the initial content block and metadata in the parent node to which the initial content block belongs. The metadata of the parent node not only stores the initial content blocks belonging to the parent node and the order between the initial content blocks, but also includes at least one of the following attribute information of the content unit to which the parent node belongs, such as a chapter: chapter name, work name, author, and publishing information.
[0065] In the recall stage, metadata filters can also be introduced into the RAG system to significantly improve the accuracy and efficiency of retrieval, especially for query requests with specific requirements. In the recall stage, the metadata filtering conditions can be determined from the query request, that is, the filtering fields and filter field values for the metadata can be obtained; the attribute information of each parent node, the filtering fields in the filtering conditions, and the filter field values are used to determine the primary screening parent nodes that meet the filtering conditions, and other parent nodes are eliminated. Only the query request and the initial content blocks belonging to the primary screening parent node are matched to obtain candidate content blocks, and the first content block and the second content block are determined from the primary screening parent node. By determining the primary screening parent node that meets the filtering conditions, the interference of irrelevant parent nodes and content blocks in irrelevant parent nodes is avoided. This filtering mechanism can more accurately match the user's query intent and greatly improve the relevance of the retrieval results.
[0066] For example, if a user wants to search for the first chapter of The Art of War, and only focuses on the first chapter of the book, the metadata filter can be used to accurately lock in this specific chapter. By using metadata filters during retrieval, other chapters or irrelevant content can be quickly excluded, directly providing the results that best meet the user's needs. This not only saves the user's time, but also improves the overall user experience, making the RAG system more efficient and intelligent when processing complex queries.
[0067] In an optional implementation, determining the metadata filtering condition according to the query request includes: obtaining the metadata filtering condition input by the user in the query request. In order to facilitate the user to use the metadata filtering condition simply and directly. When inputting the query request, the user can also input the filtering condition that he wants to add. By the user directly inputting the filtering condition, the user can accurately control the scope that he wants to query.
[0068] In an optional implementation, determining the filtering condition of the metadata according to the query request includes: inputting the query request into a pre-trained filtering recognition model to obtain the filtering condition.
[0069] Exemplarily, the filter field and the value of the filter field can be extracted from the attribute information in the metadata of the parent node, and the filter field and the value of the filter field are used to construct a training set, and the training set is used to fine-tune BERT (Bidirectional Encoder Representations from Transformers, a pre-trained language representation model) to obtain a filter recognition model. The query request can be input into the filter recognition model to obtain the filter condition. By automatically identifying the filter condition from the query request and avoiding user input, the processing efficiency and flexibility of metadata filtering can be further improved.
[0070] The technical solution provided by the disclosed embodiment introduces metadata filtering in the recall stage. Based on the metadata filtering, each parent node is first screened to obtain the preliminary screened parent nodes that meet the filtering conditions, and other parent nodes are eliminated. Only the query request and the initial content blocks belonging to the preliminary screened parent nodes are matched to obtain the candidate content blocks, thereby avoiding the interference of irrelevant parent nodes and the content blocks in the irrelevant parent nodes, and being able to more accurately match the user's query intention, thereby greatly improving the relevance of the retrieval results.
[0071] In an optional implementation, matching the query request and the candidate content blocks and determining the target content block from the candidate content blocks according to the matching results includes: sorting the query request and each candidate content block by relevance based on preset refined sorting prompt words to obtain a matched target content block.
[0072] In the fine sorting stage, each candidate content block can be integrated into the same fine sorting prompt, and the In-Context Learning (context learning or context learning) capability of the large language model can be used to sort according to the query request and the integrated text, and several candidate content blocks with the highest ranking can be selected as target content blocks and returned to the user. Among them, the In-Context Learning capability is an important learning paradigm, especially when using large-scale pre-trained models, allowing the model to learn and reason in a given context without actually updating the model parameters. By using a large language model to finely sort each candidate content block, it is possible to more accurately find the target content block that is highly relevant to the query request. It should be noted that if the total number of words in each candidate content block exceeds the upper limit of the number of words input by the large language model, the summary and summary of each candidate content block can also be extracted, and the summary and summary of each candidate content block can be integrated into the same fine sorting prompt.
[0073] In an optional implementation, after determining the target content block from the candidate content blocks according to the matching results, the method further includes: obtaining the order of the target content blocks in the corresponding parent node from the metadata of the target content blocks; and integrating each of the target content blocks according to the order of the target content blocks to obtain an integration result.
[0074] For example, the parent node to which the target content block belongs and the order of the target content block in the corresponding parent node can be obtained according to the metadata of the target content block; if any parent node includes multiple target content blocks, the target content blocks can be integrated and reordered according to the order of each target content block to obtain an integrated result, and the integrated result is fed back to the user. By integrating the target content blocks in order, the coherence of the integrated result is improved.
[0075] In addition, if the user needs to use the complete parent node content for content generation tasks, he only needs to reassemble the multiple initial content blocks belonging to the parent node in order according to the guidance of the meta information in the parent node. The above processing is particularly suitable for application scenarios that require contextual coherence, such as video content explanation scenarios.
[0076] Figure 4 1 is a schematic diagram of a content retrieval device according to an embodiment of the present disclosure. The device is suitable for retrieving matching target content blocks for query requests. The device can be implemented in software and / or hardware and can be integrated into electronic devices. Figure 4 As shown, the content retrieval device 400 of this embodiment may include:
[0077] A query request module 410 is used to obtain a user's query request;
[0078] The candidate content block module 420 is used to determine the candidate content blocks from the initial content blocks according to the query request and the tree index information to which the initial content blocks belong; wherein the tree index information includes the metadata of the initial content blocks and the metadata in the parent node to which the initial content blocks belong;
[0079] The target content block module 430 is used to match the query request with the candidate content blocks, and determine the target content block from the candidate content blocks according to the matching result; wherein the candidate content blocks at least include the candidate content blocks.
[0080] In an optional implementation, the candidate content block module 420 includes:
[0081] a first content block unit, configured to match the query request with the initial content block, and determine a first content block from the initial content block according to a matching result;
[0082] The second content block unit is used to determine a second content block matching the first content block from the remaining initial content blocks according to the metadata of the first content block and the metadata in the first parent node to which the first content block belongs, wherein the candidate content blocks include the first content block and the second content block.
[0083] In an optional implementation manner, the second content block unit is specifically configured to include:
[0084] Determining, according to the metadata of the first content block, a first parent node to which the first content block belongs;
[0085] Determining each initial content block belonging to the first parent node according to the metadata in the first parent node;
[0086] If the ratio of the number of first content blocks in any first parent node to the number of initial content blocks in the first parent node is greater than a preset ratio threshold, the remaining initial content blocks in the first parent node are all used as second content blocks matching the first content block.
[0087] In an optional implementation manner, the candidate content block module 420 further includes a third content block unit, and the third content block unit is specifically used to:
[0088] Performing entity recognition on the first content block and the remaining initial content blocks respectively to obtain a first entity included in the first content block and an initial entity included in the remaining initial content blocks;
[0089] According to the first entity and the initial entity, a third content block associated with the first content block is determined from the remaining initial content blocks; wherein the candidate content blocks also include the third content block.
[0090] In an optional implementation manner, the first content block unit includes:
[0091] a semantic similarity subunit, configured to encode the query request to obtain a query vector, and determine a semantic similarity between the query vector and a vector representation of each of the initial content blocks;
[0092] a content relevance subunit, configured to determine the content relevance between the query request and the initial content block according to the word frequency, the inverse document frequency and the document length of the initial content block of the query word in the query request;
[0093] The first content block subunit is configured to select the first content block from the initial content blocks according to the semantic similarity and the content relevance.
[0094] In an optional implementation manner, the first content block sub-unit is specifically used for:
[0095] Determining a first range of semantic similarities according to the semantic similarities of each initial content block, and processing each semantic similarity using the first range to obtain processed semantic similarities;
[0096] Determining a second range of content similarity according to the content similarity of each initial content block, and processing each content similarity using the second range to obtain a processed content similarity;
[0097] The first content block is selected from the initial content blocks according to the processed semantic similarities and the processed content similarities of the initial content blocks.
[0098] In an optional implementation, the initial content block is stored in an Elasticsearch database.
[0099] In an optional implementation, the candidate content block module 420 includes:
[0100] A filtering condition unit, used to determine a filtering condition of metadata according to the query request; wherein the filtering condition includes a filtering field and a value of the filtering field;
[0101] A primary screening parent node unit, used for matching the attribute information in the metadata of the parent node with the filtering condition to obtain the primary screening parent node that meets the filtering condition; wherein the attribute information includes at least one of the following: chapter name, work name, author, and publishing information;
[0102] The candidate content block unit is used to match the query request with the initial content block in the primary screening parent node to obtain the candidate content block.
[0103] In an optional implementation manner, the filtering condition unit is specifically used to:
[0104] Obtaining the filtering condition of the metadata entered by the user in the query request; or,
[0105] The query request is input into a pre-trained filtering recognition model to obtain filtering conditions.
[0106] In an optional implementation manner, the target content block module 430 is specifically used to:
[0107] Based on the preset refined sorting prompt words, the query request and each candidate content block are sorted by relevance to obtain a matching target content block.
[0108] In an optional implementation manner, the content retrieval device 400 further includes a target integration module, and the target integration module is specifically used to:
[0109] Acquire the order of the target content block in the corresponding parent node from the metadata of the target content block;
[0110] The target content blocks are integrated according to the sorting order of the target content blocks to obtain an integration result.
[0111] The content retrieval device provided in the embodiment of the present invention can execute the content retrieval method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0112] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0113] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, an artificial intelligence agent, a readable storage medium and a computer program product.
[0114] Figure 5 It is a block diagram of an electronic device used to implement the content retrieval method of the embodiment of the present disclosure. Figure 5 A schematic block diagram of an example electronic device 500 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0115] like Figure 5 As shown, the electronic device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 can also be stored. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0116] Multiple components in the electronic device 500 are connected to the I / O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the electronic device 500 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0117] The computing unit 501 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above, such as the content retrieval method. For example, in some embodiments, the content retrieval method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, one or more steps of the content retrieval method described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform the content retrieval method in any other appropriate manner (e.g., by means of firmware).
[0118] Figure 5A schematic block diagram of an example electronic device 500 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0119] like Figure 5 As shown, the electronic device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 can also be stored. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0120] Multiple components in the electronic device 500 are connected to the I / O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the electronic device 500 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0121] The computing unit 501 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above, such as the content retrieval method. For example, in some embodiments, the content retrieval method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, one or more steps of the content retrieval method described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform the content retrieval method in any other appropriate manner (e.g., by means of firmware).
[0122] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0123] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0124] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0125] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, audio input, or tactile input).
[0126] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communications network). Examples of communications networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0127] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0128] Artificial intelligence is a discipline that studies how to use computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.). It includes both hardware-level and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include computer vision technology, audio recognition technology, natural language processing technology, machine learning / deep learning technology, big data processing technology, knowledge graph technology, and other major directions.
[0129] Cloud computing refers to a technology system that uses network access to elastically scalable shared physical or virtual resource pools. Resources can include servers, operating systems, networks, software, applications, and storage devices, and can be deployed and managed on demand and in a self-service manner. Cloud computing technology can provide efficient and powerful data processing capabilities for technical applications such as artificial intelligence and blockchain, as well as model training.
[0130] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0131] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A content retrieval method, comprising: Get the user's query request; Determine a candidate content block from the initial content block according to the query request and the tree index information to which the initial content block belongs; wherein the tree index information includes metadata of the initial content block and metadata in a parent node to which the initial content block belongs; The query request and the candidate content blocks are matched, and a target content block is determined from the candidate content blocks according to the matching result; wherein the candidate content blocks at least include the candidate content blocks.
2. The method according to claim 1, wherein: The step of determining a candidate content block from the initial content block according to the query request and the tree index information to which the initial content block belongs includes: matching the query request with the initial content block, and determining a first content block from the initial content block according to the matching result; According to the metadata of the first content block and the metadata in the first parent node to which the first content block belongs, a second content block matching the first content block is determined from the remaining initial content blocks, and the candidate content blocks include the first content block and the second content block.
3. The method according to claim 2, wherein: The determining, from the remaining initial content blocks, a second content block matching the first content block according to the metadata of the first content block and the metadata in the first parent node to which the first content block belongs, comprises: Determining, according to the metadata of the first content block, a first parent node to which the first content block belongs; Determining each initial content block belonging to the first parent node according to the metadata in the first parent node; If the ratio of the number of first content blocks in any first parent node to the number of initial content blocks in the first parent node is greater than a preset ratio threshold, the remaining initial content blocks in the first parent node are all used as second content blocks matching the first content block.
4. The method according to claim 2, after determining the first content block from the initial content block according to the matching result, further comprising: Performing entity recognition on the first content block and the remaining initial content blocks respectively to obtain a first entity included in the first content block and an initial entity included in the remaining initial content blocks; According to the first entity and the initial entity, a third content block associated with the first content block is determined from the remaining initial content blocks; wherein the candidate content blocks also include the third content block.
5. The method according to claim 2, wherein: The step of matching the query request with the initial content block and determining the first content block from the initial content block according to the matching result includes: Encoding the query request to obtain a query vector, and determining a semantic similarity between the query vector and a vector representation of each of the initial content blocks; Determining the content relevance between the query request and the initial content block according to the word frequency, inverse document frequency and document length of the query word in the query request in the initial content block; The first content block is selected from the initial content blocks according to the semantic similarity and the content relevance.
6. The method according to claim 5, wherein: The selecting the first content block from the initial content blocks according to the semantic similarity and the content relevance includes: Determining a first range of semantic similarities according to the semantic similarities of each initial content block, and processing each semantic similarity using the first range to obtain processed semantic similarities; Determining a second range of content similarity according to the content similarity of each initial content block, and processing each content similarity using the second range to obtain a processed content similarity; The first content block is selected from the initial content blocks according to the processed semantic similarities and the processed content similarities of the initial content blocks.
7. The method according to claim 5, wherein: The initial content block is stored in an Elasticsearch database.
8. The method according to claim 1, wherein: The step of determining, from the initial content block, a candidate content block matching the query request according to the query request and the tree index information to which the initial content block belongs, comprises: Determining a filtering condition for metadata according to the query request; wherein the filtering condition includes a filtering field and a value of the filtering field; Matching the attribute information in the metadata of the parent node with the filtering condition to obtain a primary screening parent node that meets the filtering condition; wherein the attribute information includes at least one of the following: chapter name, work name, author, and publishing information; The query request is matched with the initial content block in the primary screening parent node to obtain the candidate content block.
9. The method according to claim 8, wherein: The determining of the filtering condition of the metadata according to the query request includes: Obtaining the filtering condition of the metadata entered by the user in the query request; or, The query request is input into a pre-trained filtering recognition model to obtain filtering conditions.
10. The method according to claim 1, wherein: The step of matching the query request with the candidate content blocks and determining a target content block from the candidate content blocks according to the matching result includes: Based on the preset refined sorting prompt words, the query request and each candidate content block are sorted by relevance to obtain a matching target content block.
11. The method according to claim 1, after determining the target content block from the candidate content blocks according to the matching results, further comprising: Acquire the order of the target content block in the corresponding parent node from the metadata of the target content block; The target content blocks are integrated according to the sorting order of the target content blocks to obtain an integration result.
12. A content retrieval device, comprising: A query request module is used to obtain the user's query request; A candidate content block module, configured to determine a candidate content block from the initial content block according to the query request and the tree index information to which the initial content block belongs; wherein the tree index information includes metadata of the initial content block and metadata in a parent node to which the initial content block belongs; The target content block module is used to match the query request with the candidate content blocks, and determine the target content block from the candidate content blocks according to the matching result; wherein the candidate content blocks at least include the candidate content blocks.
13. The device according to claim 12, wherein: The candidate content block module includes: a first content block unit, configured to match the query request with the initial content block, and determine a first content block from the initial content block according to a matching result; The second content block unit is used to determine a second content block matching the first content block from the remaining initial content blocks according to the metadata of the first content block and the metadata in the first parent node to which the first content block belongs, wherein the candidate content blocks include the first content block and the second content block.
14. The device according to claim 13, wherein: The second content block unit is specifically configured to include: Determining, according to the metadata of the first content block, a first parent node to which the first content block belongs; Determining each initial content block belonging to the first parent node according to the metadata in the first parent node; If the ratio of the number of first content blocks in any first parent node to the number of initial content blocks in the first parent node is greater than a preset ratio threshold, the remaining initial content blocks in the first parent node are all used as second content blocks matching the first content block.
15. The device according to claim 13, wherein the candidate content block module further comprises a third content block unit, wherein the third content block unit is specifically configured to: Performing entity recognition on the first content block and the remaining initial content blocks respectively to obtain a first entity included in the first content block and an initial entity included in the remaining initial content blocks; According to the first entity and the initial entity, a third content block associated with the first content block is determined from the remaining initial content blocks; wherein, The candidate content blocks also include the third content block.
16. The device according to claim 13, wherein: The first content block unit includes: a semantic similarity subunit, configured to encode the query request to obtain a query vector, and determine a semantic similarity between the query vector and a vector representation of each of the initial content blocks; a content relevance subunit, configured to determine the content relevance between the query request and the initial content block according to the word frequency, the inverse document frequency and the document length of the initial content block of the query word in the query request; The first content block subunit is configured to select the first content block from the initial content blocks according to the semantic similarity and the content relevance.
17. The device according to claim 16, wherein: The first content block sub-unit is specifically used for: Determining a first range of semantic similarities according to the semantic similarities of each initial content block, and processing each semantic similarity using the first range to obtain processed semantic similarities; Determining a second range of content similarity according to the content similarity of each initial content block, and processing each content similarity using the second range to obtain a processed content similarity; The first content block is selected from the initial content blocks according to the processed semantic similarities and the processed content similarities of the initial content blocks.
18. The device according to claim 16, wherein: The initial content block is stored in an Elasticsearch database.
19. The device according to claim 12, wherein: The candidate content block module includes: A filtering condition unit, used to determine a filtering condition of metadata according to the query request; wherein the filtering condition includes a filtering field and a value of the filtering field; A primary screening parent node unit, used for matching the attribute information in the metadata of the parent node with the filtering condition to obtain the primary screening parent node that meets the filtering condition; wherein the attribute information includes at least one of the following: chapter name, work name, author, and publishing information; The candidate content block unit is used to match the query request with the initial content block in the primary screening parent node to obtain the candidate content block.
20. The device according to claim 19, wherein The filtering condition unit is specifically used for: Obtaining the filtering condition of the metadata entered by the user in the query request; or, The query request is input into a pre-trained filtering recognition model to obtain filtering conditions.
21. The device according to claim 12, wherein: The target content block module is specifically used for: Based on the preset refined sorting prompt words, the query request and each candidate content block are sorted by relevance to obtain a matching target content block.
22. The device according to claim 12, further comprising a target integration module, wherein the target integration module is specifically configured to: Acquire the order of the target content block in the corresponding parent node from the metadata of the target content block; The target content blocks are integrated according to the sorting order of the target content blocks to obtain an integration result.
23. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 11.
24. An artificial intelligence agent configured to execute the method according to any one of claims 1-11.
25. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to make a computer execute the method according to any one of claims 1-11.
26. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 11.
Citation Information
Cited By
Retrieval generation optimization method based on long-term enhancement, medium and system
CN119494410A
Charging station management system intelligent question and answer method, electronic equipment and storage medium
CN120448603A
