Intelligent retrieval enhanced text creation method and device and storage medium
By building a multi-dimensional feature knowledge base and combining it with vectorization methods to dynamically adjust weights, the problem of rigid content generation in existing text creation systems is solved, and high-quality, personalized text creation effects are achieved.
Patent Information
- Application Number
- CN202510693801.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-27
- Publication Date
- 2025-09-09
AI Technical Summary
Existing text creation systems rely on preset templates or simple keyword matching, making it difficult to generate high-quality text that meets user needs, especially in professional creation tasks where they lack depth and personalization.
Build a multi-dimensional feature knowledge base, vectorize features through one-hot encoding, TF-IDF, and word vectorization, calculate the target similarity between feature vectors, dynamically adjust the weights based on configuration information, filter text fragments above the matching threshold as creation references, and combine with a large language model for text creation.
It realizes the intelligence and personalization of text creation, improves the quality and usability of generated content, and ensures that the creation meets user needs.
Smart Images

Figure CN120611033A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method, device and storage medium for text creation enhanced by intelligent retrieval. Background Art
[0002] With the development of artificial intelligence and natural language processing technology, artificial intelligence technology has gradually been applied to text creation, making automated text creation possible.
[0003] However, current text creation still relies on preset templates or simple keyword matching, making it difficult to accurately understand the user's complex intent. The generated text lacks depth and is often stiff, even containing repetitive and irrelevant expressions, failing to meet the user's personalized needs. Furthermore, existing technologies struggle to generate high-quality text and have limited adaptability to diverse styles and specific domains. This results in a low level of quality, particularly for highly specialized creative tasks.
[0004] Therefore, it is necessary to develop a more intelligent and personalized text creation system that can understand the user's query conditions and provide content that is more in line with actual needs as a reference for creation. Summary of the Invention
[0005] The main purpose of this application is to provide a text creation method, device and storage medium with intelligent retrieval enhancement, aiming to solve the technical problem that current text creation relies on preset templates or simple keyword matching, making it difficult to generate high-quality text that meets user needs.
[0006] To achieve the above objectives, the present application proposes a text creation method enhanced by intelligent retrieval, which includes:
[0007] Build a multi-dimensional feature knowledge base and set configuration information;
[0008] receiving query conditions and determining input text according to the query conditions;
[0009] Performing feature vectorization on the input text based on the multidimensional feature knowledge base to obtain a feature vector;
[0010] Calculating target similarity between the feature vectors;
[0011] Dynamically adjusting the weight of the input text based on the configuration information to obtain an adjusted weight, and calculating a target similarity score based on the adjusted weight and the target similarity;
[0012] Screening text segments that are higher than a matching threshold in the configuration information using the target similarity score as a creation reference;
[0013] The preset prompt word template and the creation reference are input into a large language model, and text creation is performed using the large language model.
[0014] In one embodiment, the feature vector includes a coding vector and a word vector;
[0015] The step of performing feature vectorization on the input text based on the multidimensional feature knowledge base to obtain a feature vector comprises:
[0016] Creating a zero vector using a scientific computing library, and creating a vector space of corresponding length based on the zero vector and the multidimensional feature knowledge base;
[0017] Performing word segmentation on the input text to obtain text word segmentation;
[0018] Traversing the multidimensional feature knowledge base through the text segmentation, when the text segmentation is located in the multidimensional feature knowledge base, setting the corresponding vector space to a first preset value, and when the text segmentation is not located in the multidimensional feature knowledge base, setting the vector space to a second preset value;
[0019] Obtaining a coding vector by using the first preset value and the second preset value;
[0020] The text word segmentation is mapped to a high-dimensional space through a preset word vector model to obtain a word vector.
[0021] In one embodiment, the feature vector comprises a numerical feature vector;
[0022] The step of performing feature vectorization on the input text based on the multidimensional feature knowledge base to obtain a feature vector comprises:
[0023] Performing word segmentation on the input text to obtain text word segmentation;
[0024] Calculate the word frequency of the text segmentation in the multidimensional feature knowledge base, wherein the word frequency is calculated by the following formula:
[0025]
[0026] Calculate the inverse document frequency of the text segmentation in the multidimensional feature knowledge base, wherein the inverse document frequency is calculated by the following formula:
[0027]
[0028] A numerical feature vector is calculated using the word frequency and the inverse document frequency.
[0029] In one embodiment, the step of calculating the target similarity between the feature vectors includes:
[0030] The initial similarity between the feature vectors is calculated, and the initial similarity is obtained by the following formula:
[0031]
[0032] Where A and B are two feature vectors, · represents the dot product operation, || || represents the modulus of the vector, and the initial similarity includes the encoding vector similarity, the numerical feature vector similarity, and the word vector similarity. The encoding vector similarity is calculated by the following formula:
[0033] onehot_sim=1-cosine(query_onehot, text_onehot)
[0034] query_onehot is the encoding vector, text_onehot is the encoding vector of the target text;
[0035] The numerical feature vector similarity is calculated by the following formula:
[0036] tfidf_sim=1-cosine(query_tfidf,text_tfidf)
[0037] query_tfidf is a numerical feature vector, and text_tfidf is a numerical feature vector of the target text;
[0038] The word vector similarity is calculated by the following formula:
[0039] vector_sim=1-cosine(query_vec,text_vec)
[0040] query_vec is the word vector, text_vec is the word vector of the target text;
[0041] Obtaining weights of various dimensions according to the configuration information;
[0042] The target similarity is calculated by the dimension weight, the encoding vector similarity, the numerical feature vector similarity and the word vector similarity. The target similarity is calculated by the following formula:
[0043] dimension_sim=0.3*onehot_sim+0.4*tfidf_sim+0.3*vector_sim
[0044] total_score=Σ(dimension_sim_i*weight_i)
[0045] Among them, total_score is the target similarity, the dimension weights include plot weight weight_plot, character weight weight_character, style weight weight_style and theme weight weight_theme, and the specific weight distribution is: weight_plot = 0.3 (plot), weight_character = 0.3 (character), weight_style = 0.2 (style), weight_theme = 0.2 (theme), dimension_sim_i is the similarity score of the i-th dimension, weight_i is the weight of the i-th dimension, i∈{plot, character, style, theme}.
[0046] In one embodiment, the step of dynamically adjusting the weight of the input text based on the configuration information to obtain an adjusted weight, and calculating a target similarity score based on the adjusted weight and the target similarity comprises:
[0047] Obtaining a preset text adjustment rule and the text length of the input text;
[0048] Determining a target text adjustment rule from the preset text adjustment rules according to the text length;
[0049] Dynamically adjusting the weight of the feature vector according to the target text adjustment rule to obtain a feature vector adjustment weight;
[0050] The reference similarity is calculated by adjusting the feature vector weight and the target similarity. The reference similarity is obtained by the following formula:
[0051] dimension_sim=w1*onehot_sim+w2*tfidf_sim+w3*vector_sim
[0052] Among them, w1, w2, and w3 are the weights of the feature vector after adaptive adjustment;
[0053] A target similarity score is calculated using the reference similarity and the input text.
[0054] In one embodiment, the step of calculating a target similarity score using the reference similarity and the input text includes:
[0055] Calculate the density of the characteristic words in the input text, and the characteristic word density is obtained by the following formula:
[0056] density = number of feature words / total number of words
[0057] Among them, density is the density of feature words;
[0058] Adjusting the weight of each dimension in the configuration information according to the feature word density to obtain a feature word density adjustment factor;
[0059] Calculate the average value and standard deviation of the dimensional similarity based on the encoding vector similarity, the numerical feature vector similarity and the word vector similarity in the initial similarity between the feature vectors;
[0060] The dimension Z score is calculated based on the dimension similarity average and the standard deviation, and the dimension Z score is obtained by the following formula:
[0061] z_score=(score-mean_score) / std_score
[0062] Wherein, the score is the dimension similarity, mean_score is the mean value, and std_score is the standard deviation;
[0063] The Z score is mapped to the adjustment factor using the Sigmoid function to obtain the Z score Sigmoid adjustment factor, which is obtained by the following formula:
[0064] adjustment_i=1 / (1+e^(-z_score_i))
[0065] adjustment_factor_i=0.5+adjustment_i
[0066] Among them, the Z score Sigmoid adjustment factor is adjustment_factor_i, and z_score_i is the dimension Z score;
[0067] The dimension adjustment weight is determined according to the feature word density adjustment factor and the Z score Sigmoid adjustment factor. The dimension adjustment weight is obtained by the following formula:
[0068] adjusted_weight_i=base_weight_i*density_factor_i*adjustment_factor_i
[0069] Among them, base_weight_i is the initial dimension weight, density_factor_i is the feature word density adjustment factor, and adjustment_factor_i is the Z score Sigmoid adjustment factor;
[0070] The dimension adjustment weight is normalized to obtain a normalized weight, and the normalized weight is obtained by the following formula:
[0071] normalized_weight_i=adjusted_weight_i / Σ(adjusted_weight_i)
[0072] Among them, normalized_weight_i is the normalized weight, and adjusted_weight_i is the dimension adjustment weight;
[0073] The target similarity score is calculated by the normalized weight and the reference similarity, and the target similarity score is calculated by the following formula:
[0074] total_score=Σ(dimension_sim_i*normalized_weight_i)
[0075] where i∈{plot,character,style,theme}.
[0076] In one embodiment, the steps of constructing a multi-dimensional feature knowledge base and initializing configuration information include:
[0077] Collect feature word data;
[0078] Performing multi-dimensional division on the feature word data using a preset word segmentation library to obtain multi-dimensional feature words;
[0079] Establishing a multidimensional feature knowledge base based on the multidimensional feature words;
[0080] Setting a matching threshold and setting a dimension weight for each dimension in the multi-dimensional feature word;
[0081] Configuration information is obtained through the matching threshold and the dimension weight.
[0082] In one embodiment, the step of inputting the preset prompt word template and the creation reference into a large language model and performing text creation using the large language model includes:
[0083] Combining the preset prompt word template with the creation reference to obtain target prompt information;
[0084] The target prompt information is input into a large language model, and text creation is performed through the large language model to generate a target creation text.
[0085] In addition, to achieve the above-mentioned purpose, the present application also proposes a text creation device enhanced by intelligent retrieval, wherein the text creation device enhanced by intelligent retrieval comprises:
[0086] Construction module, used to build a multi-dimensional feature knowledge base and set configuration information;
[0087] A determination module, configured to receive a query condition and determine an input text according to the query condition;
[0088] A feature vectorization module, configured to perform feature vectorization on the input text based on the multidimensional feature knowledge base to obtain a feature vector;
[0089] A calculation module, used for calculating the target similarity between the feature vectors;
[0090] an adjustment module, configured to dynamically adjust the weight of the input text based on the configuration information to obtain an adjusted weight, and calculate a target similarity score based on the adjustment weight and the target similarity;
[0091] A screening module, configured to screen text segments having a target similarity score higher than a matching threshold in the configuration information as a creation reference;
[0092] Input module, used to input the preset prompt word template and the creation reference into the large language model, and perform text creation through the large language model
[0093] In addition, to achieve the above-mentioned purpose, the present application also proposes a text creation device enhanced by intelligent retrieval, which includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the computer program is configured to implement the steps of the text creation method enhanced by intelligent retrieval as described above.
[0094] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the intelligent retrieval enhanced text creation method as described above are implemented.
[0095] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the intelligent retrieval enhanced text creation method as described above.
[0096] One or more technical solutions proposed in this application are to construct a multi-dimensional feature knowledge base and set configuration information; receive query conditions and determine input text according to the query conditions; perform feature vectorization on the input text based on the multi-dimensional feature knowledge base to obtain feature vectors; calculate the target similarity between the feature vectors; dynamically adjust the weight of the input text based on the configuration information to obtain an adjusted weight, and calculate the target similarity score based on the fusion of the adjusted weight and the target similarity; filter text fragments that are higher than the matching threshold in the configuration information as a creation reference through the target similarity score; input the preset prompt word template and the creation reference into a large language model, and perform text creation through the large language model. By constructing a multi-dimensional feature knowledge base and combining it with a vectorization method, a multi-dimensional feature representation of the text is achieved; a dynamic weight adjustment mechanism is designed to achieve intelligent similarity calculation. Through multi-level similarity fusion calculation combined with dynamic adjustment of dimensional weights, it is ensured that the selected reference fragments meet the creation requirements, thereby improving the quality and usability of the created content. BRIEF DESCRIPTION OF THE DRAWINGS
[0097] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0098] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0099] Figure 1 A flowchart of the first embodiment of the text creation method for intelligent retrieval enhancement provided in this application;
[0100] Figure 2 A flowchart of the second embodiment of the text creation method for intelligent retrieval enhancement provided in this application;
[0101] Figure 3 A schematic diagram of a simplified process of the text creation method enhanced by intelligent retrieval provided in Example 2 of the present application;
[0102] Figure 4 This is a schematic diagram of the module structure of the text creation device with intelligent retrieval enhancement according to an embodiment of the present application;
[0103] Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the intelligent retrieval enhanced text creation method in the embodiment of the present application.
[0104] The purpose, features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0105] It should be understood that the specific embodiments described herein are merely used to explain the technical solutions of the present application and are not intended to limit the present application.
[0106] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0107] The main solution of the embodiment of the present application is: building a multidimensional feature knowledge base and setting configuration information; receiving query conditions and determining input text based on the query conditions; feature vectorizing the input text based on the multidimensional feature knowledge base to obtain a feature vector; calculating the target similarity between the feature vectors; dynamically adjusting the weight of the input text based on the configuration information to obtain an adjusted weight, and calculating a target similarity score based on the fusion of the adjusted weight and the target similarity; screening text fragments that are higher than the matching threshold in the configuration information as a creation reference through the target similarity score; inputting a preset prompt word template and the creation reference into a large language model, and performing text creation through the large language model.
[0108] Because existing technologies use large language models to create novels, the generated content is too rigid and lacks real writing skills and expressions. LLMs find it difficult to accurately grasp the writing characteristics of different themes and styles, resulting in the generated content being stereotyped. Furthermore, they lack effective reference to excellent human creative experience, making it difficult to form a unique writing style.
[0109] This application provides a solution that realizes multi-dimensional feature representation of text by constructing a feature dictionary of four dimensions: plot, character, style, and subject matter, and combining three vectorization methods: one-hot encoding, TF-IDF, and word vector. Through multi-level similarity fusion calculation and dynamic adjustment of dimension weights, it ensures that the selected reference fragments meet the creative needs, realizes LLM (Large Language Model) creation enhancement based on real writing samples, and effectively improves the quality and usability of AI-created content.
[0110] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, mobile phone, etc., or an electronic device capable of implementing the above functions, a text creation device enhanced by intelligent retrieval, etc. The following uses the text creation device enhanced by intelligent retrieval as an example to illustrate this embodiment and the following embodiments.
[0111] Based on this, the embodiment of the present application provides a text creation method enhanced by intelligent retrieval, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the text creation method enhanced by intelligent retrieval in this application.
[0112] In this embodiment, the intelligent retrieval-enhanced text creation method includes steps S10 to S70:
[0113] Step S10: Build a multi-dimensional feature knowledge base and set configuration information.
[0114] It should be noted that you can collect and organize feature word data from different fields, use a preset word segmentation library to divide it into multiple dimensions (such as plot, character, style, etc.), and then build a multi-dimensional feature knowledge base. At the same time, initialize the configuration information, set the matching threshold and the weight of each dimension.
[0115] In a feasible implementation, step S10 may include steps A11 to A15:
[0116] Step A11: Collect feature word data.
[0117] It should be noted that the feature word data may include various types of feature words. This embodiment is mainly applied in text creation, such as novel creation, essay creation, etc. This embodiment uses novel creation as an example for explanation. Feature words are key words that describe the content of a text.
[0118] Feature word data may include "rebirth", "counterattack", "revenge", "genius", "domineering boss", "cool writing", "city", etc.
[0119] Step A12: performing multi-dimensional division on the feature word data using a preset word segmentation library to obtain multi-dimensional feature words;
[0120] It is understandable that the preset word segmentation library can be the JIEBA library, which is also called the Jieba word segmentation library. It is a very popular open source Chinese word segmentation tool in the field of Chinese text processing. Chinese is different from languages such as English. There are no obvious separators between words, so specific technology is required to identify each word in a sentence. This process is called "word segmentation." Accurate word segmentation is crucial for subsequent natural language processing tasks (such as semantic analysis, machine translation, information retrieval, etc.). The JIEBA library is used to divide the feature word data into multiple dimensions, so that feature words of different dimensions can be obtained. For example, the feature words are divided into four dimensions, including:
[0121] Plot dimension: Contains characteristic words such as "female hero", "superpower", "counterattack", "secret admiration", and "cultivation";
[0122] Role dimension: including characteristic words such as "domineering boss", "super detective", "common daughter", "cook", and "poison doctor";
[0123] Style dimension: including characteristic words such as "suspense", "cool", "sweet pet", "romantic", and "youth";
[0124] Theme dimension: includes characteristic words such as "fantasy", "science fiction", "time travel", "history", and "martial arts".
[0125] Step A13: establishing a multidimensional feature knowledge base based on the multidimensional feature words;
[0126] In a specific implementation, a multi-dimensional feature knowledge base can be established through the divided multi-dimensional feature words, that is, the feature words of different dimensions mentioned above are classified and stored to facilitate subsequent retrieval and query.
[0127] Step A14: setting a matching threshold and setting a dimension weight for each dimension in the multi-dimensional feature word;
[0128] It is understandable that the matching threshold may be a critical value for matching text. The matching threshold is set to 0.3 by default and may be adjusted as needed.
[0129] Set the dimension weight of each dimension, that is, the initial dimension weight, specifically the plot weight is 30%, the character weight is 30%, the style weight is 20%, and the subject matter weight is 20%.
[0130] Step A15: Obtain configuration information through the matching threshold and the dimension weight.
[0131] It should be noted that the matching threshold and the set dimension weight can be used as configuration information to facilitate subsequent text screening and adjustment.
[0132] Step S20: receiving a query condition and determining an input text according to the query condition.
[0133] In a specific implementation, the query condition is a condition input by a user for determining the input text. The input text is a specific text content determined according to the query condition.
[0134] When a user enters a query, such as "write a science fiction novel about a future city," the device determines the input text based on the query, such as a text describing future city life.
[0135] Step S30: performing feature vectorization on the input text based on the multi-dimensional feature knowledge base to obtain a feature vector.
[0136] In a specific implementation, a variety of different feature vectorization methods can be used to perform feature vectorization on the input text to obtain a feature vector.
[0137] Feature vectorization methods include one-hot encoding, TF-IDF, and word vectorization.
[0138] For example, for the input text "Future City Life," we first segment it to obtain ["future," "city," "life"]. We then convert it into a feature vector using methods such as one-hot encoding, TF-IDF vectors, or Word2Vec vectors. One-hot encoding is a binary vector that indicates whether a word exists in a specific vocabulary. TF-IDF vectors measure the importance of a word in a document. Word2Vec vectors are numerical representations of each word in a continuous space.
[0139] In a feasible implementation, the feature vector may include a coding vector and a word vector, so step S30 may include steps A21 to A25:
[0140] Step A21: creating a zero vector using a scientific computing library, and creating a vector space of corresponding length based on the zero vector and the multidimensional feature knowledge base;
[0141] It should be noted that scientific computing libraries, such as the NumPy library or the SciPy library in Python, provide functions and tools for processing numerical data. Specifically, the numpy library can be used to create a zero vector: np.zeros(len(feature_words[dimension])).
[0142] At the same time, a space vector of corresponding length can be created based on the zero vector and the multidimensional feature knowledge base. For example, if there are 100 different features in the knowledge base, a zero vector of length 100 is created. This zero vector will serve as the basis of the vector space, used to represent the relationship between the input text and the features in the knowledge base.
[0143] Step A22: Segmenting the input text to obtain text segmentation;
[0144] The process of segmenting a continuous natural language text into semantically reasonable basic units. For Chinese, this involves breaking sentences into words; for English, this may involve breaking sentences into words or phrases, thereby obtaining text segmentation.
[0145] Step A23: traversing the multidimensional feature knowledge base through the text segmentation, and when the text segmentation is located in the multidimensional feature knowledge base, setting the corresponding vector space to a first preset value; when the text segmentation is not located in the multidimensional feature knowledge base, setting the vector space to a second preset value;
[0146] In a specific implementation, the first preset value can be 1, indicating a successful match; the second preset value can be 0, indicating no match. By traversing the multidimensional feature knowledge base, it is determined whether the text segmentation word is located in the multidimensional feature knowledge base. If it is, the corresponding position is set to 1; if it is not, the corresponding position is set to 0. For example, if the word "smart" exists in the multidimensional feature knowledge base, the corresponding vector space position is set to 1; if "creation" is not in the multidimensional feature knowledge base, the corresponding vector space position remains 0.
[0147] Step A24: Obtaining a coding vector by using the first preset value and the second preset value;
[0148] It should be noted that, based on the results of the above steps, we obtain a vector consisting of the first preset value and the second preset value, which is the so-called encoding vector. For example, if the zero vector is initially [0, 0, 0, ..., 0], after step A23 it becomes [1, 0, 1, ..., 0], thus forming an encoding vector, where 1 and 0 respectively indicate whether the corresponding feature exists.
[0149] Step A25: Map the text word segmentation to a high-dimensional space through a preset word vector model to obtain a word vector.
[0150] Word vectors are deep semantic representations of words. The preset word vector models can be Word2Vec, GloVe, etc. Specifically, you can use the Word2Vec model of gensim.models to map text word segments to a high-dimensional space to obtain word vectors.
[0151] The word vector of each text segment can be obtained. If the word does not exist, a zero vector is returned, and the average value of all word vectors is calculated as the word vector representation of the text.
[0152] In a feasible implementation, the feature vector also includes a numerical feature vector, that is, a vector obtained using the TF-IDF method, so step S30 also includes steps A26 to A29:
[0153] Step A26: Segmenting the input text to obtain text segmentation;
[0154] Step A27: Calculate the word frequency of the text segmentation in the multidimensional feature knowledge base, wherein the word frequency is calculated by the following formula:
[0155]
[0156] It should be noted that sklearn.feature_extraction.text.TfidfVectorizer can be used to create a TF-IDF vectorizer through a multidimensional feature knowledge base during initialization, so that the input text can be converted into a vector through the TF-IDF vectorizer.
[0157] Term frequency is the frequency with which a word appears in a document. Specifically, we can count the number of occurrences of word t in the multidimensional feature knowledge base and the total number of occurrences in the multidimensional feature knowledge base to calculate the term frequency TF(t). For example, if the word "nature" appears 5 times in a knowledge base containing 100 words, its term frequency is 5 / 100 = 0.05.
[0158] Step A28: Calculate the inverse document frequency of the text segmentation in the multidimensional feature knowledge base, wherein the inverse document frequency is calculated by the following formula:
[0159]
[0160] Inverse Document Frequency (IDF) is a measure of a word's general importance. The smaller the IDF value of a word, the more widely distributed it is in the entire corpus; conversely, the larger the IDF value, the more unique the word is.
[0161] In practice, the inverse document frequency (IDF) can be calculated based on the number of occurrences of word t in the multidimensional feature knowledge base and the total number of occurrences in the multidimensional feature knowledge base. For example, if there are 1000 documents in the knowledge base and the word "nature" appears in 10 documents, then its IDF value is log(1000 / 10).
[0162] Step A29: Calculate a numerical feature vector using the word frequency and the inverse document frequency.
[0163] The TF-IDF method combines the term frequency and inverse document frequency calculated in the previous steps to construct a numerical feature vector. Specifically, for each text token, its TF value is multiplied by its IDF value to obtain a new weight, which reflects the importance of the token to the current document. Finally, these weights are combined into a vector, which is the numerical feature vector.
[0164] Step S40: Calculate the target similarity between the feature vectors.
[0165] The target similarity calculation is a three-layer fusion similarity calculation, which specifically includes vector level, intra-dimensional and inter-dimensional similarity. The vector level is to calculate the cosine similarity of three vector representations; the intra-dimensional fusion is to dynamically weighted merge the similarities of the three vectors; the inter-dimensional fusion is to adaptively adjust the similarity of the importance weights of the four dimensions.
[0166] In a feasible implementation, step S40 may include steps A31 to A33:
[0167] Step A31: Calculate the initial similarity between the feature vectors. The initial similarity is obtained by the following formula:
[0168]
[0169] Where A and B are two eigenvectors, · represents the dot product operation, and || || represents the modulus of the vector.
[0170] It should be noted that the three similarities are calculated for each dimension respectively, and the calculation formula of cosine similarity is adopted. As shown in the above formula, two feature vectors of the input text can be obtained, A and B are the two vectors to be compared, and the initial similarity between the feature vectors is calculated.
[0171] In a specific implementation, the initial similarity includes encoding vector similarity, numerical feature vector similarity, and word vector similarity. The encoding vector similarity is calculated by the following formula:
[0172] onehot_sim=1-cosine(query_onehot, text_onehot)
[0173] query_onehot is the encoding vector, text_onehot is the encoding vector of the target text;
[0174] It should be noted that query_onehot is the one-hot encoding vector corresponding to the query condition, text_onehot is the one-hot encoding vector corresponding to the target text, and the target text is standard text. A standard text library can be built in advance to store the target text.
[0175] The numerical feature vector similarity is calculated by the following formula:
[0176] tfidf_sim=1-cosine(query_tfidf,text_tfidf)
[0177] query_tfidf is a numerical feature vector, and text_tfidf is a numerical feature vector of the target text;
[0178] query_tfidf is the TF-IDF numerical feature vector corresponding to the query condition, and text_tfidf is the TF-IDF numerical feature vector of the target text.
[0179] The word vector similarity is calculated by the following formula:
[0180] vector_sim=1-cosine(query_vec,text_vec)
[0181] query_vec is the word vector, text_vec is the word vector of the target text;
[0182] query_vec is the average value of the word vector corresponding to the query condition, and text_vec is the average value of the word vector of the target text. The above formula can be used to calculate the encoding vector similarity, numerical feature vector similarity, and word vector similarity.
[0183] Step A32: Obtaining the weight of each dimension according to the configuration information;
[0184] It should be noted that the configuration information configures weights for different dimensions, specifically 0.3 for the plot dimension, 0.3 for the character dimension, 0.2 for the style dimension, and 0.2 for the subject matter dimension.
[0185] Step A33: Calculate target similarity using the dimension weights, the encoding vector similarity, the numerical feature vector similarity, and the word vector similarity. The target similarity is calculated using the following formula:
[0186] dimension_sim=0.3*onehot_sim+0.4*tfidf_sim+0.3*vector_sim
[0187] total_score=Σ(dimension_sim_i*weight_i)
[0188] Among them, total_score is the target similarity, the dimension weights include plot weight weight_plot, character weight weight_character, style weight weight_style and theme weight weight_theme, and the specific weight distribution is: weight_plot = 0.3 (plot), weight_character = 0.3 (character), weight_style = 0.2 (style), weight_theme = 0.2 (theme), dimension_sim_i is the similarity score of the i-th dimension, weight_i is the weight of the i-th dimension, i∈{plot, character, style, theme}.
[0189] It should be noted that the target similarity of dimension fusion can be calculated by jointly using the dimension weights and the encoding vector similarity, numerical feature vector similarity, and word vector similarity in the initial similarity. Specifically, the single-dimensional fusion can be calculated first, that is, the similarity scores of different dimensions are calculated by using the dimension weights, encoding vector similarity, numerical feature vector similarity, and word vector similarity, and the total_score target similarity is obtained by summarizing the similarity scores of different dimensions.
[0190] Step S50: dynamically adjusting the weight of the input text based on the configuration information to obtain an adjusted weight, and calculating a target similarity score based on the fusion of the adjusted weight and the target similarity.
[0191] It should be noted that the adjustment of weights may include text length adaptive adjustment, feature density perception adjustment and matching feedback adjustment, adjusting vector weights according to text length, adjusting dimension weights based on feature word distribution, and adjusting dimension importance through Z-score calculation to calculate the final similarity score.
[0192] The weights are adjusted by factors such as text length, feature density, and matching degree, and the Z-score Sigmoid adjustment factor is used to further optimize the weights.
[0193] Step S60: Filter text segments that are higher than the matching threshold in the configuration information according to the target similarity score as creation references.
[0194] It is understandable that texts can be filtered by matching thresholds and target similarity scores to filter out high-similarity fragments, and detailed matching analysis results can be returned: overall similarity score, matching scores of each dimension, extracted feature word list and other information, so that high-similarity fragments can be used as a reference for creation.
[0195] Step S70: inputting the preset prompt word template and the creation reference into the large language model, and performing text creation through the large language model.
[0196] It should be noted that the preset prompt word template is a specific prompt template. For example, when writing a novel, the specific prompt word template is a template for writing the novel, so that the LLM is guided to learn writing skills through the specific prompt template. By inputting the preset prompt word template and the creation reference into the large language model, the novel is generated through the large language model.
[0197] In a feasible implementation, step S70 may include: combining a preset prompt word template with the creation reference to obtain target prompt information; inputting the target prompt information into a large language model, performing text creation through the large language model, and generating a target creation text.
[0198] It should be understood that the preset prompt word template and the creative reference can be combined to obtain the information needed for creating a novel, that is, the target prompt information, and the target prompt information can be input into the large language model to directly generate the target creative text.
[0199] This embodiment provides a method for text creation enhanced by intelligent retrieval, which constructs a multidimensional feature knowledge base and sets configuration information; receives query conditions and determines input text based on the query conditions; performs feature vectorization on the input text based on the multidimensional feature knowledge base to obtain a feature vector; calculates the target similarity between the feature vectors; dynamically adjusts the weight of the input text based on the configuration information to obtain an adjusted weight, and calculates a target similarity score based on the fusion of the adjusted weight and the target similarity; uses the target similarity score to filter text fragments that are higher than the matching threshold in the configuration information as a creation reference; inputs a preset prompt word template and the creation reference into a large language model, and performs text creation through the large language model. By constructing a multidimensional feature knowledge base and combining it with a vectorization method, a multidimensional feature representation of the text is achieved; a dynamic weight adjustment mechanism is designed to achieve intelligent similarity calculation. Through multi-level similarity fusion calculation combined with dynamic adjustment of dimensional weights, it is ensured that the selected reference fragment meets the creation requirements, thereby improving the quality and usability of the created content.
[0200] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above embodiment 1 can be referred to the above introduction and will not be described in detail later. Figure 2 , step S50 includes steps S501 to S505:
[0201] Step S501: obtaining a preset text adjustment rule and the text length of the input text.
[0202] Preset text adjustment rules are a set of pre-defined rules used to adjust feature vector weights based on different conditions (such as text length). These rules may be based on experience, experimental results, or specific algorithms.
[0203] Text length refers to the number of characters or words in the input text.
[0204] The default text adjustment rules are as follows:
[0205] Short text (<100 words): TF-IDF weight is reduced to 0.8 times, Word2Vec weight is increased to 1.2 times, and One-hot weight remains unchanged;
[0206] For medium-length texts (100-1000 words), the weight remains unchanged;
[0207] Long text (>1000 words): TF-IDF weight is increased to 1.2 times, One-hot weight is reduced to 0.8 times, and Word2Vec weight remains unchanged.
[0208] Step S502: determining a target text adjustment rule from the preset text adjustment rules according to the text length.
[0209] In a specific implementation, the target text adjustment rule can be determined from the preset text adjustment rules according to the specific text length. For example, if the text length is short text, the target text adjustment rule is: the TF-IDF weight is reduced to 0.8 times, the Word2Vec weight is increased to 1.2 times, and the One-hot weight remains unchanged.
[0210] Step S503: Dynamically adjust the weight of the feature vector according to the target text adjustment rule to obtain a feature vector adjustment weight.
[0211] In a specific implementation, the weight of the feature vector can be dynamically adjusted according to the target text adjustment rule. Specifically, the initial weight of the feature vector can be obtained first, and then the initial weight of the feature vector can be adjusted according to the target text adjustment rule to obtain the feature vector adjustment weight.
[0212] Step S504: Calculate reference similarity using the feature vector adjustment weight and the target similarity.
[0213] It should be understood that the reference similarity can be calculated through the feature vector adjustment weight and the target similarity, specifically according to the dimension weight, encoding vector similarity, numerical feature vector similarity and characteristic vector adjustment weight in the target similarity.
[0214] The reference similarity is obtained by the following formula:
[0215] dimension_sim=w1*onehot_sim+w2*tfidf_sim+w3*vector_sim
[0216] Among them, w1, w2, and w3 are the weights of the feature vector after adaptive adjustment. For example, w1 is the weight adjusted for the encoding vector, w2 is the weight adjusted for the numerical feature vector, and w3 is the weight adjusted for the word vector.
[0217] Step S505: Calculate a target similarity score using the reference similarity and the input text.
[0218] In a specific implementation, the target similarity score can be calculated by reference similarity and input text. Specifically, a multi-dimensional fusion calculation can be performed based on the input text to determine the weight of the feature word density and the adjustment of the dimension matching weight, and finally calculate the target similarity score.
[0219] In a feasible implementation, step S505 may include steps B11 to B18:
[0220] Step B11: Calculating the density of characteristic words in the input text;
[0221] It should be noted that the number of feature words and the total number of times may be counted in advance, thereby calculating the feature word density of the input text.
[0222] The characteristic word density is obtained by the following formula:
[0223] density = number of feature words / total number of words
[0224] Here, density is the density of feature words. If 20 of the 100 words in an article are feature words, then the feature word density density = 20 / 100 = 0.2.
[0225] Step B12: adjusting the weight of each dimension in the configuration information according to the feature word density to obtain a feature word density adjustment factor.
[0226] The feature word density adjustment factor (density_factor_i) is a factor adjusted according to the feature word density, which is used to adjust the initial weights of different dimensions (such as encoding vector similarity, numerical feature vector similarity, and word vector similarity).
[0227] For high density (>0.1), the corresponding dimension weight is increased to 1.2 times; for low density (<0.02), the corresponding dimension weight is reduced to 0.8 times; for medium density (0.02-0.1), the dimension weight remains unchanged, thereby obtaining the feature word density adjustment factor.
[0228] Step B13: Calculate the average value and standard deviation of the dimensional similarity based on the encoding vector similarity, the numerical feature vector similarity, and the word vector similarity in the initial similarity between the feature vectors.
[0229] In a specific implementation, the dimension score statistical features can be calculated based on the encoding vector similarity, the numerical feature vector similarity and the word vector similarity. Specifically, the average mean_score of all dimension similarities can be calculated first, and the standard deviation std_score can be calculated.
[0230] Step B14: Calculate the dimension Z score based on the dimension similarity average and the standard deviation.
[0231] In a specific implementation, the Z score of each dimension may be calculated based on the mean and standard deviation of the dimension similarity.
[0232] The dimension Z score is obtained by the following formula:
[0233] z_score=(score-mean_score) / std_score
[0234] Here, the score is the dimension similarity, mean_score is the mean value, and std_score is the standard deviation.
[0235] Step B15: Use the Sigmoid function to map the Z score to the adjustment factor to obtain the Z score Sigmoid adjustment factor.
[0236] It is understood that weights can be dynamically adjusted based on the Z-score. Specifically, a sigmoid function can be used to map the Z-score to an adjustment factor, thereby obtaining a Z-score sigmoid adjustment factor. The Z-score sigmoid adjustment factor is the Z-score converted by the sigmoid function and is used to adjust the weight.
[0237] The Z-score Sigmoid adjustment factor is obtained by the following formula:
[0238] adjustment_i=1 / (1+e^(-z_score_i))
[0239] adjustment_factor_i=0.5+adjustment_i
[0240] Among them, the Z score Sigmoid adjustment factor is adjustment_factor_i, and z_score_i is the dimension Z score;
[0241] In a specific implementation, the Z-score Sigmoid adjustment factor may be mapped to a range of [0.5, 1.5], thereby applying the Z-score Sigmoid adjustment factor to the dimension weight.
[0242] Step B16: Determine the dimension adjustment weight according to the feature word density adjustment factor and the Z-score Sigmoid adjustment factor.
[0243] It should be noted that the dimension adjustment weight can be determined by the feature word density adjustment factor and the Z-score Sigmoid adjustment factor.
[0244] The dimension adjustment weight is obtained by the following formula:
[0245] adjusted_weight_i=base_weight_i*density_factor_i*adjustment_factor_i
[0246] Among them, base_weight_i is the initial dimension weight, which can be obtained directly, density_factor_i is the feature word density adjustment factor (0.8~1.2), and adjustment_factor_i is the Z-score Sigmoid adjustment factor (0.5~1.5).
[0247] Step B17: normalizing the dimension adjustment weight to obtain a normalized weight;
[0248] It should be noted that the normalized weight is the result of normalizing the weights of all dimension adjustments so that their sum is equal to 1.
[0249] The normalized weight is obtained by the following formula:
[0250] normalized_weight_i=adjusted_weight_i / Σ(adjusted_weight_i)
[0251] Among them, normalized_weight_i is the normalized weight, and adjusted_weight_i is the dimension adjustment weight; for example, if there are three adjusted weights of 0.36, 0.48, and 0.16, then their normalized weights will be each divided by the sum of 1.
[0252] Step B18: Calculate a target similarity score using the normalized weight and the reference similarity. The target similarity score is calculated using the following formula:
[0253] total_score=Σ(dimension_sim_i*normalized_weight_i)
[0254] where i∈{plot,character,style,theme}.
[0255] The target similarity score is the final similarity score, which takes into account the reference similarity and the normalized weights. If we have similarities of 0.7, 0.6, 0.8, and 0.9 in four dimensions, and the corresponding normalized weights are 0.25, 0.35, 0.2, and 0.2, then the total score will be total_score = 0.7*0.25+0.6*0.35+0.8*0.2+0.9*0.2 = 0.72.
[0256] This embodiment obtains a preset text adjustment rule and the text length of the input text; determines a target text adjustment rule from the preset text adjustment rule according to the text length; dynamically adjusts the weight of the feature vector according to the target text adjustment rule to obtain a feature vector adjustment weight; calculates a reference similarity according to the feature vector adjustment weight and the target similarity, and the reference similarity is obtained by the following formula: dimension_sim = w1*onehot_sim+w2*tfidf_sim+w3*vector_sim, wherein w1, w2, and w3 are weights of the feature vector after adaptive adjustment; calculates a target similarity score according to the reference similarity and the input text. The weight system can be adjusted according to demand to support the creation of different types of novels, adapt to different writing style requirements, and meet diverse creative needs.
[0257] For example, to help understand the implementation process of the text creation method for intelligent retrieval enhancement obtained by combining this embodiment with the above embodiment 1, please refer to Figure 3 , Figure 3 A brief flowchart of a text creation method enhanced by intelligent retrieval is provided. Specifically: according to multi-dimensional creation needs, a multi-dimensional feature knowledge base is established from multiple feature dimensions: plot dimension, character dimension, style dimension, subject matter dimension, etc., intelligent retrieval and matching are performed, and triple vectorization processing is performed, including one-hot encoding, TF-IDF vector, and Word2Vec vector. Then, dynamic weight adjustment is performed, including text length, feature density and matching degree, specifically vector weight adjustment, dimension weight adjustment and Z score adjustment, so as to screen out relevant retrieved fragments, and screen them according to preset thresholds to build a creation context, and then input into the large language model for LLM creation.
[0258] It should be noted that the above examples are only used to understand this application and do not constitute a limitation on the text creation method of this application with intelligent retrieval enhancement. More simple transformations based on this technical concept are all within the scope of protection of this application.
[0259] This application also provides a text creation device with intelligent retrieval enhancement, please refer to Figure 4 , the intelligent retrieval enhanced text creation device includes:
[0260] The construction module 10 is used to construct a multi-dimensional feature knowledge base and set configuration information.
[0261] The determination module 20 is configured to receive a query condition and determine an input text according to the query condition.
[0262] The feature vectorization module 30 is configured to perform feature vectorization on the input text based on the multi-dimensional feature knowledge base to obtain a feature vector.
[0263] The calculation module 40 is used to calculate the target similarity between the feature vectors.
[0264] The adjustment module 50 is configured to dynamically adjust the weight of the input text based on the configuration information to obtain an adjusted weight, and calculate a target similarity score based on the fusion of the adjusted weight and the target similarity.
[0265] The screening module 60 is configured to screen text segments that are higher than a matching threshold in the configuration information according to the target similarity score as a creation reference.
[0266] The input module 70 is used to input the preset prompt word template and the creation reference into the large language model, and perform text creation through the large language model.
[0267] The intelligent retrieval-enhanced text creation device provided in this application, which adopts the intelligent retrieval-enhanced text creation method in the above-mentioned embodiment, can solve the technical problem that current text creation relies on preset templates or simple keyword matching, making it difficult to generate high-quality text that meets user needs. Compared with the existing technology, the beneficial effects of the intelligent retrieval-enhanced text creation device provided in this application are the same as the beneficial effects of the intelligent retrieval-enhanced text creation method provided in the above-mentioned embodiment, and the other technical features of the intelligent retrieval-enhanced text creation device are the same as the features disclosed in the above-mentioned embodiment method, and are not further described here.
[0268] The present application provides a text creation device enhanced by intelligent retrieval, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the text creation method enhanced by intelligent retrieval in the above-mentioned embodiment one.
[0269] Reference below Figure 5, which shows a schematic diagram of the structure of a text creation device for intelligent retrieval enhancement suitable for implementing the embodiments of the present application. The text creation device for intelligent retrieval enhancement in the embodiments of the present application may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The intelligent retrieval-enhanced text creation device shown is merely an example and should not limit the functions and scope of use of the embodiments of the present application.
[0270] like Figure 5 As shown, the intelligent retrieval-enhanced text creation device may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes based on programs stored in a read-only memory (ROM) 1002 or programs loaded from a storage device 1003 into a random access memory (RAM) 1004. RAM 1004 also stores various programs and data required for the operation of the intelligent retrieval-enhanced text creation device. Processing device 1001, ROM 1002, and RAM 1004 are connected to each other via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, hard disk, etc.; and communication devices 1009. The communication devices 1009 can allow the intelligent retrieval-enhanced text creation device to communicate wirelessly or wired with other devices to exchange data. Although the figure shows an intelligent retrieval-enhanced text creation device with various systems, it should be understood that it is not required to implement or have all of the systems shown. More or fewer systems may be implemented or have instead.
[0271] In particular, according to the embodiments disclosed in the present application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program comprising program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0272] The intelligent retrieval-enhanced text creation device provided in this application, which utilizes the intelligent retrieval-enhanced text creation method of the aforementioned embodiment, can resolve the technical problem that current text creation relies on preset templates or simple keyword matching, making it difficult to generate high-quality text that meets user needs. Compared to the prior art, the beneficial effects of the intelligent retrieval-enhanced text creation device provided in this application are the same as the beneficial effects of the intelligent retrieval-enhanced text creation method provided in the aforementioned embodiment, and the other technical features of the intelligent retrieval-enhanced text creation device are the same as those disclosed in the method of the previous embodiment, and are not further described here.
[0273] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0274] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
[0275] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer program) stored thereon, and the computer-readable program instructions are used to execute the intelligent retrieval-enhanced text creation method in the above-mentioned embodiment.
[0276] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0277] The computer-readable storage medium may be included in the intelligent retrieval-enhanced text creation device; or it may exist independently without being assembled into the intelligent retrieval-enhanced text creation device.
[0278] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the intelligent retrieval enhanced text creation device, the intelligent retrieval enhanced text creation device enables the following: to build a multidimensional feature knowledge base and set configuration information; to receive query conditions and determine the input text based on the query conditions; to perform feature vectorization on the input text based on the multidimensional feature knowledge base to obtain a feature vector; to calculate the target similarity between the feature vectors; to dynamically adjust the weight of the input text based on the configuration information to obtain an adjusted weight, and to calculate a target similarity score based on the fusion of the adjusted weight and the target similarity; to screen text fragments that are higher than the matching threshold in the configuration information as a creation reference through the target similarity score; to input a preset prompt word template and the creation reference into a large language model, and to perform text creation through the large language model.
[0279] The computer program code for performing the operations of the present application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, 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 can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0280] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, program segment or a part of code, and the module, program segment or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.
[0281] The modules described in the embodiments of the present application may be implemented in software or hardware, wherein the name of a module does not necessarily limit the unit itself.
[0282] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., a computer program) for executing the above-mentioned intelligent retrieval-enhanced text creation method. This computer-readable storage medium can solve the technical problem that current text creation relies on preset templates or simple keyword matching, making it difficult to generate high-quality text that meets user needs. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the intelligent retrieval-enhanced text creation method provided in the above-mentioned embodiment, and will not be repeated here.
[0283] The present application also provides a computer program product, comprising a computer program, which implements the steps of the above-mentioned intelligent retrieval-enhanced text creation method when executed by a processor.
[0284] The computer program product provided in this application can address the current technical problem that text creation relies on preset templates or simple keyword matching, making it difficult to generate high-quality text that meets user needs. Compared with the existing technology, the beneficial effects of the computer program product provided in this application are the same as those of the intelligent retrieval-enhanced text creation method provided in the above-mentioned embodiment, and will not be elaborated here.
[0285] The above description is only part of the embodiments of the present application and does not limit the patent scope of the present application. All equivalent structural transformations made by using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect application in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A text creation method enhanced by intelligent retrieval, characterized in that: The intelligent retrieval-enhanced text creation method includes: Build a multi-dimensional feature knowledge base and set configuration information; receiving query conditions and determining input text according to the query conditions; Performing feature vectorization on the input text based on the multidimensional feature knowledge base to obtain a feature vector; Calculating target similarity between the feature vectors; Dynamically adjusting the weight of the input text based on the configuration information to obtain an adjusted weight, and calculating a target similarity score based on the adjusted weight and the target similarity; Screening text segments that are higher than a matching threshold in the configuration information using the target similarity score as a creation reference; The preset prompt word template and the creation reference are input into a large language model, and text creation is performed using the large language model.
2. The method according to claim 1, wherein The feature vector includes a coding vector and a word vector; The step of performing feature vectorization on the input text based on the multidimensional feature knowledge base to obtain a feature vector comprises: Creating a zero vector using a scientific computing library, and creating a vector space of corresponding length based on the zero vector and the multidimensional feature knowledge base; Performing word segmentation on the input text to obtain text word segmentation; Traversing the multidimensional feature knowledge base through the text segmentation, when the text segmentation is located in the multidimensional feature knowledge base, setting the corresponding vector space to a first preset value, and when the text segmentation is not located in the multidimensional feature knowledge base, setting the vector space to a second preset value; Obtaining a coding vector by using the first preset value and the second preset value; The text word segmentation is mapped to a high-dimensional space through a preset word vector model to obtain a word vector.
3. The method according to claim 1, wherein The feature vector includes a numerical feature vector; The step of performing feature vectorization on the input text based on the multidimensional feature knowledge base to obtain a feature vector comprises: Performing word segmentation on the input text to obtain text word segmentation; Calculate the word frequency of the text segmentation in the multidimensional feature knowledge base, wherein the word frequency is calculated by the following formula: Calculate the inverse document frequency of the text segmentation in the multidimensional feature knowledge base, wherein the inverse document frequency is calculated by the following formula: A numerical feature vector is calculated using the word frequency and the inverse document frequency.
4. The method according to claim 1, wherein The step of calculating the target similarity between the feature vectors includes: The initial similarity between the feature vectors is calculated, and the initial similarity is obtained by the following formula: Where A and B are two feature vectors, · represents the dot product operation, |||| represents the modulus of the vector, and the initial similarity includes the encoding vector similarity, the numerical feature vector similarity, and the word vector similarity. The encoding vector similarity is calculated by the following formula: onehot_sim=1-cosine(query_onehot, text_onehot) query_onehot is the encoding vector, text_onehot is the encoding vector of the target text; The numerical feature vector similarity is calculated by the following formula: tfidf_sim=1-cosine(query_tfidf,text_tfidf) query_tfidf is a numerical feature vector, and text_tfidf is a numerical feature vector of the target text; The word vector similarity is calculated by the following formula: vector_sim=1-cosine(query_vec,text_vec) query_vec is the word vector, text_vec is the word vector of the target text; Obtaining weights of various dimensions according to the configuration information; The target similarity is calculated by the dimension weight, the encoding vector similarity, the numerical feature vector similarity and the word vector similarity. The target similarity is calculated by the following formula: dimension_sim=0.3*onehot_sim+0.4*tfidf_sim+0.3*vector_sim total_score=Σ(dimension_sim_i*weight_i) Among them, total_score is the target similarity, the dimension weights include plot weight weight_plot, character weight weight_character, style weight weight_style and theme weight weight_theme, and the specific weight distribution is: weight_plot = 0.3 (plot), weight_character = 0.3 (character), weight_style = 0.2 (style), weight_theme = 0.2 (theme), dimension_sim_i is the similarity score of the i-th dimension, weight_i is the weight of the i-th dimension, i∈{plot, character, style, theme}.
5. The method according to claim 1, wherein The step of dynamically adjusting the weight of the input text based on the configuration information to obtain an adjusted weight, and calculating a target similarity score based on the adjusted weight and the target similarity comprises: Obtaining a preset text adjustment rule and the text length of the input text; Determining a target text adjustment rule from the preset text adjustment rules according to the text length; Dynamically adjusting the weight of the feature vector according to the target text adjustment rule to obtain a feature vector adjustment weight; The reference similarity is calculated by adjusting the feature vector weight and the target similarity. The reference similarity is obtained by the following formula: dimension_sim=w1*onehot_sim+w2*tfidf_sim+w3*vector_sim Among them, w1, w2, and w3 are the weights of the feature vector after adaptive adjustment; A target similarity score is calculated using the reference similarity and the input text.
6. The method according to claim 5, wherein The step of calculating a target similarity score using the reference similarity and the input text comprises: Calculate the density of the characteristic words in the input text, and the characteristic word density is obtained by the following formula: density = number of feature words / total number of words Among them, density is the density of feature words; Adjusting the weight of each dimension in the configuration information according to the feature word density to obtain a feature word density adjustment factor; Calculate the average value and standard deviation of the dimensional similarity based on the encoding vector similarity, the numerical feature vector similarity and the word vector similarity in the initial similarity between the feature vectors; The dimension Z score is calculated based on the dimension similarity average and the standard deviation. The dimension Z score is obtained by the following formula: z_score=(score-mean_score) / std_score Wherein, the score is the dimension similarity, mean_score is the mean value, and std_score is the standard deviation; The Z score is mapped to the adjustment factor using the Sigmoid function to obtain the Z score Sigmoid adjustment factor, which is obtained by the following formula: adjustment_i=1 / (1+e^(-z_score_i)) adjustment_factor_i=0.5+adjustment_i Among them, the Z score Sigmoid adjustment factor is adjustment_factor_i, and z_score_i is the dimension Z score; The dimension adjustment weight is determined according to the feature word density adjustment factor and the Z score Sigmoid adjustment factor. The dimension adjustment weight is obtained by the following formula: adjusted_weight_i = base_weight_i * density_factor_i * adjustment_factor_i, where base_weight_i is the initial dimension weight, density_factor_i is the feature word density adjustment factor, and adjustment_factor_i is the Z-score Sigmoid adjustment factor; The dimension adjustment weight is normalized to obtain a normalized weight, and the normalized weight is obtained by the following formula: normalized_weight_i=adjusted_weight_i / Σ(adjusted_weight_i) where normalized_weight_i is the normalized weight and adjusted_weight_i is the dimension adjustment weight; The target similarity score is calculated by the normalized weight and the reference similarity, and the target similarity score is calculated by the following formula: total_score=Σ(dimension_sim_i*normalized_weight_i) Where i∈{plot,character,style,theme}.
7. The method according to claim 1, wherein The steps of constructing a multidimensional feature knowledge base and initializing configuration information include: Collect feature word data; Performing multi-dimensional division on the feature word data using a preset word segmentation library to obtain multi-dimensional feature words; Establishing a multidimensional feature knowledge base based on the multidimensional feature words; Setting a matching threshold and setting a dimension weight for each dimension in the multi-dimensional feature word; Configuration information is obtained through the matching threshold and the dimension weight.
8. The method according to any one of claims 1 to 7, characterized in that The step of inputting the preset prompt word template and the creation reference into the large language model and performing text creation using the large language model includes: Combining the preset prompt word template with the creation reference to obtain target prompt information; The target prompt information is input into a large language model, and text creation is performed through the large language model to generate a target creation text.
9. A text creation device enhanced by intelligent retrieval, characterized in that: The device comprises: Construction module, used to build a multi-dimensional feature knowledge base and set configuration information; A determination module, configured to receive a query condition and determine an input text according to the query condition; A feature vectorization module, configured to perform feature vectorization on the input text based on the multidimensional feature knowledge base to obtain a feature vector; A calculation module, used for calculating the target similarity between the feature vectors; an adjustment module, configured to dynamically adjust the weight of the input text based on the configuration information to obtain an adjusted weight, and calculate a target similarity score based on the adjustment weight and the target similarity; A screening module, configured to screen text segments having a target similarity score higher than a matching threshold in the configuration information as a creation reference; The input module is used to input the preset prompt word template and the creation reference into the large language model, and perform text creation through the large language model.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the intelligent retrieval enhanced text creation method according to any one of claims 1 to 8 are implemented.
Citation Information
Cited By
Intelligent field matching method and system based on large model and storable medium
CN120929850A
A large model-based intelligent field matching method, system and storage medium
CN120929850B
Text matching method based on large model, medium and equipment
CN121388631A