Content generation method and apparatus, and electronic device
By combining data from a pre-set knowledge base and a wide area network, target content is generated according to priority, solving the problem of intelligent assistant applications responding when there is no relevant data within a user group, and improving data acquisition efficiency and the accuracy of content generation.
Patent Information
- Application Number
- PCT/CN2025/079364
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-06-21
- Filing Date
- 2025-02-26
- Publication Date
- 2025-12-26
AI Technical Summary
Existing smart assistant applications cannot generate response content when there is no relevant data in the user group, which forces users to frequently search from the wide area network and reduces data acquisition efficiency.
Combining data from a pre-set knowledge base and a wide area network (WAN), target content is generated according to priority. Pre-set knowledge base data is used first to generate response content, while WAN data is used when there is a gap. Data processing and generation are performed through a content generation model.
It improves the efficiency for users to obtain relevant data from different data sources, meets user needs, and reduces the need for repeated searches from other data sources.
Smart Images

Figure CN2025079364_26122025_PF_FP_ABST
Abstract
Description
Content generation method and device and electronic equipment
[0001] Cross-reference to Related Applications
[0002] The present application claims priority from the Chinese patent application No. 202410815200.6, filed on June 21, 2024, and entitled "Content generation method and device and electronic equipment", the whole content of which is incorporated herein by reference. TECHNICAL FIELD
[0003] Embodiments of the present disclosure relate to the technical field of Internet, and in particular, to a content generation method, device and electronic equipment. BACKGROUND
[0004] When a user faces a question and needs to obtain knowledge, the user can initiate a question to an intelligent assistant application. The intelligent assistant application has the ability to obtain knowledge from the Internet, and can obtain relevant data from the Internet according to the question information issued by the user, and then answer the question information according to the relevant data obtained from the Internet. SUMMARY
[0005] Embodiments of the present disclosure provide a content generation method, device and electronic equipment.
[0006] In a first aspect, the embodiments of the present disclosure provide a content generation method, which comprises: receiving a first data acquisition result and a second data acquisition result; wherein the first data acquisition result is obtained by data acquisition based on knowledge content in a preset knowledge base for a content acquisition request, and the second data acquisition result is obtained by data acquisition based on a wide area network for the content acquisition request, or the second data acquisition result is generated by a content generation model according to the content acquisition request; generating prompt information comprising the first data acquisition result and the second data acquisition result; wherein the prompt information further comprises a content generation rule; the content generation rule comprises a priority of referring to the first data acquisition result and referring to the second data acquisition result when generating target content; inputting the prompt information into a pre-trained content generation model, and generating target content by the content generation model according to the content generation rule, the first data acquisition result and the second data acquisition result. In a second aspect, the embodiments of the present disclosure provide a content generation device, which comprises: a receiving unit configured to receive a first data acquisition result and a second data acquisition result; wherein the first data acquisition result is obtained by data acquisition based on knowledge content in a preset knowledge base for a content acquisition request, and the second data acquisition result is obtained by data acquisition based on a wide area network for the content acquisition request, or the second data acquisition result is generated by a content generation model according to the content acquisition request; a first generation unit configured to generate prompt information comprising the first data acquisition result and the second data acquisition result; wherein the prompt information further comprises a content generation rule; the content generation rule comprises a priority of referring to the first data acquisition result and referring to the second data acquisition result when generating target content; and a second generation unit configured to input the prompt information into a pre-trained content generation model, and generate target content by the content generation model according to the content generation rule, the first data acquisition result and the second data acquisition result.
[0007] In a third aspect, the embodiments of the present disclosure provide an electronic device, which comprises: a processor and a memory; the memory stores computer execution instructions; and the processor executes the computer execution instructions stored in the memory, so that the at least one processor executes the first aspect and various possible methods of the first aspect.
[0008] In a fourth aspect, the embodiments of the present disclosure provide a computer readable storage medium, which stores computer execution instructions, and when a processor executes the computer execution instructions, the first aspect and various possible methods of the first aspect are implemented.
[0009] In a fifth aspect, the embodiments of the present disclosure provide a computer program product, comprising a computer program, wherein the computer program is executed by a processor to implement the method in the first aspect and various possible methods in the first aspect. BRIEF DESCRIPTION OF DRAWINGS
[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present disclosure, and other drawings can be obtained by a person of ordinary skill in the art without creative labor.
[0011] FIG. 1 is a flowchart of a content generation method provided by the present disclosure;
[0012] FIG. 2 is a flowchart of a content generation method provided by the present disclosure;
[0013] FIG. 3 is a structural block diagram of a content generation apparatus provided by the embodiments of the present disclosure;
[0014] FIG. 4 is a hardware structure diagram of an electronic device provided by the embodiments of the present disclosure. DETAILED DESCRIPTION
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present disclosure, and other drawings can be obtained by a person of ordinary skill in the art without creative labor.
[0016] In some embodiments, when a user initiates a content acquisition request (for example, initiates a question) to a smart assistant application, the smart assistant application can acquire relevant information from the knowledge data possessed by itself and generate a reply content. If the knowledge data available to the smart assistant application itself does not have relevant information, the external data corresponding to the content acquisition request can be acquired from a wide area network, and a reply content is generated according to the external data.
[0017] In some application scenarios, a user can belong to a certain user group. For a user group, a user group's own internal knowledge base, that is, a user group knowledge base, can be constructed. The user group knowledge base can include various knowledge data generated within the user group.
[0018] When a user in a user group initiates a content acquisition request to an intelligent assistant application, the user has a demand for obtaining information from the internal knowledge base of the user group, for example, a content acquisition request for obtaining the content of a relevant transaction processing flow in the user group. In this case, if the intelligent assistant application generates reply content based on data obtained from the wide area network, the user's demand may not be met.
[0019] In some embodiments, data can be obtained from the user group according to the user's content acquisition request, and reply content can be generated based on the data in the user group. However, when there is no relevant data in the user group and the intelligent assistant application itself also has no relevant information, the reply content cannot be generated. The user needs to initiate a search in the wide area network to obtain relevant information, which is inconvenient for the user.
[0020] The scheme provided by the present disclosure combines the first data acquisition result obtained from the preset database and the second data acquisition result obtained from the wide area network to generate target content according to the priority of referring to the first data acquisition result and the priority of referring to the second data acquisition result. When the priority indicates that the priority of referring to the first data acquisition result is high, the target content is generated based on the first data acquisition result, so that the user's demand for obtaining reply content from the preset knowledge base can be met. In addition, when the first data acquisition result is empty, that is, the content acquisition request is irrelevant to the preset knowledge base, the target content can also be generated based on the second data acquisition result to provide reply content for the content acquisition request. The efficiency of obtaining relevant data from different data sources by the user is improved.
[0021] Please refer to FIG. 1, which is a flowchart of a content generation method provided by the present disclosure. As shown in FIG. 1, the method comprises the following steps:
[0022] S101: receiving a first data acquisition result and a second data acquisition result; wherein the first data acquisition result is obtained by acquiring data based on knowledge content in a preset knowledge base for a content acquisition request, and the second data acquisition result is obtained by acquiring data based on a wide area network for the content acquisition request, or the second data acquisition result is generated by a content generation model according to the content acquisition request.
[0023] In this embodiment, the execution subject of the content generation method can be a server (for example, a server providing services for an intelligent assistant application).
[0024] The content acquisition request can be sent by a user terminal, for example, the user uses the user terminal to send the content acquisition request to the server. Specifically, an intelligent assistant application can be run in the user terminal. The user can input the content acquisition request in the intelligent assistant application. The intelligent assistant application can send the content acquisition request to the server.
[0025] The server can perform data acquisition based on the knowledge content in the preset database according to the content acquisition request after receiving the content acquisition request, and obtain a first data acquisition result.
[0026] In one embodiment, the preset database herein can be a knowledge base constructed according to data generated within a user group.
[0027] In some embodiments, the server can also perform data acquisition from a wide area network according to the content acquisition request after receiving the content acquisition request, and obtain a second data acquisition result according to the acquired data.
[0028] For example, the server initiates a search in the wide area network according to the content acquisition request, and obtains a plurality of candidate second data acquisition results; then sorts and filters the plurality of candidate second data acquisition results to obtain the second data acquisition result.
[0029] In some other embodiments, the server can also send the content acquisition request to a content generation model after receiving the content acquisition request, and generate the first data acquisition result according to the content acquisition request by the content generation model.
[0030] The execution subject can receive the first data acquisition result obtained based on the data in the preset database, and the second data acquisition result obtained based on the data in the wide area network.
[0031] S102: Generate prompt information including the first data acquisition result and the second data acquisition result; wherein the prompt information further includes a content generation rule; the content generation rule includes a priority of referring to the first data acquisition result and referring to the second data acquisition result when generating content.
[0032] After receiving the first data acquisition result and the second data acquisition result, prompt information can be generated. The prompt information can include the first data acquisition result, the second data acquisition result and the content generation rule. The content generation rule can include a priority of referring to the first data acquisition result and referring to the second data acquisition result when generating content.
[0033] As an example, the content generation rule can include "when there is a first data acquisition result related to the content acquisition request in the preset database, preferentially use the first data acquisition result to generate the reply content", and for example, the content generation rule can also include "when there is no data related to the content acquisition request in the preset database, use the second data acquisition result to generate the reply content". That is, the priority of the first data acquisition result from the preset database is the highest.
[0034] It can be understood that the first data acquisition result and the second data acquisition result in the prompt information can be distinguished. For example, a first label can be set for the first data acquisition result and a second label can be set for the second data acquisition result in the prompt information. The first label is different from the second label. For another example, a preset separator is used to separate the first data acquisition result and the second data acquisition result. By setting the first label and the second label for the first data acquisition result and the second data acquisition result respectively, or setting the preset separator to separate the first data acquisition result and the second data acquisition result, the content generation model can distinguish the first data acquisition result and the second data acquisition result.
[0035] S103: inputting the prompt information into the pre-trained content generation model, and generating target content by the content generation model according to the content generation rule, the first data acquisition result and the second data acquisition result.
[0036] The content generation model herein can be any learning model with language processing capability or content generation capability.
[0037] The prompt information includes the first data acquisition result, the second data acquisition result and the content generation rule, and can also include a content acquisition request. Therefore, the content generation model will generate target content according to the first data acquisition result and / or the second data acquisition result according to the content generation rule.
[0038] Since the content generation rule indicates the priority of referring to the first data acquisition result and the second data acquisition result, under the premise that the priority indicates which data acquisition result is used to generate the target content, the content generation model generates the target content according to the data acquisition result indicated by the priority.
[0039] In one example, the content generation rule is that the first data acquisition result from the preset database is used to generate the target content, and when there is no data related to the content acquisition request in the preset database, the second data acquisition result is used to generate the target content.
[0040] In this example, the content generation rule indicates that if there is data related to the content acquisition request from the preset database in the prompt information, that is, the first data acquisition result is not empty, the reply content can be generated from the first data acquisition result. Therefore, when the first data acquisition result in the prompt information is not empty, the content generation model can generate the target content according to the first data acquisition result. That is, when the prompt information includes the non-empty first data acquisition result and the second data acquisition result, the content generation model can generate the target content based on the first data acquisition result based on the content generation rule.
[0041] If the first data acquisition result is empty, that is, there is no data related to the content acquisition request in the preset knowledge base, according to the prompt information, the content generation model can generate the target content according to the second data acquisition result.
[0042] In another example, the content generation rule can also indicate that the second data acquisition result is used to generate the target content preferentially, and when the second data acquisition result is empty, the first data acquisition result from the preset database is used to generate the target content.
[0043] According to the content generation rule provided in this example, the content generation model can use the second data acquisition result to generate the target content corresponding to the content acquisition request when the second data acquisition result is not empty; and use the first data acquisition result to generate the target content when the second data acquisition result is empty.
[0044] As another example, the prompt information can also prompt to generate the target content according to the first data acquisition result first, and then generate the target content according to the second data acquisition result, and display the two target contents separately. The content generation model can generate the first target content according to the first data acquisition result and the second target content according to the second data acquisition result according to the prompt information. Then, the first target content and the second target content are output respectively, and the first target content is marked as coming from the preset knowledge base, and the second target content is marked as coming from the wide area network or from the content generation model itself.
[0045] As an implementation manner, the content generation model can send the target content to the execution subject, and the execution subject uses the target content to reply to the content acquisition request. For example, the execution subject sends the target content to the user terminal, so that the user terminal displays the target content in the intelligent assistant application.
[0046] In the embodiment, after receiving the content acquisition request, first data acquisition results are obtained based on the knowledge content in the preset database, second data acquisition results are obtained based on the wide area network, or the second data acquisition results are generated by the content generation model; then, prompt information including the first data acquisition results, the second data acquisition results, and a content generation rule is generated, the content generation rule including a priority of referring to the first data acquisition results and referring to the second data acquisition results when generating the target content, and the content generation model generates the target content according to the priority, the first data acquisition results, and the second data acquisition results after receiving the prompt information. The priority set in the content generation rule can match the source of the reply expected to be acquired by the user, so that the target content generated by the content generation model according to the prompt information matches the user demand. In addition, based on the prompt information, the content generation model can also generate the target content from another data acquisition result when the data acquisition result indicated by the priority cannot generate the target content, so that the operation of the user initiating the reply content acquisition from other data sources for the content acquisition request can be reduced, and the efficiency of the user acquiring related content from different data sources can be improved.
[0047] In some embodiments of the present embodiment, the content generation method further comprises the following steps:
[0048] First, a plurality of first data segments are acquired from the preset knowledge base according to the content acquisition request.
[0049] Second, the plurality of first data segments are sorted according to the relevance to the content acquisition request, and the sorting result is filtered to obtain the first data acquisition result.
[0050] In these embodiments, the content acquisition request can be matched in the preset database to obtain a plurality of first data segments.
[0051] As an implementation manner, the plurality of first data segments are acquired from the preset knowledge base according to the content acquisition request, comprising:
[0052] The content acquisition request is matched with a plurality of third data segments in the preset knowledge base, and the plurality of first data segments are acquired from the plurality of third data segments according to the matching result; wherein the plurality of third data segments are obtained by pre-cutting the data in the preset knowledge base.
[0053] Specifically, the data in the preset knowledge base can be cut in the following manner to obtain the plurality of third data segments: rule-based cutting, cutting the data in the knowledge base based on a semantic segmentation model, etc.
[0054] The rule-based segmentation can include setting a segmentation rule, and then segmenting data in the preset knowledge base according to the segmentation rule. The segmentation rule can include paragraph-based segmentation, sentence-based segmentation, topic-based segmentation, or fixed-length-based segmentation.
[0055] The paragraph-based segmentation can include segmenting text in the preset knowledge base by paragraphs, and each paragraph can be taken as an independent third data segment.
[0056] The sentence-based segmentation can include segmenting text in the preset knowledge base by sentences, and each sentence can be taken as an independent third data segment.
[0057] The topic-based segmentation can include using a topic model or a clustering algorithm to segment text by topics. Data under each topic can be taken as a third data segment.
[0058] The fixed-length-based segmentation can include segmenting text by fixed lengths (e.g., the number of characters or the number of words). The content included in each fixed length can be a third data segment.
[0059] For multiple third data segments in the preset knowledge base, each third data segment can be vectorized to obtain a third data segment vector corresponding to each third data segment. After receiving a content acquisition request, the content acquisition request can be vectorized in the same way to obtain a content acquisition request vector. Then, the similarity between the content acquisition request and each third data segment can be calculated according to the content acquisition request vector and the third data segment vector. Third data segments with a similarity greater than a preset similarity threshold value can be taken as first data segments, or multiple third data segments with a sorting number less than or equal to N can be sorted in descending order of the similarity between the content acquisition request and each third data segment, and the multiple third data segments can be taken as first data segments.
[0060] After obtaining multiple first data segments, the multiple first data segments can be sorted according to the relevance to the content acquisition request. The relevance can be represented by the similarity between the first data segment and the content acquisition request. The multiple first data segments can be sorted in descending order of the similarity between each first data segment and the content acquisition request to obtain a sorting result of the multiple first data segments. First data segments with a sorting number less than a preset sequence number threshold value (e.g., K, which can be an integer greater than 0, and the specific value of K can be determined according to the application scenario, and illustratively, K can be 10) can be extracted from the sorting result as second data segments. That is, the first K first data segments in the sorting result can be selected as K second data segments.
[0061] In order to quickly find the first data acquisition result, after obtaining the plurality of second data segments, the plurality of second data segments need to be screened. The plurality of second data segments can also be de-duplicated first, and the plurality of second data segments after de-duplication are screened to obtain the first data acquisition result.
[0062] In some embodiments of the present embodiment, the above-mentioned sorting of the plurality of first data segments according to the relevance to the content acquisition request comprises:
[0063] First, input the plurality of first data segments and the content acquisition request into a pre-trained sorting model, and output the relevance score between each first data segment and the content acquisition request by the sorting model;
[0064] Second, sort the plurality of first data segments according to the relevance score.
[0065] In these embodiments, the above-mentioned sorting model can be various models with text processing capability. After inputting the content acquisition request and the plurality of first data segments into the sorting model, the sorting model outputs the relevance score between the plurality of first data segments and the content acquisition request. Then, the plurality of first data segments are sorted in descending order of the above-mentioned relevance score. The sorting result is obtained.
[0066] Specifically, the above-mentioned sorting model can be obtained by the following steps:
[0067] First, construct a training sample, and construct a sample content acquisition request for each third data segment in a preset knowledge base. The constructed sample content acquisition request and the current third data segment are taken as a positive sample, the relevance score is a first relevance score, and the relevance score of the sample content acquisition request and the current third data segment is given. A plurality of other third data segments are recalled from the preset knowledge base by the text similarity of the sample content acquisition request, and the plurality of other third data segments are taken as negative samples corresponding to the sample content acquisition request, and the relevance score of each negative sample is a second relevance score. Further, a plurality of sample content acquisition requests respectively correspond to one positive sample and a plurality of negative samples.
[0068] The first relevance score here can be 1, and the second relevance score can be 0, for example.
[0069] Second, for each training sample in the plurality of training samples, input the third data segment in the training sample and the sample content acquisition request into the sorting model, and take the relevance score corresponding to the training sample as the output. Train the sorting model.
[0070] In the above training process, a loss function can be selected, and the loss function can be a contrastive loss function or a ternary loss function, for example.
[0071] After training on multiple training samples, a trained ranking model can be obtained. The trained ranking model can output a relevance score between a data segment and a content acquisition request for an input content acquisition request and data segment.
[0072] In this embodiment, the relevance score between the content acquisition request and each first data segment is determined by the ranking model, and then the multiple first data segments are ranked according to the relevance score, so that the ranking of the multiple first data segments can be quickly completed, and the first data acquisition result can be quickly obtained.
[0073] In one embodiment of these embodiments, the screening of the multiple second data segments to obtain the first data acquisition result comprises:
[0074] The multiple second data segments are screened according to one or more of the following:
[0075] timeliness, authority, and relevance to the content acquisition request.
[0076] As an application scenario, the multiple second data segments can be screened according to timeliness. For example, a timeliness score can be calculated according to the time difference between the timestamp of the multiple second data segments and the target time when the content acquisition request is received. The timeliness score of a historical second data segment corresponding to a larger time difference is lower, and the timeliness score of a historical second data segment corresponding to a smaller time difference is higher. A timeliness threshold can be set, and the second data segment with a timeliness score greater than the timeliness threshold is regarded as the first data acquisition result.
[0077] As an application scenario, the multiple second data segments can be screened according to authority. The authority indicators can be defined in advance, including but not limited to data sources and citation times. The data sources include the credibility and reputation of the data sources. The citation times include the number or frequency of citations of the data. Then, the scoring rules of the authority indicators are defined. Taking the data sources as an example, the second data segment from data source A corresponds to a score of 1, the second data segment from data source B corresponds to a score of 0.9, the second data segment from data source C corresponds to a score of 0.5, and so on. For different authority indicators, the weighted sum of the scores of each authority indicator can be calculated to obtain the authority score of each second data segment. A preset authority threshold can be set, and the second data segment with an authority score greater than the preset authority threshold is regarded as the first data acquisition result.
[0078] The relevance of the second data segment to the content acquisition request can be represented by the similarity between the second data segment and the content acquisition request. The greater the similarity between the second data segment and the content acquisition request, the greater the relevance score corresponding to the second data segment. The smaller the similarity between the second data segment and the content acquisition request, the smaller the relevance score corresponding to the second data segment. A preset relevance threshold can be set, and the second data segment with a relevance score greater than the preset relevance threshold is regarded as the first data acquisition result.
[0079] In one application scenario, the timeliness, authority and relevance can be comprehensively considered to filter multiple second data. Specifically, for each second data segment, the timeliness score, the authority score and the relevance score corresponding to the second data segment are weighted and summed, and the sum result is taken as the comprehensive score of the second data segment. A comprehensive threshold can be set, and the second data segment with a comprehensive score greater than the comprehensive threshold is taken as the first data acquisition result.
[0080] The first data acquisition result obtained through the above sorting and filtering has high accuracy and credibility, and the target content generated from the first data acquisition result has high quality.
[0081] Referring to FIG. 2, FIG. 2 is a schematic flowchart of a content generation method provided by the present disclosure. As shown in FIG. 2, the method comprises the following steps:
[0082] S201: Analyze the reply to the content acquisition request, whether external data needs to be acquired, wherein the external data is data acquired from outside the content generation model and used to assist the content generation model to generate target content.
[0083] In the embodiment, the execution subject of the content generation method can be a server (for example, a server providing services for an intelligent assistant application).
[0084] The content acquisition request described above can be sent by a user terminal, for example.
[0085] The server described above can be pre-set with a parsing rule, and the parsing rule is used to analyze whether external data needs to be acquired in reply to the content acquisition request.
[0086] For example, the parsing rule described above can include: if the content acquisition request is used to acquire weather information, external data does not need to be acquired; if the content acquisition request is used to acquire information about historical figures, external data does not need to be acquired, and the like. It can be understood that the parsing rule can also include other rules, and the other rules can be determined according to the data range covered by the database of the content generation model itself.
[0087] After receiving the content obtaining request, semantic understanding can be performed on the content obtaining request. According to the semantic understanding result and the above-mentioned parsing rule, it is determined whether external data needs to be obtained. For example, the content obtaining request is "how is the weather trend this week", and according to the semantic understanding result, it is determined that the content obtaining request is used to obtain the weather information in this week, so external data does not need to be obtained. If the content obtaining request is "how to pick up the office computer", the semantic understanding result is that the content obtaining request is related to the pick-up of the office computer, and the semantic understanding result is matched with the parsing rule. If the matching is not successful, it is determined that external data needs to be obtained.
[0088] In some embodiments, the above step S201 comprises:
[0089] The content obtaining request is input into the prediction model, and the prediction model outputs a prediction result. The prediction result indicates whether the reply to the content obtaining request needs to obtain external data.
[0090] For example, the prediction result is "0", indicating that external data does not need to be obtained. The prediction result is "1", indicating that external data needs to be obtained.
[0091] The above-mentioned prediction model can be trained based on the following steps:
[0092] First, from the historical content obtaining requests, a plurality of first historical content obtaining requests which reply to the historical content requests need to obtain external data are determined as positive samples, and the corresponding first labels are "1". From the historical content obtaining requests, a plurality of second historical content obtaining requests which reply to the historical content requests do not need to obtain external data are determined as negative samples, and the corresponding second labels are "0".
[0093] Then, the first historical content obtaining request in the positive sample is taken as the input, the first label is taken as the output true value, the second historical content obtaining request in the negative sample is taken as the input, and the second label is taken as the output. The prediction model is trained to obtain the trained prediction model.
[0094] In these embodiments, whether the reply to the content obtaining request needs to obtain external data is determined by the prediction model, which can quickly obtain the determination result. This is conducive to improving the efficiency of generating target content.
[0095] S202: In response to the parsing result being that external data needs to be obtained, the first data obtaining result and the second data obtaining result are obtained.
[0096] When the parsing result of step S201 is that external data needs to be obtained, the steps of obtaining the first data obtaining result and obtaining the second data obtaining result are performed.
[0097] For example, a plurality of first data segments are obtained from a preset knowledge base according to a content acquisition request; the plurality of first data segments are sorted according to relevance to the content acquisition request, and a sorting result is filtered to obtain a first data acquisition result.
[0098] In some embodiments, the obtaining of the second data acquisition result includes the following steps:
[0099] First, a search is initiated in a wide area network for the content acquisition request to obtain a plurality of fourth data segments.
[0100] Second, the plurality of fourth data segments are sorted according to relevance to the content acquisition request, and a sorting result is filtered to obtain a second data acquisition result.
[0101] In these embodiments, a search can be performed in the wide area network for the content acquisition request to obtain a plurality of fourth data segments that satisfy a preset similarity requirement with the content acquisition request.
[0102] Then, the plurality of fourth data segments are sorted in descending order of relevance (represented by similarity) to the content acquisition request. The first L (L is an integer greater than 1 and equal to 1) data segments in the sorting result are filtered (for example, deduplicated, combined with timeliness, authority, and relevance to the content acquisition request, etc.), to obtain the second data acquisition result.
[0103] The second data acquisition result obtained through the above steps has a high matching degree with the content acquisition request, and the target content generated according to the second data acquisition result also has high accuracy.
[0104] The operations of obtaining the first data acquisition result and the second data acquisition result can be performed synchronously.
[0105] S203: receiving a first data acquisition result and a second data acquisition result; wherein the first data acquisition result is obtained by data acquisition based on knowledge content in a preset knowledge base for a content acquisition request, and the second data acquisition result is obtained by data acquisition based on a wide area network for the content acquisition request.
[0106] S204: generating prompt information including the first data acquisition result and the second data acquisition result; wherein the prompt information further includes a content generation rule; the content generation rule includes a priority of referring to the first data acquisition result and referring to the second data acquisition result when generating target content.
[0107] S205: inputting the prompt information into a pre-trained content generation model, and generating target content by the content generation model according to the content generation rule, the first data acquisition result, and the second data acquisition result.
[0108] The specific implementation of steps S203-S205 can refer to the description of steps S101-S103 in the embodiment shown in FIG. 1, and details are not repeated here.
[0109] It can be understood that if the analysis result obtained in step S201 indicates that external data does not need to be acquired, the content acquisition request can be directly sent to the content generation model, and the content generation model can generate the target content according to the data in the database of the content generation model.
[0110] In this embodiment, it is first analyzed whether external data needs to be acquired. When external data does not need to be acquired, the content generation model can quickly generate the target content. The data processing amount required for acquiring external data and processing the external data is reduced, and the speed of generating the target content is improved. When it is analyzed that external data needs to be acquired, the first data acquisition result from the preset database and the second data acquisition result from the wide area network are acquired, and then the content generation model generates the target content according to the first data acquisition result, the second data acquisition result, and the priority in the prompt information. The first data acquisition result and the second data acquisition result are both data segments, the matching degree of the generated target content with the user demand is high, and the efficiency of acquiring related data from different data sources by the user can be improved.
[0111] In some implementations of the embodiments shown in FIGS. 1 and 2, the content generation method further includes:
[0112] The target content is displayed in the page where the content acquisition request is located.
[0113] In these implementations, after the target content is generated, the target content can be displayed in the page where the content acquisition request is located.
[0114] Specifically, the execution subject can send the target content as reply content of the content acquisition request to the terminal device, and the terminal device can display the target content in the page where the content acquisition request is located.
[0115] In these implementations, by displaying the target content in the page where the content acquisition request is located, the user can browse the target content that replies to the content acquisition request in the page in time.
[0116] In some implementations of the embodiments shown in FIGS. 1 and 2, the content generation model is generated based on the following steps:
[0117] Firstly, a first training sample pair is constructed, the first training sample pair comprising a first sample prompt information as input and a first sample reply content as output; wherein the first sample prompt information comprises a first sample content acquisition request, a first sample data segment, a second sample data segment and a first content generation rule; the first sample data segment is a data segment in a preset knowledge base, and the first sample reply content is generated from the first sample data segment; the second sample data segment is data related to the first sample content acquisition request in a wide area network; the first priority in the first content generation rule indicates that the reply content is generated by giving priority to the first sample data segment;
[0118] Secondly, a second training sample pair is constructed, the second training sample pair comprising a second sample prompt information as input and a second sample reply content as output; wherein the second sample prompt information comprises a second sample content acquisition request, a third sample data segment, a fourth sample data segment and a second content generation rule; the third sample data segment is a data segment in a preset knowledge base, and the fourth sample data segment is data related to the second sample content acquisition request in a wide area network; the second sample reply content is generated from the fourth sample data segment; the second priority in the second content generation rule indicates that the reply content is generated by giving priority to the fourth sample data segment;
[0119] Finally, the initial content generation model is trained using the plurality of first training sample pairs and / or the plurality of second training sample pairs to obtain a trained content generation model.
[0120] It can be understood that the initial content generation model can be a model with language processing capability. The initial content generation model can be fine-tuned using the first training sample pair and / or the second training sample pair to obtain a fine-tuned content generation model.
[0121] In some application scenarios, the initial content generation model is fine-tuned using the plurality of first training sample pairs, and the fine-tuned content generation model can have the capability of generating reply content of a content acquisition request based on the first priority in the prompt information and from a data segment in a preset knowledge base.
[0122] In some application scenarios, the initial content generation model is fine-tuned using the plurality of first training sample pairs, and the fine-tuned content generation model can have the capability of generating reply content of a content acquisition request based on the second priority in the prompt information and from a data segment in a wide area network.
[0123] During the training process, the loss value of each training can be calculated according to a preset loss function, and the parameters of the content generation model are adjusted in reverse according to the loss value. The above-mentioned preset loss function can be, for example, a cross-entropy loss function, a mean square error loss function, etc.
[0124] After the above training, a trained content generation model can be obtained. The trained content generation model can accurately generate the target content according to the content generation rule, and the first data acquisition result and the second data acquisition result in the prompt information.
[0125] Corresponding to the content generation method of the above embodiment, FIG. 3 is a structural block diagram of a content generation apparatus provided by an embodiment of the present disclosure. For ease of illustration, only parts related to the embodiments of the present disclosure are shown. Referring to FIG. 3, the apparatus 30 includes a receiving unit 301, a first generation unit 302, and a second generation unit 303. Among them,
[0126] The receiving unit 301 is configured to receive a first data acquisition result and a second data acquisition result. The first data acquisition result is obtained by data acquisition based on knowledge content in a preset knowledge base for a content acquisition request. The second data acquisition result is obtained by data acquisition based on a wide area network for the content acquisition request, or the second data acquisition result is generated by a content generation model according to the content acquisition request.
[0127] The first generation unit 302 is configured to generate prompt information including the first data acquisition result and the second data acquisition result. The prompt information further includes a content generation rule. The content generation rule includes a priority of referring to the first data acquisition result and referring to the second data acquisition result when generating a target content.
[0128] The second generation unit 303 is configured to input the prompt information to a pre-trained content generation model, and generate the target content by the content generation model according to the content generation rule, the first data acquisition result, and the second data acquisition result.
[0129] In some embodiments, the apparatus 30 further includes a first data acquisition unit (not shown in the figure), which is configured to:
[0130] acquire a plurality of first data segments from a preset knowledge base according to the content acquisition request;
[0131] sort the plurality of first data segments according to the relevance to the content acquisition request, and filter the sorting result to obtain the first data acquisition result.
[0132] In some embodiments, the first data acquisition unit is further configured to:
[0133] sort the plurality of first data segments according to the relevance to the content acquisition request from large to small;
[0134] select a plurality of first data segments with a sorting number less than a first preset threshold as second data segments, and filter the plurality of second data segments to obtain the first data acquisition result.
[0135] In some embodiments, the first data obtaining unit is further configured to:
[0136] input the plurality of first data segments and the content obtaining request into a pre-trained ranking model, and output a ranking of the plurality of first data segments by the ranking model.
[0137] In some embodiments, the first data obtaining unit is further configured to:
[0138] filter the plurality of second data segments according to one or more of the following:
[0139] timeliness, authority, and relevance to the content obtaining request.
[0140] In some embodiments, the first data obtaining unit is further configured to:
[0141] match the content obtaining request with a plurality of third data segments in a preset knowledge base, and obtain the plurality of first data segments from the plurality of third data segments according to a matching result, wherein the plurality of third data segments are obtained by pre-splitting data in the preset knowledge base.
[0142] In some embodiments, the apparatus 30 further comprises an analysis unit (not shown in the figure), configured to:
[0143] analyze whether external data needs to be obtained for the reply to the content obtaining request, wherein the external data is data obtained from outside the content generation model and used to assist the content generation model in generating the target content.
[0144] obtain the first data obtaining result and the second data obtaining result in response to the analysis result being that the external data needs to be obtained.
[0145] In some embodiments, the analysis unit is further configured to:
[0146] input the content obtaining request into a prediction model, and output a prediction result by the prediction model, wherein the prediction result indicates whether the external data needs to be obtained for the reply to the content obtaining request.
[0147] In some embodiments, the apparatus 30 further comprises a second data obtaining unit (not shown in the figure), configured to:
[0148] initiate a search in a wide area network for the content obtaining request, and obtain a plurality of candidate second data obtaining results.
[0149] rank and filter the plurality of candidate second data obtaining results, and obtain the second data obtaining result.
[0150] In some embodiments, the apparatus 30 further comprises a display unit (not shown in the figure), configured to present the target content in a page where the content acquisition request is located.
[0151] To implement the above-mentioned embodiments, the embodiments of the present disclosure further provide an electronic device.
[0152] Referring to FIG. 4, a structural schematic diagram of an electronic device 400 suitable for implementing the embodiments of the present disclosure is shown, which can be a terminal device or a server. The terminal device can include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, personal digital assistants (PDA), tablet computers (PAD), portable multimedia players (PMP), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. The electronic device shown in FIG. 4 is only an example, and should not impose any limitation on the functions and use range of the embodiments of the present disclosure.
[0153] As shown in FIG. 4, the electronic device 400 can include a processing device (such as a central processor, a graphics processor, etc.) 401, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 402 or loaded into a random access memory (RAM) 403 from a storage device 408. In the RAM 403, various programs and data required for the operation of the electronic device 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other through a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0154] Generally, the following devices can be connected to the I / O interface 405: input devices 406 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, and the like; output devices 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, and the like; storage devices 408 including, for example, a magnetic tape, a hard disk, and the like; and communication devices 409. The communication devices 409 can allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. Although FIG. 4 shows the electronic device 400 with various devices, it should be understood that it is not required to implement or have all the shown devices. More or fewer devices can be alternatively implemented or provided.
[0155] In particular, according to embodiments of the present disclosure, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a computer readable medium, the computer program comprising program code for performing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via the communication device 409, or installed from the storage device 408, or installed from the ROM 402. When the computer program (computer execution instructions) is executed by the processing device 401, the above-mentioned functions defined in the methods of the embodiments of the present disclosure are performed.
[0156] It should be noted that the computer readable medium described above in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination thereof. The computer readable storage medium may, for example, be, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any suitable combination thereof. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, the computer readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus or device. In the present disclosure, the computer readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, in which a computer readable program code is carried. Such a propagated data signal can take any of a variety of forms, including, but not limited to, an electromagnetic signal, an optical signal, or any suitable combination thereof. The computer readable signal medium can also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate or transport a program for use by or in connection with an instruction execution system, apparatus or device. The program code contained in the computer readable medium can be transmitted by any suitable medium, including, but not limited to, a wire, an optical fiber, an RF (radio frequency) or the like, or any suitable combination thereof.
[0157] The computer readable medium described above can be included in the electronic device described above; or can exist separately from the electronic device and not be assembled into the electronic device.
[0158] The computer readable medium described above carries one or more programs (computer execution instructions), which, when executed by the electronic device, cause the electronic device to perform the methods illustrated by the embodiments described above.
[0159] Computer program code for carrying out operations of the present disclosure can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0160] The flow diagrams and the block diagrams in the drawings are illustrations of architectures, functionalities, and operations of possible implementations of systems, methods, and computer program products according to various embodiments of present disclosure. In this regard, each block in the flow diagrams or block diagrams can represent a module, a procedure, or a part of code, which comprises one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in some cases, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It is also noted that each block of the block diagrams and / or flow diagrams and combinations of blocks in the block diagrams and / or flow diagrams can be implemented by a dedicated hardware-based system that carries out specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0161] The units described in the embodiments of the present disclosure can be implemented by software, or by hardware. In some cases, the name of the unit does not constitute a limitation on the unit itself.
[0162] The functions described above in the detailed description of embodiments of the present disclosure can be implemented in at least in part by one or more hardware logic components. For example, and without limitation, illustrative types of hardware logic components that can be used include Field-programmable Gate Arrays (FPGAs), Program-specific Integrated Circuits (ASICs), Application-specific Standard Products (ASSPs), System-on-a-chip systems (SOCs), Complex Programmable Logic Devices (CPLDs), etc.
[0163] In the context of this disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium would include a lined- up electrical connection, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0164] The foregoing description merely exemplifies the preferred embodiments of the disclosure and the principles of the technology applied. It is understood by those skilled in the art that the disclosed scope of the disclosure is not limited to the technical solutions formed by the specific combinations of the technical features described above, and also covers other technical solutions formed by any combinations of the technical features described above or their equivalent features without departing from the disclosed concept. For example, the technical solutions formed by the mutual replacement of the above-described features and the technical features disclosed in the disclosure (but not limited to) having similar functions.
[0165] Furthermore, although the operations have been depicted in a particular order, this should not be understood as requiring the operations to be performed in the particular order shown or in sequential order, and that certain operations can be performed in parallel or in any order. Also, although specific implementation details have been included for the purpose of illustration, these need not be interpreted in a limiting manner. Certain features described in the context of separate embodiments can also be implemented together in a single embodiment. Conversely, various features described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable sub-combination.
[0166] Although the subject matter has been described in language specific to structural features and / or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.
Claims
1. A content generation method, comprising: Receive a first data acquisition result and a second data acquisition result; wherein, the first data acquisition result is obtained by acquiring data based on knowledge content in a preset knowledge base in response to the content acquisition request, and the second data acquisition result is obtained by acquiring data based on a wide area network in response to the content acquisition request, or the second data acquisition result is generated by a content generation model according to the content acquisition request; Generate a prompt message including the first data acquisition result and the second data acquisition result; wherein, the prompt message further includes content generation rules; the content generation rules include the priority of referring to the first data acquisition result and referring to the second data acquisition result when generating target content; The prompt information is input into a pre-trained content generation model, which then generates target content based on the content generation rules, the first data acquisition result, and the second data acquisition result.
2. The method according to claim 1, further comprising: According to the content retrieval request, multiple first data fragments are retrieved from the preset knowledge base; The plurality of first data fragments are sorted according to their relevance to the content acquisition request, and the sorting results are filtered to obtain the first data acquisition result.
3. The method according to claim 2, wherein, The step of sorting the plurality of first data segments according to their relevance to the content acquisition request, filtering the sorting results, and obtaining the first data acquisition result includes: The plurality of first data fragments are sorted in descending order of their relevance to the content retrieval request; Multiple first data segments with sort numbers less than a first preset threshold are used as second data segments. These multiple second data segments are then filtered to obtain the first data acquisition result.
4. The method according to claim 3, wherein, The step of filtering multiple second data segments to obtain the first data acquisition result includes: Filter multiple second data segments based on one or more of the following: Timeliness, authority, and relevance to the content retrieval request.
5. The method according to claim 2, wherein, The step of retrieving multiple first data fragments from a preset knowledge base based on a content retrieval request includes: The content retrieval request is matched with multiple third data fragments in the preset knowledge base, and the multiple first data fragments are obtained from the multiple third data fragments according to the matching results; wherein, the multiple third data fragments are obtained by pre-segmenting the data in the preset knowledge base.
6. The method according to any one of claims 1-5, further comprising: The response to the content retrieval request is analyzed to determine whether external data needs to be obtained. The external data refers to data obtained from outside the content generation model to assist the content generation model in generating the target content. In response to the parsing result indicating that external data needs to be obtained, the first data acquisition result and the second data acquisition result are obtained.
7. The method according to claim 6, wherein, The parsing of the response to the content retrieval request, including whether external data needs to be obtained, includes: The content retrieval request is input into a prediction model, which outputs a prediction result, wherein the prediction result indicates whether external data needs to be retrieved in response to the content retrieval request.
8. The method according to any one of claims 1-5, further comprising: In response to the content retrieval request, a search was initiated on the wide area network, resulting in multiple candidate second data retrieval results; The multiple candidate second data acquisition results are sorted and filtered to obtain the second data acquisition result.
9. The method according to any one of claims 1-5, further comprising: The target content is displayed on the page where the content retrieval request is located.
10. A content generation apparatus, comprising: A receiving unit is configured to receive a first data acquisition result and a second data acquisition result; wherein the first data acquisition result is obtained by acquiring data based on knowledge content in a preset knowledge base in response to a content acquisition request, and the second data acquisition result is obtained by acquiring data based on a wide area network in response to the content acquisition request, or the second data acquisition result is generated by a content generation model according to the content acquisition request; The first generation unit is used to generate a prompt message including the first data acquisition result and the second data acquisition result; wherein, the prompt message further includes content generation rules; the content generation rules include the priority of referring to the first data acquisition result and referring to the second data acquisition result when generating target content; The second generation unit is used to input the prompt information into a pre-trained content generation model, and the content generation model generates target content according to the content generation rules, the first data acquisition result, and the second data acquisition result.
11. An electronic device, comprising: Processor and memory; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the processor to perform the method as described in any one of claims 1 to 9.
12. A computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the method as described in any one of claims 1 to 9.
13. A computer program product comprising a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Search method, search system and search engine
CN103310010A
Keyword discovery method and system based on information monitoring and electronic equipment
CN112131462A
Internet mass data accurate search method and system based on AI technology
CN118093982A
Content generation method and device and electronic equipment
CN118861225A
Post-ranker for search results
US20210004420A1