A sentence query method and device, electronic equipment and storage medium
By generating semantic vectors and document rating results, the accuracy and completeness of the retrieval process are improved, solving the problems of semantic ambiguity and retrieval delay in existing technologies, and achieving more efficient information retrieval.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-18
- Publication Date
- 2026-07-10
AI Technical Summary
Existing search augmentation generation (RAG) techniques cannot eliminate semantic ambiguity when faced with spelling errors, terminological ambiguities, or unclear references in user input. This results in a significant deviation between search results and user input, and the retrieval latency increases significantly when dealing with large amounts of data, making it difficult to meet the response requirements of real-time question answering.
By determining the semantic vector of the query statement, a target candidate document set is generated, and the query result set is determined based on the document scoring results. A pre-trained scoring model is used for multi-dimensional evaluation, and a large language model is combined for fine ranking to improve the matching degree and response speed.
It improves the matching degree between user input and search results, enhances search accuracy and response speed, and solves the problems of semantic ambiguity and delay in searching large amounts of documents.
Smart Images

Figure CN122364374A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a statement query method, apparatus, electronic device, and storage medium. Background Technology
[0002] Currently, information retrieval primarily relies on traditional Retrieval-Augmented Generation (RAG) techniques. Existing RAG techniques mainly combine external knowledge retrieval with large language models. For example, keyword-based full-text search uses the BM25 algorithm to match user input with document content, which is suitable for the rapid location of explicit information.
[0003] User input often contains spelling errors, ambiguous terms, or unclear referents. Existing RAG methods rely on simple keyword matching or fixed rules, which cannot eliminate semantic ambiguity, leading to significant discrepancies between search results and user input. Furthermore, traditional RAG methods depend on single vector databases or simple text retrieval; when faced with large amounts of documents, the time complexity of vector similarity calculation increases linearly with the data volume. This significantly increases retrieval latency, making it difficult to meet the response requirements of real-time question answering. Summary of the Invention
[0004] This invention provides a statement query method, apparatus, electronic device, and storage medium to improve the matching degree between user input and search results, and to improve the accuracy and response speed of the search.
[0005] According to one aspect of the present invention, a statement query method is provided, comprising: Determine the query statement and the semantic vector corresponding to the query statement, wherein the semantic vector is related to the lexical units contained in the query statement; The semantic vector is retrieved to generate a target candidate document set, which includes at least one target candidate document and documents related to the query statement. For each target candidate document, the target candidate document is evaluated based on the query statement to obtain a document score result corresponding to the target candidate document. The document score result indicates the relevance of the target candidate document to the query statement. Based on the target candidate document set and the document rating results corresponding to each target candidate document, a query result set corresponding to the query statement is determined. The query result set consists of target candidate documents in the target candidate document set that meet set conditions, and the set conditions are related to the numerical values of each document rating result.
[0006] According to another aspect of the present invention, a statement query apparatus is provided, comprising: The first determining module is used to determine the query statement and the semantic vector corresponding to the query statement, wherein the semantic vector is related to the word elements contained in the query statement; A generation module is used to retrieve the semantic vector and generate a target candidate document set, wherein the target candidate document set includes at least one target candidate document, and the target candidate document includes documents related to the query statement; An evaluation module is used to evaluate each target candidate document based on the query statement to obtain a document score result corresponding to the target candidate document. The document score result indicates the relevance of the target candidate document to the query statement. The second determining module is used to determine the query result set corresponding to the query statement based on the target candidate document set and the document rating results corresponding to each target candidate document. The query result set consists of target candidate documents in the target candidate document set that meet set conditions, and the set conditions are related to the numerical values of each document rating result.
[0007] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the statement query method according to any embodiment of the present invention.
[0008] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the statement query method described in any embodiment of the present invention.
[0009] The technical solution of this invention involves determining a query statement and its corresponding semantic vector; retrieving the semantic vector to generate a target candidate document set; evaluating each target candidate document based on the query statement to obtain a document score result; and determining the query result set corresponding to the query statement based on the target candidate document set and the document score results of each target candidate document. By retrieving the semantic vector corresponding to the query statement to generate the target candidate document set, the accuracy and completeness of the retrieval process are achieved. Determining the query result set through document score results improves the matching degree between the user-input query statement and the query result set, thereby improving retrieval accuracy and response speed.
[0010] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a flowchart of a statement query method provided according to Embodiment 1 of the present invention; Figure 2 This is a flowchart of an evaluation method provided according to Embodiment 2 of the present invention; Figure 3 This is a schematic diagram of the structure of a statement query device provided in Embodiment 3 of the present invention; Figure 4 This is a block diagram of an electronic device provided according to Embodiment 4 of the present invention. Detailed Implementation
[0013] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0014] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0015] It is understood that before using the technical methods disclosed in the various embodiments of the present invention, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in the present invention and their authorization should be obtained in accordance with relevant laws and regulations through appropriate means.
[0016] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to autonomously choose whether to provide personal information to the software or hardware, such as the electronic device, application program, server, or storage medium performing the operations of this invention, based on the prompt message.
[0017] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0018] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this disclosure.
[0019] Example 1 Figure 1 This is a flowchart of a statement query method according to Embodiment 1 of the present invention. This embodiment is applicable to the query of statements. The method can be executed by a statement query device, which can be implemented in hardware and / or software and can be configured in an electronic device. Figure 1 As shown, the method includes: S110. Determine the query statement and the semantic vector corresponding to the query statement.
[0020] The semantic vector is related to the terms contained in the query statement.
[0021] In this embodiment, the query statement can be understood as a statement entered by the user, which consists of at least one term. The semantic vector can be understood as the vector corresponding to the query statement, which may include the term of the query statement and the term associated with that term.
[0022] Specifically, the process involves determining the query statement input by the user and performing error correction, calibration, and semantic enhancement on the query statement to generate a semantic vector corresponding to the query statement. In the semantic enhancement stage, the lexical units of the query statement are first determined, and these lexical units are anchored to knowledge graph nodes in the domain to which they belong. Then, lexical units associated with these lexical units are searched, ultimately yielding the semantic vector corresponding to the query statement.
[0023] S120. Retrieve the semantic vector to generate a target candidate document set.
[0024] The target candidate document set includes at least one target candidate document, and the target candidate document includes documents related to the query statement.
[0025] In this embodiment, the target candidate document set can be understood as the collection of target candidate documents. Target candidate documents can be understood as documents related to the query statement, and can be documents obtained by searching based on the semantic vector corresponding to the query statement.
[0026] Specifically, the semantic vector is retrieved to obtain at least one initial candidate document related to the query. Based on the score between the initial candidate document and the semantic vector, the initial candidate documents are ranked. The ranked initial candidate documents are determined as target candidate documents, and the set of all ranked target candidate documents is determined as the target candidate document set.
[0027] For example, semantic vectors are retrieved to obtain a Top-K target candidate document set from the multi-path recall module.
[0028] S130. For each target candidate document, evaluate the target candidate document based on the query statement to obtain the document score result corresponding to the target candidate document.
[0029] The document scoring result indicates the relevance of the target candidate document to the query statement.
[0030] In this embodiment, the document scoring result can be understood as the scoring result of the target candidate document, which can indicate the relevance of the target candidate document to the query statement.
[0031] Specifically, for each target candidate document, a pre-trained scoring model is used to evaluate it from multiple dimensions. The evaluation results from these multiple dimensions are then fused to obtain the document score for each target candidate document.
[0032] S140. Based on the target candidate document set and the document scoring results corresponding to each target candidate document, determine the query result set corresponding to the query statement.
[0033] The query result set consists of target candidate documents in the target candidate document set that meet the set conditions, and the set conditions are related to the numerical values of the score results of each document.
[0034] In this embodiment, the query result set can be understood as the query result of the query statement, and the query result set consists of target candidate documents that meet the set conditions. The set conditions may be to select at least one target candidate document with a larger numerical value among the document rating results corresponding to the target candidate documents.
[0035] Specifically, the target candidate documents in the target candidate document set are sorted based on their document rating results. Target candidate documents that meet the set criteria are selected from the target candidate document set, and the set of these target candidate documents is used as the query result set corresponding to the query statement.
[0036] For example, based on the document score results corresponding to each target candidate document in the Top-K target candidate document set, the target candidate documents in the Top-K target candidate document set are sorted and then finely ranked using a large language model (LLM) to generate a Top-10 query result set.
[0037] The technical solution of this invention involves determining a query statement and its corresponding semantic vector; retrieving the semantic vector to generate a target candidate document set; evaluating each target candidate document based on the query statement to obtain a document score result; and determining the query result set corresponding to the query statement based on the target candidate document set and the document score results of each target candidate document. By retrieving the semantic vector corresponding to the query statement to generate the target candidate document set, the accuracy and completeness of the retrieval process are achieved. Determining the query result set through document score results improves the matching degree between the user-input query statement and the query result set, thereby improving retrieval accuracy and response speed.
[0038] Based on the above embodiments, modified embodiments of the above embodiments are proposed. It should be noted that, in order to keep the description brief, only the differences from the above embodiments are described in the modified embodiments.
[0039] In one embodiment, determining the query result set corresponding to the query statement based on the target candidate document set and the document scoring results corresponding to each target candidate document includes: For each target candidate document, the document score result is mapped to a standardized weight. The standardized weights are updated based on the feedback signal to obtain the updated weights corresponding to each standardized weight. The feedback signal is related to the click-through rate of the target candidate document. For each target candidate document in the target candidate document set, if the updated weight of the target candidate document satisfies the set condition, the target candidate document is placed into the query result set corresponding to the query statement.
[0040] In this embodiment, the standardized weight can be understood as the result obtained by mapping the document scoring results, and the standardized weight can indicate the degree of correlation between the target candidate document and the query statement. The updated weight can be understood as the weight obtained after updating the standardized weight based on user feedback signals.
[0041] Specifically, for each target candidate document, the document rating result is mapped to standardized weights through a learnable fully connected layer. The values of each standardized weight are adjusted in real time based on a reinforcement learning framework (PPO algorithm). A reward function is calculated using user feedback signals (such as the click-through rate of the target candidate document), and the standardized weights are updated using a gradient ascent strategy based on the reward function. For each target candidate document in the target candidate document set, if the updated weight of the target candidate document meets a set condition, the target candidate document is added to the query result set corresponding to the query statement. For example, the set of the first predetermined number of target candidate documents in the target candidate document set is used as the query result set.
[0042] For example, when determining the query result set for queries of varying complexity, a traditional cross-encoder (such as MiniLM-L12) is used to quickly sort the candidate documents for simple queries (e.g., entity class queries). For complex queries (requiring logical reasoning or multi-hop retrieval), a large language model is invoked, and a lightweight classifier (based on query length, entity density, and intent complexity features) dynamically sorts the candidate documents. The final output query result set is then interpreted by the interpretability module to generate the reasons for the sorting of the candidate documents.
[0043] In one embodiment, retrieving the semantic vector to generate a target candidate document set includes: The semantic vector is retrieved to determine an initial candidate document set corresponding to the semantic vector, wherein the initial candidate document set includes at least one initial candidate document; The semantic vector is semantically projected to obtain the query embedding vector corresponding to the semantic vector, and the query embedding vector includes a vector after the semantic vector is aligned. For each initial candidate document, a search score is determined between the initial candidate document and the query embedding vector. The search score includes a weighted sum of a keyword retrieval score and a cosine similarity score. The keyword retrieval score is related to the number of keywords contained in the query embedding vector of the initial candidate document. The cosine similarity score is related to the cosine similarity between the query embedding vector and the vector corresponding to the initial candidate document. Based on the search score values, the initial candidate documents in the initial candidate document set are sorted to obtain the target candidate document set.
[0044] In this embodiment, the initial candidate document set can be understood as the collection formed by the initial candidate documents. The initial candidate documents can be understood as documents obtained based on the query statement. The query embedding vector can be understood as a vector obtained by projecting a semantic vector onto a unified semantic space. The search score can be understood as a score between the initial candidate documents and the query embedding vector, indicating the degree of matching between them. The keyword retrieval score is determined based on the number of keywords contained in the query embedding vectors included in the initial candidate documents, indicating the degree of matching between the keywords contained in the query embedding vectors and the initial candidate documents. The cosine similarity score can be understood as the numerical value of the cosine similarity between the query embedding vector and the corresponding vector of the initial candidate document.
[0045] For example, semantic vectors are retrieved, and initial candidate documents corresponding to the semantic vectors are determined in an existing database. These initial candidate documents then form an initial candidate document set. To map semantic vectors from different modalities to a unified semantic space and address scale and distribution differences between modalities, semantic projection is performed on the semantic vectors to obtain the query embedding vectors corresponding to the semantic vectors. Semantic projection can be performed on the semantic vectors using a dynamic semantic projection network. This dynamic semantic projection network includes a lightweight residual adapter that projects the semantic vectors (zraw) onto a shared semantic space, as follows: Where W1 and W2 are learnable parameter matrices. A gating mechanism is also introduced to dynamically adjust the projection intensity through attention weights. , where σ is the Sigmoid function, Wg is the gating weight matrix, and finally the multimodal aligned query embedding vector is obtained.
[0046] For each initial candidate document, a search score is determined between the initial candidate document and the query embedding vector. The search score includes a weighted sum of the keyword retrieval score and the cosine similarity score. Keyword retrieval score: Explicit keywords are matched in the `text` field using the BM25 algorithm; Cosine similarity score: The cosine similarity between the query embedding vector and the document vector corresponding to the initial candidate document is calculated in the `unified_vector` field; Dynamic score fusion: The keyword retrieval score and the cosine similarity score from BM25 are weighted and summed through the `rank_feature` interface to generate the search score between the initial candidate document and the query embedding vector, and the target candidate document set for comprehensive ranking is determined based on the search score.
[0047] Furthermore, when determining the query embedding vector, joint adversarial training can be performed using the total loss function of the joint training objective. The total loss function is a weighted sum of the contrastive loss function and the adversarial loss function. The contrastive loss function: The goal of the triplet contrastive learning module is to narrow the embedding distance of semantically relevant samples corresponding to semantic vectors and push away irrelevant samples. A triple consists of an Anchor `a`, which randomly selects a sample from one modality; Positive `p`, which represents other modal samples semantically consistent with the Anchor; and Negative `n`, which represents other modal samples unrelated to the Anchor. A modality weight factor `am` is introduced into the contrastive loss function `Lcontrast` to dynamically balance the contributions of different modalities. The contrastive loss function `Lcontrast` is calculated as follows: Where M is the modality set (text, image, speech, etc.), am is dynamically adjusted through learnable parameters, and τ is a temperature coefficient that controls the smoothness of the distribution. Adversarial loss function: The goal of adversarial training is to eliminate distribution differences between modalities, forcing the encoder to generate modality-independent semantic representations. Adversarial training includes a generator G, which is a feature encoder for each modality (such as CLIP or Wav2Vec), sharing the underlying Transformer layer, used to maximize the prediction error of the discriminator D; the discriminator D is a multilayer perceptron (MLP), taking the embedding vector z as input and outputting the modality type probability D(z), used to accurately distinguish the modality origin of the embedding vector. To force the generator to generate modality-independent semantic representations by minimizing the modality classification ability of the discriminator, the adversarial loss function Ladv is used, calculated as follows: .
[0048] In one embodiment, determining the query statement and the semantic vector corresponding to the query statement includes: Determine the query statement and the modality type corresponding to the query statement, wherein the query statement includes a statement composed of information of at least one modality; Based on the modality type, determine the initial semantic vector corresponding to the query statement; For each query term contained in the initial semantic vector, determine the semantic related words corresponding to the query term, wherein the semantic related words include terms that belong to the same domain as the query term; Each of the semantic related words is injected into the initial semantic vector to obtain the semantic vector corresponding to the query statement.
[0049] In this embodiment, modality type can be understood as information indicating the type of the query statement, which may include text type, image type, and speech type. The initial semantic vector can be understood as a vector obtained by structurally transforming the query statement, and the initial semantic vector consists of at least one query term. The query term is obtained by transforming the words contained in the query statement. Semantic related words can be understood as terms that are related to the query term; semantic related words can be terms belonging to the same domain as the query term.
[0050] Specifically, the modality type of the query statement is determined. For different modality types, different methods are used to convert the query statement into an initial semantic vector. For each word in the initial semantic vector, a context-aware error detection network is constructed using the encoder structure of a pre-trained language model (such as BERT). The abnormal probability distribution of each word is calculated through a self-attention mechanism. Combined with a dynamically generated domain confusion matrix (containing a general spelling error library, a domain terminology whitelist, and a homophone mapping table), the abnormal words are weighted and corrected, and the corrected words are used as the query words. For each query word, the key terms corresponding to the query word are anchored to domain knowledge graph nodes through a knowledge graph entity linking network. Simultaneously, a thesaurus expansion network based on bidirectional gated recurrent units (BiGRU) is triggered to search for semantic related words from a pre-loaded domain terminology library and inject the semantic related words into the initial semantic vector to generate the semantic vector corresponding to the query statement.
[0051] Optionally, determining the initial semantic vector corresponding to the query statement based on the modality type includes: When the modality type indicates that the query statement is of text type, the query statement is divided into blocks to generate a text semantic vector, and the text semantic vector is determined as the initial semantic vector corresponding to the query statement; When the modality type indicates that the query statement is an image type, the text content and visual features of the query statement are extracted respectively, a joint image-text embedding vector is generated from the text content and the visual features, and the joint image-text embedding vector is determined as the initial semantic vector corresponding to the query statement; When the modality type indicates that the query statement is a speech type, the query statement is transcribed into speech to generate a text sequence vector, and the text sequence vector is determined as the initial semantic vector corresponding to the query statement.
[0052] In this embodiment, the text semantic vector can be understood as the initial semantic vector corresponding to the text-type query statement. The image-text joint embedding vector can be understood as the initial semantic vector corresponding to the image-type query statement. The text sequence vector can be understood as the initial semantic vector corresponding to the speech-type query statement.
[0053] For example, for text-type queries, a dynamic chunking strategy is used to segment the query into chunks, adaptively adjusting the chunk size based on the query content, setting overlapping windows to preserve context, and generating text semantic vectors using a series of sentence-transformers models. For image-type queries, OCR technology is used to extract the text content, and CLIP visual encoder is used to extract the visual features of the query. A joint image-text embedding vector is generated from the text content and visual features to achieve spatial alignment between visual features and text content. For speech-type queries, the Wav2Vec 2.0 acoustic model is used for end-to-end speech transcription, generating a text sequence which is then vectorized using sentence-transformers. Simultaneously, acoustic features such as Mel-frequency cepstral coefficients are extracted as auxiliary modal information. Combining the vectorized sequence and auxiliary modal information, a text sequence vector is generated.
[0054] Example 2 Figure 2 This is a flowchart of an evaluation method according to Embodiment 2 of the present invention. This embodiment focuses on the method for evaluating target candidate documents described in the above embodiments. Figure 2 As shown, the method includes: S210. Determine the query statement and the semantic vector corresponding to the query statement.
[0055] S220. Retrieve the semantic vector to generate a target candidate document set.
[0056] S230. For each target candidate document, execute S231-S233.
[0057] S231. Based on the query statement, construct the structured input sequence corresponding to the target candidate document.
[0058] In this embodiment, the structured input sequence can be understood as the information obtained after performing a structured operation on the query statement and the target candidate document.
[0059] Specifically, the structured information of the target candidate documents is determined, and this structured information, along with the query statement, is combined to form a structured input sequence. The structured information may include information indicating the source and timeliness of the target candidate documents.
[0060] Optionally, constructing the structured input sequence corresponding to the target candidate document based on the query statement includes: Determine the metadata corresponding to the target candidate document, wherein the metadata includes the features of the target candidate document; Identify document fragments in the target candidate documents that are related to the query statement; The structured input sequence corresponding to the target candidate document is composed of the query statement, the document fragment content, and the metadata.
[0061] In this embodiment, metadata can be understood as data indicating the characteristics of the target candidate document, and metadata may include the source and timeliness of the target candidate document. Document-related fragments can be understood as fragments in the target candidate document that are related to the query statement.
[0062] Specifically, the metadata indicating the source and timeliness of the target candidate documents is determined, and content related to the query statement is searched within the target candidate documents as document fragment content. The query statement, document fragment content, and metadata are then processed in a structured manner to obtain the structured input sequence corresponding to the target candidate documents.
[0063] S232. Determine the semantic interaction matrix corresponding to the structured input sequence.
[0064] The semantic interaction matrix is composed of features of the structured input sequence.
[0065] In this embodiment, the semantic interaction matrix can be understood as fine-grained features in the structured input sequence.
[0066] Specifically, a cross-attention layer can be used to calculate the semantic interaction matrix corresponding to the structured input sequence. The semantic interaction matrix includes fine-grained relevance features of the structured input sequence.
[0067] S233. Input the semantic interaction matrix into the scoring model to obtain the document scoring result corresponding to the target candidate document.
[0068] In this embodiment, the scoring model can be understood as a model used to score the semantic interaction matrix, and the scoring model can be a deep learning model based on the self-attention mechanism.
[0069] Specifically, the semantic interaction matrix is input into the scoring model, which outputs relevance score (based on the semantic coverage of the query and document), integrity score (based on the coverage ratio of key sub-questions) and credibility score (based on the authority level of the document source) in parallel. The relevance score, integrity score and credibility score are then fused into the document scoring result corresponding to the target candidate document through a learnable fully connected layer.
[0070] S240. Based on the target candidate document set and the document scoring results corresponding to each target candidate document, determine the query result set corresponding to the query statement.
[0071] The technical solution of this invention involves constructing a structured input sequence corresponding to the target candidate document based on the query statement; determining the semantic interaction matrix corresponding to the structured input sequence; and inputting the semantic interaction matrix into a scoring model to obtain the document scoring result corresponding to the target candidate document. By constructing the semantic interaction matrix corresponding to the query statement, the quality of information input into the scoring model is improved, reducing the impact of semantic ambiguity, misinterpretation, and modal fragmentation on the query result set. Determining the document scoring result through the scoring model deeply integrates information from multiple modalities, improving retrieval accuracy and response speed.
[0072] Example 3 Figure 3 This is a schematic diagram of the structure of a statement query device provided according to Embodiment 3 of the present invention. Figure 3 As shown, the device includes: The first determining module 310 is used to determine the query statement and the semantic vector corresponding to the query statement, wherein the semantic vector is related to the word elements contained in the query statement; The generation module 320 is used to retrieve the semantic vector and generate a target candidate document set, wherein the target candidate document set includes at least one target candidate document, and the target candidate document includes documents related to the query statement; Evaluation module 330 is used to evaluate each target candidate document based on the query statement to obtain a document score result corresponding to the target candidate document, wherein the document score result indicates the relevance of the target candidate document to the query statement; The second determining module 340 is used to determine the query result set corresponding to the query statement based on the target candidate document set and the document rating results corresponding to each target candidate document. The query result set consists of target candidate documents in the target candidate document set that meet set conditions, and the set conditions are related to the numerical values of each document rating result.
[0073] The technical solution of this invention involves: a first determining module determining the query statement and its corresponding semantic vector; a generation module retrieving the semantic vector to generate a target candidate document set; an evaluation module evaluating each target candidate document based on the query statement to obtain a document score; and a second determining module determining the query result set corresponding to the query statement based on the target candidate document set and the document score results. Through the cooperation of these modules, the semantic vector corresponding to the query statement is retrieved, and the target candidate document set is generated, achieving accuracy and completeness in the retrieval process. Determining the query result set based on the document score results improves the matching degree between the user-input query statement and the query result set, thereby enhancing retrieval accuracy and response speed.
[0074] In one embodiment, the evaluation module 330 includes: The construction unit is used to construct a structured input sequence corresponding to the target candidate document based on the query statement; The first determining unit is used to determine the semantic interaction matrix corresponding to the structured input sequence, wherein the semantic interaction matrix is composed of the features of the structured input sequence; The input unit is used to input the semantic interaction matrix into the scoring model to obtain the document scoring result corresponding to the target candidate document.
[0075] In one embodiment, the building unit is specifically used for: Determine the metadata corresponding to the target candidate document, wherein the metadata includes the features of the target candidate document; Identify document fragments in the target candidate documents that are related to the query statement; The structured input sequence corresponding to the target candidate document is composed of the query statement, the document fragment content, and the metadata.
[0076] In one embodiment, the second determining module 340 is specifically used for: For each target candidate document, the document score result is mapped to a standardized weight. The standardized weights are updated based on the feedback signal to obtain the updated weights corresponding to each standardized weight. The feedback signal is related to the click-through rate of the target candidate document. For each target candidate document in the target candidate document set, if the updated weight of the target candidate document satisfies the set condition, the target candidate document is placed into the query result set corresponding to the query statement.
[0077] In one embodiment, the generation module 320 is specifically used for: The semantic vector is retrieved to determine an initial candidate document set corresponding to the semantic vector, wherein the initial candidate document set includes at least one initial candidate document; The semantic vector is semantically projected to obtain the query embedding vector corresponding to the semantic vector, and the query embedding vector includes a vector after the semantic vector is aligned. For each initial candidate document, a search score is determined between the initial candidate document and the query embedding vector. The search score includes a weighted sum of a keyword retrieval score and a cosine similarity score. The keyword retrieval score is related to the number of keywords contained in the query embedding vector of the initial candidate document. The cosine similarity score is related to the cosine similarity between the query embedding vector and the vector corresponding to the initial candidate document. Based on the search score values, the initial candidate documents in the initial candidate document set are sorted to obtain the target candidate document set.
[0078] In one embodiment, the first determining module 310 includes: The second determining unit is used to determine the query statement and the modality type corresponding to the query statement, wherein the query statement includes a statement composed of information of at least one modality; The third determining unit is used to determine the initial semantic vector corresponding to the query statement based on the modality type. The fourth determining unit is used to determine the semantic related word corresponding to each query word contained in the initial semantic vector, wherein the semantic related word includes words that belong to the same domain as the query word; An injection unit is used to inject each of the semantic related words into the initial semantic vector to obtain the semantic vector corresponding to the query statement.
[0079] In one embodiment, the third determining unit is specifically used for: When the modality type indicates that the query statement is of text type, the query statement is divided into blocks to generate a text semantic vector, and the text semantic vector is determined as the initial semantic vector corresponding to the query statement; When the modality type indicates that the query statement is an image type, the text content and visual features of the query statement are extracted respectively, a joint image-text embedding vector is generated from the text content and the visual features, and the joint image-text embedding vector is determined as the initial semantic vector corresponding to the query statement; When the modality type indicates that the query statement is a speech type, the query statement is transcribed into speech to generate a text sequence vector, and the text sequence vector is determined as the initial semantic vector corresponding to the query statement.
[0080] The statement query device provided in this embodiment of the invention can execute the statement query method provided in any embodiment of the invention. Through the cooperation and coordination between the modules, the statement query is completed, and it has the corresponding functional modules and beneficial effects of the execution method.
[0081] Example 4 According to embodiments of the present invention, the present invention also provides an electronic device and a computer-readable storage medium.
[0082] Figure 4 This is a block diagram of an electronic device according to Embodiment 4 of the present invention, which implements the statement query method described in the embodiments of the present invention. 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 processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0083] like Figure 4As shown, the electronic device 410 includes at least one processor 411 and a memory, such as a read-only memory (ROM) 412 or a random access memory (RAM) 413, communicatively connected to the at least one processor 411. The memory stores computer programs executable by the at least one processor. The processor 411 can perform various appropriate actions and processes based on the computer program stored in the ROM 412 or loaded from storage unit 418 into the RAM 413. The RAM 413 may also store various programs and data required for the operation of the electronic device 410. The processor 411, ROM 412, and RAM 413 are interconnected via a bus 414. An input / output (I / O) interface 415 is also connected to the bus 414.
[0084] Multiple components in the electronic device are connected to the I / O interface 415, including: an input unit 416, such as a keyboard, mouse, etc.; an output unit 417, such as various types of displays, speakers, etc.; a storage unit 418, such as a disk, optical disk, etc.; and a communication unit 419, such as a network card, modem, wireless transceiver, etc. The communication unit 419 allows the electronic device to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0085] Processor 411 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 411 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 411 performs the various methods and processes described above, such as statement query methods.
[0086] In some embodiments, the statement query method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 418. In some embodiments, part or all of the computer program may be loaded and / or mounted on electronic device 410 via ROM 412 and / or communication unit 419. When the computer program is loaded into RAM 413 and executed by processor 411, one or more steps of the statement query method described above may be performed. Alternatively, in other embodiments, processor 411 may be configured to execute the statement query method by any other suitable means (e.g., by means of firmware).
[0087] Various embodiments 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-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0088] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0089] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0090] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device 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 provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, 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 sound input, voice input, or tactile input).
[0091] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0092] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0093] The technical solution of this invention provides a statement query method, apparatus, electronic device, and storage medium. The process involves: determining the statement to be queried and its corresponding semantic vector; retrieving the semantic vector to generate a target candidate document set; evaluating each target candidate document based on the statement to be queried to obtain a document score; and determining the query result set corresponding to the statement to be queried based on the target candidate document set and the document score results. By retrieving the semantic vector corresponding to the statement to be queried to generate the target candidate document set, the accuracy and completeness of the retrieval process are achieved. Determining the query result set through document score results improves the matching degree between the user-inputted statement and the query result set, thereby improving retrieval accuracy and response speed.
[0094] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0095] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A statement query method, characterized in that, include: Determine the query statement and the semantic vector corresponding to the query statement, wherein the semantic vector is related to the lexical units contained in the query statement; The semantic vector is retrieved to generate a target candidate document set, which includes at least one target candidate document and documents related to the query statement. For each target candidate document, the target candidate document is evaluated based on the query statement to obtain a document score result corresponding to the target candidate document. The document score result indicates the relevance of the target candidate document to the query statement. Based on the target candidate document set and the document rating results corresponding to each target candidate document, a query result set corresponding to the query statement is determined. The query result set consists of target candidate documents in the target candidate document set that meet set conditions, and the set conditions are related to the numerical values of each document rating result.
2. The method according to claim 1, characterized in that, The step of evaluating the target candidate documents based on the query statement to obtain the document score result corresponding to the target candidate documents includes: Based on the query statement, construct the structured input sequence corresponding to the target candidate document; Determine the semantic interaction matrix corresponding to the structured input sequence, wherein the semantic interaction matrix is composed of the features of the structured input sequence; The semantic interaction matrix is input into the scoring model to obtain the document scoring result corresponding to the target candidate document.
3. The method according to claim 2, characterized in that, The step of constructing the structured input sequence corresponding to the target candidate document based on the query statement includes: Determine the metadata corresponding to the target candidate document, wherein the metadata includes the features of the target candidate document; Identify document fragments in the target candidate documents that are related to the query statement; The structured input sequence corresponding to the target candidate document is composed of the query statement, the document fragment content, and the metadata.
4. The method according to claim 1, characterized in that, The step of determining the query result set corresponding to the query statement based on the target candidate document set and the document scoring results corresponding to each target candidate document includes: For each target candidate document, the document score result is mapped to a standardized weight. The standardized weights are updated based on the feedback signal to obtain the updated weights corresponding to each standardized weight. The feedback signal is related to the click-through rate of the target candidate document. For each target candidate document in the target candidate document set, if the updated weight of the target candidate document satisfies the set condition, the target candidate document is placed into the query result set corresponding to the query statement.
5. The method according to claim 1, characterized in that, The step of retrieving the semantic vector to generate a target candidate document set includes: The semantic vector is retrieved to determine an initial candidate document set corresponding to the semantic vector, wherein the initial candidate document set includes at least one initial candidate document; The semantic vector is semantically projected to obtain the query embedding vector corresponding to the semantic vector, and the query embedding vector includes a vector after the semantic vector is aligned. For each initial candidate document, a search score is determined between the initial candidate document and the query embedding vector. The search score includes a weighted sum of a keyword retrieval score and a cosine similarity score. The keyword retrieval score is related to the number of keywords contained in the query embedding vector of the initial candidate document. The cosine similarity score is related to the cosine similarity between the query embedding vector and the vector corresponding to the initial candidate document. Based on the search score values, the initial candidate documents in the initial candidate document set are sorted to obtain the target candidate document set.
6. The method according to claim 1, characterized in that, The process of determining the query statement and the semantic vector corresponding to the query statement includes: Determine the query statement and the modality type corresponding to the query statement, wherein the query statement includes a statement composed of information of at least one modality; Based on the modality type, determine the initial semantic vector corresponding to the query statement; For each query term contained in the initial semantic vector, determine the semantic related words corresponding to the query term, wherein the semantic related words include terms that belong to the same domain as the query term; Each of the semantic related words is injected into the initial semantic vector to obtain the semantic vector corresponding to the query statement.
7. The method according to claim 6, characterized in that, The step of determining the initial semantic vector corresponding to the query statement based on the modality type includes: When the modality type indicates that the query statement is of text type, the query statement is divided into blocks to generate a text semantic vector, and the text semantic vector is determined as the initial semantic vector corresponding to the query statement; When the modality type indicates that the query statement is an image type, the text content and visual features of the query statement are extracted respectively, a joint image-text embedding vector is generated from the text content and the visual features, and the joint image-text embedding vector is determined as the initial semantic vector corresponding to the query statement; When the modality type indicates that the query statement is a speech type, the query statement is transcribed into speech to generate a text sequence vector, and the text sequence vector is determined as the initial semantic vector corresponding to the query statement.
8. A statement query device, characterized in that, include: The first determining module is used to determine the query statement and the semantic vector corresponding to the query statement, wherein the semantic vector is related to the word elements contained in the query statement; A generation module is used to retrieve the semantic vector and generate a target candidate document set, wherein the target candidate document set includes at least one target candidate document, and the target candidate document includes documents related to the query statement; An evaluation module is used to evaluate each target candidate document based on the query statement to obtain a document score result corresponding to the target candidate document. The document score result indicates the relevance of the target candidate document to the query statement. The second determining module is used to determine the query result set corresponding to the query statement based on the target candidate document set and the document rating results corresponding to each target candidate document. The query result set consists of target candidate documents in the target candidate document set that meet set conditions, and the set conditions are related to the numerical values of each document rating result.
9. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the statement query method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the statement query method according to any one of claims 1-7.