Material generation method, model training method, feature extraction method, and device
By generating and filtering material pairs using a large language model, the problems of insufficient efficiency and accuracy in material construction are solved, achieving efficient and accurate construction of training samples and improving the model training effect.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ALIBABA DAMO (HANGZHOU) TECH CO LTD
- Filing Date
- 2023-09-19
- Publication Date
- 2026-05-29
AI Technical Summary
The efficiency and accuracy of material construction in existing technologies need to be improved, especially in the case of unlabeled data, it is difficult to generate high-quality training samples, resulting in poor model training performance.
By using a large language model to generate materials that have implicit or contradictory relationships with the original materials, and then verifying and filtering them through a second model, high-quality material pairs are constructed, thereby improving the efficiency and accuracy of material generation.
Automatically constructing training samples under unlabeled data conditions improves the efficiency and accuracy of data generation, reduces sampling bias, and enhances the overall efficiency and accuracy of model training.
Smart Images

Figure CN117194638B_ABST
Abstract
Description
Technical Field
[0001] This application relates to artificial intelligence technology, and in particular to a method for generating materials, a method for training models, a method for extracting features, and an apparatus. Background Technology
[0002] With the continuous development of artificial intelligence, the importance of material construction has become increasingly prominent, as materials play an important role in model training, user interaction, and other aspects.
[0003] For example, in the field of natural language processing, the material may include sentences. Positive sample pairs and negative sample pairs can be constructed based on the material. Positive sample pairs contain two sentences with the same semantics, and negative sample pairs contain two sentences with different semantics. Thus, based on contrastive learning, a model for extracting feature vectors of sentences is obtained.
[0004] Currently, the efficiency and accuracy of material creation need to be further improved. Summary of the Invention
[0005] This application provides a method for generating materials, a method for training models, a method for extracting features, and an apparatus to improve the efficiency and accuracy of constructing materials, thereby improving the overall efficiency and accuracy of model training.
[0006] In a first aspect, embodiments of this application provide a method for generating materials, including:
[0007] Obtain original materials and at least one generated material corresponding to a target relationship, wherein the generated material corresponding to any target relationship is a material generated by the first model that has the target relationship with the original materials;
[0008] For any generated material, the relationship between the original material and the generated material is verified based on the second model to obtain a material pair that has been verified to meet the corresponding target relationship. The material pair includes the original material and the generated material.
[0009] Secondly, embodiments of this application provide a model training method, including:
[0010] Obtain a training sample set, wherein the training samples in the training sample set include material pairs obtained based on the method described in the first aspect;
[0011] The base model is trained based on the training sample set.
[0012] Thirdly, embodiments of this application provide a feature extraction method, including:
[0013] Obtain the target information to be processed, input the target information into the feature extraction model, and obtain the feature vector corresponding to the target information;
[0014] The feature extraction model is either the material pair constructed by the method described in the first aspect, or the model obtained by training the base model by the method described in the second aspect.
[0015] Fourthly, embodiments of this application provide an information processing method, including:
[0016] Retrieve query information to be processed;
[0017] Based on the target model, at least one piece of knowledge is obtained by searching the knowledge base, wherein the at least one piece of knowledge is: knowledge that has a target relationship with the query information;
[0018] Based on at least one piece of knowledge found, determine the output query results;
[0019] The target model is either the material pair constructed by the method described in the first aspect, or the model obtained by training the base model by the method described in the second aspect.
[0020] Fifthly, embodiments of this application provide an electronic device, including:
[0021] At least one processor; and
[0022] A memory that is communicatively connected to the at least one processor;
[0023] The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, cause the electronic device to perform the method described in any of the above aspects.
[0024] Sixthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the method described in any of the above aspects.
[0025] In a seventh aspect, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the method described in any of the above aspects.
[0026] The material generation method, model training method, feature extraction method, and device provided in this application embodiment can use a first model to obtain generated materials that have at least one target relationship with the original materials. For any generated material, the relationship between the original material and the generated material is verified based on a second model to obtain material pairs that have been verified to meet the corresponding target relationship. In this way, a large number of materials can be generated using the model's generation capability, effectively improving the efficiency of material construction. Furthermore, the model's evaluation capability can be used to screen the generated materials, improving the accuracy of the obtained material pairs, thereby improving the overall efficiency and accuracy of model training. Attached Figure Description
[0027] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0028] Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of this application;
[0029] Figure 2 A schematic diagram illustrating the principle of constructing training samples using the model's generation and evaluation capabilities, provided for an embodiment of this application;
[0030] Figure 3 A schematic flowchart illustrating a material generation method provided in an embodiment of this application;
[0031] Figure 4 A schematic diagram illustrating a material selection range provided in an embodiment of this application;
[0032] Figure 5 A schematic diagram of an interactive interface corresponding to the material construction stage provided in an embodiment of this application;
[0033] Figure 6 A schematic flowchart illustrating a model training method provided in an embodiment of this application;
[0034] Figure 7 A schematic diagram illustrating the principle of a model training method provided in an embodiment of this application;
[0035] Figure 8 A schematic diagram of an interactive interface corresponding to the model training stage provided in an embodiment of this application;
[0036] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0037] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0038] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application.
[0039] It should be noted that the user information (including but not limited to user device information, user attribute information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with relevant laws, regulations and standards, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0040] First, let me explain the terms used in this application:
[0041] Contrastive learning is a machine learning method that aims to learn data representations by comparing the similarities and differences between different samples. For each sample in contrastive learning, the algorithm compares it to other samples, defining similarity and difference as part of the loss function. The goal of contrastive learning is to make samples in positive pairs more similar and samples from different negative pairs more different. Therefore, to clearly define the positive and negative pairs needed for contrastive learning, there often needs to be a clear relationship between the samples. In this way, more robust and better generalization-performing feature vectors (feature representations) can be learned, which can be used for various machine learning tasks such as classification, clustering, and retrieval.
[0042] Sentence Representation Learning (SRM) is a natural language processing (NLP) technique that aims to learn feature representations of sentences from large-scale text data and convert natural language text into mathematical vector representations for computer processing and analysis. The goal is to encode the semantic information of sentences into points in a continuous vector space, such that similar sentences are closer together and dissimilar sentences are farther apart. This representation method can be applied to various NLP tasks, such as text classification, sentence similarity calculation, and sentiment analysis.
[0043] Natural Language Inference (NLI) refers to the process of reasoning and inferring from natural language text using natural language understanding and reasoning techniques. It aims to extract logical relationships and infer new information from text to understand its meaning. NLI typically consists of two main tasks: textual entailment and inference verification. Textual entailment determines whether a sentence can be inferred from another sentence, while inference verification checks whether a given text conforms to a certain logical structure. NLI has wide applications in natural language processing, artificial intelligence, and cognitive science, such as question answering systems, information retrieval, automatic summarization, and machine translation.
[0044] Similarity masking refers to labeling similar content. For example, in natural language processing, similar parts of a text sequence or similar sentences within a batch can be labeled, enabling the model to better capture the relationships between them during the learning process and perform subsequent operations. In some techniques, similarity masks are implemented using subword-based masking, which involves segmenting the text sequence into multiple subwords and labeling identical subwords. Common subword segmentation algorithms in natural language processing include Byte Pair Encoding (BPE) and WordPiece. Similarity masks are commonly used in tasks such as text matching and text classification to improve the accuracy and generalization ability of text processing models, enabling them to better understand the semantic and structural information in text sequences. In this embodiment, similarity masking refers to using a pre-trained model to identify a batch of sentences and find those with similar semantics.
[0045] This application's embodiments can construct training samples using large models, such as large language models. A large language model refers to a deep learning language model with a massive number of language model parameters, typically containing hundreds of millions, tens of billions, hundreds of billions, trillions, or even tens of trillions of language model parameters. Large language models can also be called foundational language models. They are pre-trained using large-scale unlabeled corpora to produce pre-trained language models with hundreds of millions of parameters. Such language models can adapt to a wide range of downstream tasks and have good generalization capabilities. Examples include Large Language Models (LLMs) and multi-modal pre-training models.
[0046] In practical applications, large language models require only a small number of samples to fine-tune the pre-trained language model before they can be applied to different tasks. Large language models can be widely used in fields such as Natural Language Processing (NLP) and Computer Vision. Specifically, they can be applied to computer vision tasks such as Visual Question Answering (VQA), Image Captioning (IC), and Image Generation, as well as NLP tasks such as text-based sentiment classification, text summarization, and machine translation. The main application scenarios of large language models include digital assistants, intelligent robots, search, online education, office software, e-commerce, and intelligent design.
[0047] The application scenarios of this application will be explained below.
[0048] The solution in this application embodiment can realize the construction of materials, wherein the materials can be statements or other materials of any other form, which can be used as training samples to train the feature extraction model. The feature extraction model can be used to extract the feature vector of the target object, thereby realizing tasks such as classification and search.
[0049] Figure 1 This is a schematic diagram illustrating an application scenario provided by an embodiment of this application. For example... Figure 1 As shown, in the e-commerce field, after obtaining the user's corresponding search information, the search information can be input into the feature extraction model to extract the feature vector of the search information, and based on the feature vector, related products can be searched from the product information database. Here, related products refer to one or more products whose feature vector is closest to the feature vector of the search information.
[0050] like Figure 1As shown, the product information database contains multiple products, such as product A, product B, and product C. Each product can have its corresponding feature vector extracted using a feature extraction model. The feature vector represents the product's position in the vector space. For any two products, the closer their feature vectors are, the more similar the two products are; the farther apart their feature vectors are, the greater the difference between the two products. In this way, one or more products matching the user's search information can be found from the product information database using the feature vectors, and corresponding search results can be provided to the user based on the found products.
[0051] The search information may include user-inputted search terms, as well as user profile information, reviews, browsing information, etc. When extracting the feature vector of a product, relevant product information, such as descriptions and reviews, can be input into the feature extraction model. The specific relevant information used can be set according to actual needs, and this embodiment does not impose any restrictions.
[0052] Feature extraction models can be trained using contrastive learning methods. Contrastive learning is highly effective and efficient in feature extraction scenarios by bringing positive sample pairs closer together and pushing negative sample pairs further apart, thus attracting widespread attention. However, because contrastive learning is very sensitive to the quality of positive and negative sample pairs, its training performance is highly dependent on the data used, often requiring manual annotation of sample pairs.
[0053] For example, in the field of natural language processing, when training a sentence representation model to extract feature vectors from sentences, a natural language inference dataset consisting of sentence pairs with clear semantic relationships becomes a suitable data source. However, obtaining a large number of manually annotated sentence pairs can be costly in terms of time and resources, especially for different application domains. Domain-specific sentence pairs are needed to better train the model. When there are multiple application domains, the cost of manual annotation increases exponentially, making it difficult for such methods to generalize to application scenarios in different domains.
[0054] To address this issue, unsupervised sentence representation learning methods can be considered. However, the lack of explicit label information may lead to poor training performance. For example, a sentence can be used as a positive example, while other sentences in the same training batch are used as negative examples to train the model. However, this can cause sampling bias, as the model learns features beyond semantic information as clustering criteria, thus failing to accurately extract feature vectors.
[0055] An intuitive example is that during model training, a batch of sentences is randomly sampled from the database and trained on this batch of sentences. Since the sentences themselves are positive examples, all positive sample pairs are two sentences with the same surface features such as length and syntax. This causes the model to learn more about the surface features of the sentences. The model tends to classify sentences with the same length and syntax into one category, while learning less about the semantic information of the sentences themselves, making it difficult to accurately extract semantic features.
[0056] In view of this, embodiments of this application provide a method for constructing training samples. This method utilizes the generation capabilities of a large language model to generate sentences with implicit relationships to the original sentences, as well as sentences with contradictory relationships, which are used as positive and negative examples, respectively. Furthermore, since sentences generated by the large language model may contain certain errors, the generated sentences can be further filtered using the model's evaluation capabilities.
[0057] Figure 2 This is a schematic diagram illustrating the principle of constructing training samples using the model's generation and evaluation capabilities, as provided in an embodiment of this application. Figure 2 As shown, in the first stage, an implied sentence and a contradictory sentence can be generated for each original sentence using a large language model. The first original sentence is "an increase in temperature of a gas will result in an increase in its volume", and the second original sentence is "an older man is drinking orange juice at a restaurant".
[0058] By inputting two original statements and a prompt into a large language model, we can obtain the implied sentences and contradictory sentences corresponding to each original statement. The prompt can be divided into two types: positive prompt and negative prompt, which are used to prompt the model to generate sentences that have an implied relationship with the original statements and sentences that have a contradictory relationship with the original statements, respectively.
[0059] For example, the implied sentence generated from the first original statement is "The volume of a gas increases as temperature increases," while the contradictory sentence is "A decrease in temperature of a gas will result in an adecrease in its volume." The implied sentence generated from the second original statement is "An old man is consuming orange juice while dining at a restaurant," while the contradictory sentence is "A younger woman is drinking orange juice at home."
[0060] Although the large language model generates implied and contradictory sentences corresponding to the original statements based on its own generation capabilities, there may be errors. For example, the contradictory sentence corresponding to the first original statement, "A decrease in gas temperature will lead to a decrease in its volume," actually has the same meaning as the original statement, "An increase in gas temperature will lead to an increase in its volume." However, because there are contradictory words (such as "increase" and "decrease") between it and the original statement, the model mistakenly treats it as a statement with a contradictory relationship. The actual meaning of this sentence is correct and it should not be considered a contradictory sentence. Therefore, the generated contradictory sentence is unqualified and should be discarded. The dashed lines in the figure represent the discarded operations.
[0061] Therefore, in this embodiment, a second stage can be introduced, in which the large language model is used as a semantic-aware filter. The evaluation capability of the large language model is used to further screen the generated implied sentences and contradictory sentences. For example, unqualified sentences are filtered out, and qualified sentences are added to the training sample set. The training sample set can be used to train the feature extraction model.
[0062] In this way, by leveraging the generation and evaluation capabilities of large language models, training sample sets can be automatically constructed without any data annotations. This significantly improves efficiency compared to manual annotation methods. Furthermore, it can better avoid the sampling bias problem that the aforementioned unsupervised sentence representation learning methods cannot solve, thereby improving the accuracy of training samples and having a wide range of application scenarios.
[0063] Based on the above implementation scheme, this application provides the following concept: first, obtain original materials and generated materials, wherein the original materials and generated materials have a target relationship; then, filter the original materials and generated materials to obtain material pairs that meet the target relationship. The materials are not limited to statements, the application of the materials is not limited to model training, and the target relationship is not limited to implication and contradiction. Specific implementation schemes will be described in detail below.
[0064] The following detailed description of some embodiments of this application is provided in conjunction with the accompanying drawings. Where there is no conflict between the embodiments, the following embodiments and features can be combined with each other. Furthermore, the timing of the steps in the following method embodiments is merely an example and not a strict limitation.
[0065] Figure 3 This is a flowchart illustrating a material generation method provided in an embodiment of this application. The method in this embodiment can be implemented on any device with data processing capabilities, such as in the cloud, locally deployed, on a client device, or on an IoT (Internet of Things) device. Figure 3 As shown, the method may include:
[0066] Step 301: Obtain the original material and at least one generated material corresponding to the target relationship, wherein the generated material corresponding to any target relationship is a material generated by the first model that has the target relationship with the original material.
[0067] The original material may include at least one modality, which is at least one of the following: text, image, audio, video, etc.
[0068] In one example, the original material can be text, which can be a statement or other types of text, such as code, paragraphs, etc. In another example, the original material can be an image. In yet another example, the original material can be a combination of image and audio.
[0069] Based on the original material, corresponding generated material can be obtained using the first model. The original material and the generated material can have the same or different modalities. For example, both the original material and the generated material can be text, or both can be images. Alternatively, the original material can be text with audio, and the generated material can be an image.
[0070] One or more generated materials can be obtained from the same original material. If there are multiple generated materials, each generated material can have a different target relationship with the original material.
[0071] The target relationship can be: implied, contradictory, neutral, etc., or it can be a relationship with a specific degree of similarity.
[0072] Optionally, obtaining the original material and the generated material corresponding to at least one target relationship includes: obtaining the original material from the original material library; inputting the original material and the generation prompt information corresponding to any target relationship into the first model to obtain the generated material corresponding to the target relationship; wherein, the generation prompt information is used to prompt the first model to generate material that has the target relationship with the original material.
[0073] Optionally, when there are multiple target relationships, the generated prompts for each target relationship can be different. For each target relationship, the corresponding generated prompts can be input into the first model to obtain generated material that matches the original material for that target relationship.
[0074] Taking the source material as a statement and at least one target relation as implication and / or contradiction as an example, in this step, the original statement and at least one generated statement corresponding to the original statement can be obtained. The generated statement is generated by the first model based on the original statement, and the at least one generated statement includes: an implication statement and / or a contradiction statement.
[0075] Wherein, the implied sentence is a sentence that has an implied relationship with the original sentence, and the contradictory sentence is a sentence that has a contradictory relationship with the original sentence. An implied relationship can mean that the original sentence and the generated sentence have the same meaning, and a contradictory relationship can mean that the original sentence and the generated sentence have contradictory meanings.
[0076] Optionally, the generated hints corresponding to the target relation may specifically be positive example hints corresponding to the implied sentence and / or negative example hints corresponding to the contradictory sentence. Obtaining the original statement and at least one generated statement corresponding to the original statement may include:
[0077] Obtain the original statements from the original resource library;
[0078] Input the original statement and positive example prompts into the first model to obtain the implied statement corresponding to the original statement; and / or input the original statement and negative example prompts into the first model to obtain the contradictory statement corresponding to the original statement;
[0079] The positive example prompts and negative example prompts are used to prompt the first model to generate the implied sentence and contradictory sentence of the original statement, respectively.
[0080] Optionally, the original material library may include multiple original statements. Any original statement to be processed is selected from the original material library, and the first model is used to generate the corresponding implied and contradictory statements. In this embodiment, both the implied and contradictory statements are referred to as generated statements. Assuming the original material library contains N original statements, and one implied and one contradictory statement are generated for each original statement, then 2N generated statements can be obtained from the N original statements.
[0081] Optionally, the first model can be a large language model, into which the original sentence and prompt information can be input to obtain the corresponding implied and contradictory sentences. Prompt information can be set separately for the implied and contradictory sentences.
[0082] For example, the positive example prompt for an implied sentence could be: "Write a sentence that is an entailment of '{x}'"; the negative example prompt for a contradictory sentence could be: "Write a sentence that is negative with '{x}'". Here, 'x' can be replaced with the original sentence.
[0083] In other optional implementations, the at least one target relationship can be having a specific similarity to the original material. In this step, the original material and at least one generated material corresponding to a preset similarity can be obtained, wherein any generated material corresponding to a preset similarity is a material generated by the first model that has the preset similarity to the original material.
[0084] For example, two preset similarity values can be set, namely 0 and 5. The first model can generate two generated materials based on an original material. The similarity values of the two generated materials with the original material are 0 and 5, respectively, which can correspond to the aforementioned contradictory sentence and implied sentence.
[0085] Alternatively, three preset similarity levels can be set: 0, 2.5, and 5. The resulting three generated materials can correspond to contradictory, neutral, and implied sentences, respectively. Of course, the two or three preset similarity levels can also be other values, or more or fewer preset similarity levels can be set; the corresponding processing principle is similar.
[0086] Specifically, the first model can be a large language model with a certain level of language understanding and processing capabilities. When the target relationship is implication or contradiction, it can directly prompt the first model to generate material that has an implication or contradiction relationship with the original material. However, when the target relationship is other, such as a preset similarity, the large language model may not understand the actual meaning of the preset similarity. In this case, material examples can be added to the generated prompt information.
[0087] For example, the generated prompt message could be: "There are two materials here: Material 1 and Material 2, and their similarity is 4. Please refer to the above information to generate a material with a similarity of 4 to the target material x."
[0088] In this way, by using a large language model as a generator, generated materials with target relationships can be directly generated from the unlabeled original materials in the original material library, which effectively improves the efficiency of obtaining generated materials. Furthermore, the generated materials have a certain degree of accuracy and can serve as the basis for subsequent training.
[0089] In other alternative implementations, models other than large language models can be used to obtain generated content. For example, a small model specifically designed to generate content with target relationships can be trained. This small model can generate content without prompting. Here, "small model" can refer to any type of machine learning model with a simple structure and fewer parameters than a large language model.
[0090] Step 302: For any generated material, verify the relationship between the original material and the generated material based on the second model to obtain a material pair that has been verified to meet the corresponding target relationship. The material pair includes the original material and the generated material.
[0091] Optionally, the second model can determine the relationship between the original and generated materials. If this relationship matches the corresponding target relationship, the material pair is considered to be a verified material pair that conforms to the target relationship; otherwise, it is considered to be a material pair that does not conform to the target relationship. In this way, the second model can be used to filter the generated materials.
[0092] Optionally, verifying the relationship between the original material and the generated material based on the second model to obtain a material pair that has been verified to conform to the corresponding target relationship may include: inputting the original material, the generated material, and verification prompt information into the second model to obtain the relationship between the original material and the generated material; if the obtained relationship matches the target relationship, then determining the original material and the generated material as a material pair that has been verified to conform to the corresponding target relationship; wherein, the verification prompt information is used to instruct the second model to determine the relationship between the original material and the generated material.
[0093] Optionally, the verification prompt information may be used to instruct the second model to determine the relationship between the original material and the generated material from a preset relationship range, and to provide the meaning of at least two preset relationships in the preset relationship range as a reference.
[0094] Specifically, the preset relationship range can be a continuous range or include discrete values, where different values represent different relationships. For example, the preset relationship range can include multiple preset relationships, which can be exactly the same as, partially the same as, or completely different from, at least one target relationship in the aforementioned steps.
[0095] For example, the at least one target relation can be implication or contradiction, and the multiple preset relations can be multiple preset similarities. For example, a similarity of 5 matches implication, a similarity of 0 matches contradiction, and a similarity of 3 matches neither implication nor contradiction.
[0096] Taking the material as a statement, at least one target relation as implication and / or contradiction, and a preset relation range as the similarity range as an example, in this step, for any generated statement, the similarity between the original statement and the generated statement can be determined based on the second model. If the similarity meets the preset requirements, then the original statement and the generated statement are determined to be a material pair that has been verified to conform to the corresponding target relation.
[0097] The second model can be the same as the first model, or it can be a different model. For example, the first model and the second model can be the same large language model; or, the first model and the second model can both be large language models, but with different structures or trained on different datasets; or, at least one of the first model and the second model can be a small model specifically designed to perform generation or evaluation functions.
[0098] Optionally, the original statement, the generated statement, and the verification prompt information can be input into the second model to obtain the similarity between the original statement and the generated statement;
[0099] The verification prompt information is used to instruct the second model to determine the similarity between the original statement and the generated statement from a preset similarity range, and to provide the meaning of at least two similarities in the similarity range as a reference; the first model and the second model are the same model.
[0100] Specifically, when the first and second models are the same model, different prompts can be used to instruct the model to perform different processing. When evaluating similarity, the original statement, the generated statement, and verification prompts can be input into the second model. The verification prompts provide a similarity range, serving as a constraint on the final similarity output of the second model. Furthermore, the verification prompts can provide guidance on the similarity, i.e., the actual meaning of multiple similarity values within the similarity range. In particular, they can inform the second model of the meaning of the values at the two endpoints and / or the center of the similarity range, facilitating a better evaluation of the statement similarity.
[0101] For example, the verification prompt information may be: scoring the semantic similarity of the following sentences between 0.0 and 5.0, where 5.0 indicates they have the same meaning and 0.0 indicates they are completely different: (a) “{x}”, (b) “{x_y}”. Here, x can be replaced with the original statement, and x_y can be replaced with the generated statement corresponding to the original statement.
[0102] In other optional implementations, the preset relationship range in the verification prompt information may include: implication, neutrality, contradiction, etc., instructing the second model to select the relationship between the original material and the generated material, that is, to determine which of the above three relationships the original material and the generated material belong to (a three-class classification operation). Alternatively, a small model can be trained as a second model to implement the three-class classification operation, eliminating the need for verification prompt information and improving processing efficiency.
[0103] In this way, the second model can accurately verify the relationship between the generated material and the original material under the guidance of the verification prompts, thereby improving the screening effect. Furthermore, the first model and the second model can be the same model, using different prompts. The generation and evaluation operations can be completed through the same model, which can obtain better material with less resources, balancing efficiency and accuracy.
[0104] In one or more embodiments of this application, optionally, when there are multiple target relationships, for any generated material, the relationship between the original material and the generated material is verified based on the second model to obtain a material pair that has been verified to conform to the corresponding target relationship, including:
[0105] The relationship between the original materials and the generated materials is determined based on the second model;
[0106] If the relationship between the original material and each generated material matches the corresponding target relationship, then the original material and each generated material are determined to constitute a material pair with a corresponding target relationship, and the material pair is added to the target material library;
[0107] If the relationship between the original material and any generated material does not match the corresponding target relationship, then the original material and each of the corresponding generated materials are discarded.
[0108] Specifically, when there are multiple target relationships, there are also multiple corresponding generated materials. For any generated material, if the relationship between the generated material and the original material, as determined by the second model, matches the target relationship corresponding to the generated material, it means that the generated material meets the requirements.
[0109] If all generated assets meet the requirements, each generated asset and the original asset form an asset pair, and the tag of this asset pair is the target relationship corresponding to the generated asset, and it is added to the target asset library. If any one of the generated assets corresponding to a certain original asset does not meet the requirements, all generated assets corresponding to that original asset will be discarded.
[0110] Optionally, the at least one target relation includes positive example relations and negative example relations, with corresponding generated materials being positive example materials and negative example materials, respectively. Positive example relations and negative example relations can have the same meaning and different meanings, respectively, corresponding to positive sample pairs and negative sample pairs during model training. Optionally, positive example materials can be materials with an implied relationship to the original materials, such as implied sentences; negative example materials can be materials with a contradictory relationship to the original materials, such as contradictory sentences.
[0111] Optionally, the relationship between the original material and the generated material is specifically characterized by similarity.
[0112] Specifically, determining the relationship between the original material and each generated material based on the second model includes: determining the first similarity between the original material and the positive example material, and the second similarity between the original material and the negative example material based on the second model.
[0113] Correspondingly, if both the first similarity and the second similarity meet the corresponding requirements, then it can be considered that the relationship between the original material and each generated material matches the corresponding target relationship, and the material pair consisting of the original material and each generated material can be added to the target material library.
[0114] Optionally, based on the above conditions, further comparison and verification of the relationships corresponding to different generated materials can be added. Specifically, if the relationships between the original materials and each generated material match the corresponding target relationships, then the original materials and each generated material are determined to constitute material pairs with corresponding target relationships, and the material pairs are added to the target material library, which may include:
[0115] If the first similarity is greater than the positive example threshold, the second similarity is less than the negative example threshold, and the difference between the first similarity and the second similarity is greater than the difference threshold, then the positive example material, the negative example material, and the original material are added to the target material library together.
[0116] Optionally, the target material library can be used as a training sample set to train the base model. In the target material library, original materials and their corresponding positive examples constitute positive sample pairs, and original materials and their corresponding negative examples constitute negative sample pairs.
[0117] Taking sentences as source material and at least one target relation as implication and contradiction as an example, the first similarity between the original sentence and the implication sentence, and the second similarity between the original sentence and the contradiction sentence can be determined based on the second model. If both the first similarity and the second similarity meet the corresponding preset requirements, the implication sentence is added as a positive example of the original sentence and the contradiction sentence is added as a negative example of the original sentence, together with the original sentence, to the target source material library.
[0118] When training the model based on the target material library, positive examples and original sentences can form positive sample pairs, and negative examples and original sentences can form negative sample pairs.
[0119] Optionally, the preset requirements for implied sentences and contradictory sentences can be different. For example, the preset requirement for implied sentences can be a similarity greater than the positive example threshold, while the preset requirement for contradictory sentences can be a similarity less than the negative example threshold. The negative example threshold can be less than the positive example threshold.
[0120] Alternatively, you can set requirements for the similarity between each generated statement and the original statement to meet certain preset criteria, as well as for the similarity between the generated statements themselves. For example, if the first similarity is greater than or equal to the positive example threshold, the second similarity is less than or equal to the negative example threshold, and the difference between the first and second similarities is greater than or equal to the difference threshold, then both implied and contradictory statements can be added to the target material library; otherwise, they are discarded.
[0121] Specifically, the first similarity 'a' and the second similarity 'b' can be obtained using the following formula:
[0122]
[0123] Among them, C θThe large language model can be used as the second model, where d represents the verification prompt information, and x represents the large language model. s , These are the original source material, positive example material generated from the original source material, and negative example material generated from the original source material, respectively. d can indicate that a and b range from [0, 5], where a similarity of 5 means the two source materials are semantically identical, and 0 means the two source materials are completely different.
[0124] Based on this, the following formula can be used to determine which materials to add to the target material library:
[0125]
[0126] in, For the training sample set, α, β, and γ are the positive example threshold, negative example threshold, and difference threshold, respectively.
[0127] Figure 4 This is a schematic diagram illustrating a material filtering range provided in an embodiment of this application. For example... Figure 4 As shown, for each pair of generated materials, only when a is large enough, b is small enough, and ab exceeds a certain threshold will they be retained. That is, only the materials corresponding to the bolded line range will be added to the target material library.
[0128] According to the above scheme, in a pair of positive and negative examples generated from the original material, if the positive example is filtered out, the corresponding negative example is also filtered out; similarly, if the negative example is filtered out, the corresponding positive example is also filtered out. For example... Figure 2 In the illustrated scheme, contradictory sentences are invalid; therefore, both the contradictory sentence and the implied sentence generated using the same original sentence are filtered out. This is because if either one is invalid, it indicates that there may be problems with the model's understanding and generation of the original sentence. Filtering both simultaneously effectively reduces noise in the target material library and improves training accuracy. Furthermore, this method ensures that the data in the target material library has a uniform format, and each original material and its generated material can be utilized. The triples are stored to facilitate batch sampling and processing during subsequent training, thereby improving training efficiency and reducing the probability of errors.
[0129] Meanwhile, during filtering, not only are the thresholds corresponding to the positive and negative examples considered individually, but also the threshold corresponding to the difference between the two. This ensures that the similarity between the positive and negative examples and the original examples meets the requirements, while maximizing the similarity between the positive and negative examples. This gives the positive and negative examples more correct constraints, helping the model to accurately perceive the positions of the original, positive, and negative examples in the vector space and improving the accuracy of training.
[0130] In other alternative implementation methods, different preset requirements can be set to filter the generated materials. For example, setting separate requirements for positive and negative examples without considering the relationship between them can effectively improve the filtering efficiency. Alternatively, both positive and negative examples can be filtered out simultaneously, or only unqualified materials can be filtered out. If the corresponding qualified material is added to the target material library, it can be expanded to increase the number of samples.
[0131] In one example, when generating positive and negative examples based on the original material, the second model can obtain the first similarity between the original material and the positive example material, and the second similarity between the original material and the negative example material. If the first similarity between the original material and the positive example material is greater than the positive example threshold, the generated positive example material is qualified and can be added to the target material library as a positive sample pair; otherwise, the positive example material is discarded. If the second similarity between the original material and the negative example material is less than the negative example threshold, the generated negative example material is qualified and can be added to the target material library as a negative sample pair; otherwise, the negative example material is discarded.
[0132] In another example, when only positive examples are generated from the original material, or only negative examples are generated, the similarity of the generated positive or negative examples can be judged only in the manner described above, and it can be determined whether to add them to the target material library.
[0133] The data in the target material library can be stored in the manner of the triples described above (if there are no positive or negative examples, special characters are used instead), or positive and negative sample pairs can be stored separately. This embodiment does not impose any restrictions on this. The above operations can be performed on multiple original materials in the original material library to obtain a target material library containing multiple original materials and their corresponding generated materials.
[0134] Optionally, the target material library can be used not only as training samples but also in other scenarios. For example, the target material library can be made available to users, who can search for and use the materials they need during design, production, and other tasks, thus meeting their actual material needs, providing convenience, and improving user experience.
[0135] The method provided in this embodiment can utilize a first model to obtain generated material that has at least one target relationship with the original material. For any generated material, the relationship between the original material and the generated material is verified based on a second model to obtain material pairs that have been verified to meet the corresponding target relationship. This allows the model to generate a large number of materials, effectively improving the efficiency of material construction. Furthermore, the model's evaluation capability is used to screen the generated materials, improving the accuracy of the obtained material pairs, thereby improving the overall efficiency and accuracy of model training.
[0136] Based on the basic solution provided in the above embodiments, optionally, multiple reference information corresponding to multiple values can be displayed through an interactive interface; wherein, the reference information corresponding to any value includes at least two material examples, and the similarity between the at least two material examples is the value; at least one threshold input by the user through the interactive interface based on the reference information corresponding to the multiple values is obtained, and the at least one threshold includes at least one of: positive example threshold, negative example threshold, and difference threshold.
[0137] Figure 5 This is a schematic diagram of an interactive interface corresponding to the material construction stage provided in an embodiment of this application. For example... Figure 5 As shown, the interactive interface allows users to input one or more thresholds, such as α, β, and γ mentioned above. For example, the user could be prompted with "Please enter the positive example threshold. If the similarity between the generated implied sentence and the original sentence is less than this positive example threshold, it will be discarded."
[0138] To better assist users in configuration, reference information can also be displayed. This reference information may include multiple selectable values for similarity, and for each value, a corresponding example can be shown. For example, the multiple values may include 1, 2, 3, and 4, and the user can be shown two example statements corresponding to values 1, 2, 3, and 4 respectively. A value of 1 indicates that the similarity between these two example statements is 1.
[0139] In this way, the interactive interface can display material examples corresponding to each similarity value to the user, so that the user can understand the specific degree of similarity corresponding to different similarity values. This makes it easier for the user to configure the threshold required for the scenario based on the reference information, improve the user experience, and meet the usage needs in different scenarios.
[0140] In one or more embodiments of this application, optionally, interaction with the user can also be achieved through at least one of the following interactive methods.
[0141] In one optional interaction method, reference information corresponding to multiple candidate target relationships can be displayed through an interactive interface; wherein, the reference information corresponding to any target relationship includes at least two material examples, and the relationship between the at least two material examples is the target relationship; and the at least one target relationship input by the user through the interactive interface based on the reference information is obtained.
[0142] For example, multiple candidate target relations may include implication, contradiction, and neutrality. These target relations are presented on the interactive interface, along with reference information corresponding to each target relation. For instance, the reference information for implication is: "The relationship between the following two statements is implication: Statement 1; Statement 2". Alternatively, multiple candidate target relations may be multiple different similarities or other relations, which are not limited in this application.
[0143] Users can select which target relations they want to generate statements through the interactive interface. For example, if a user selects implication and contradiction, the first model can generate statements corresponding to implication and contradiction.
[0144] In this way, users can understand the meaning of each target relationship based on the reference information, and select the target relationship they want through the interactive interface. This allows users to selectively choose the target relationship between the original material and the generated material, meeting the usage needs of different scenarios.
[0145] In one optional interaction method, the original materials and corresponding generated materials are displayed through an interactive interface, so that the user can confirm, modify or filter the original materials or the corresponding generated materials, so as to obtain material pairs that are verified to meet the corresponding target relationship based on the materials confirmed, modified or filtered by the user.
[0146] Optionally, the generated assets displayed can be those obtained from the first model. After the first model obtains the generated assets, the original assets and generated assets can be displayed to the user, who can then confirm and modify them to obtain the desired original assets and generated assets. Optionally, multiple original assets and their corresponding generated assets can also be displayed to the user, allowing the user to easily filter out the desired original assets and generated assets.
[0147] After the user confirms, modifies, and filters, the next step can be performed based on the original and generated materials desired by the user. That is, the second model verifies the relationship between the original and generated materials, thereby obtaining material pairs that have been verified to meet the corresponding target relationship.
[0148] In one optional interaction method, material pairs that conform to the target relationship as verified by the second model are displayed through an interactive interface, so that the user can confirm, modify or filter the material pairs, and add the material pairs confirmed, modified or filtered by the user to the target material library;
[0149] Optionally, after the second model verifies the relationship between the original and generated materials, the material pairs can be displayed to the user, who can then confirm, modify, or filter them. After the user confirms, modifies, or filters them, the material pairs can be added to the target material library.
[0150] In this way, users can process the materials generated by the first model and / or the materials verified by the second model, making it convenient for users to follow up and adjust the materials obtained at each stage of the material construction process, so that the final materials are more in line with the user's needs.
[0151] In one optional interaction method, the user interface displays material pairs that conform to the target relationship as verified by the second model or material pairs from the target material library, allowing the user to select material pairs for fine-tuning training; in response to the fine-tuning command input by the user, the pre-trained base model is fine-tuned based on the material pairs selected by the user.
[0152] Optionally, the interactive interface can also include a button for starting fine-tuning training. Users can input fine-tuning commands by clicking the button. Users can first select the material pairs to be fine-tuned on the interactive interface, and then start fine-tuning training by inputting fine-tuning commands.
[0153] In addition, other functions can be set on the interactive interface. For example, at least one selectable model can be shown to the user, from which the user can select one as the base model for fine-tuning and training.
[0154] Through the above interactive methods, users can promptly understand the intermediate results at each stage of the material construction process, as well as the final target material library. This allows users to promptly confirm or adjust the intermediate results or the final material library, making the constructed material library more in line with the user's needs. Furthermore, users can select or modify various aspects of fine-tuning through the interactive interface to meet the fine-tuning needs in different scenarios, further enhancing the user experience.
[0155] Based on the technical solutions provided in the above embodiments, this application also provides a model training method. Figure 6 This is a flowchart illustrating a model training method provided in an embodiment of this application. Figure 6 As shown, the method includes:
[0156] Step 601: Obtain the training sample set.
[0157] The training samples in the training sample set include material pairs obtained based on the method described in any of the foregoing embodiments.
[0158] Step 602: Train the base model based on the training sample set.
[0159] Optionally, the base model can be a pre-trained model. Step 602 can be used to fine-tune the base model.
[0160] Optionally, training the base model based on the training sample set may include: if the training sample set contains positive and negative examples corresponding to the original material, then the base model is trained by comparative learning based on the training sample set.
[0161] Optionally, the original material and its corresponding positive example material can be used as a positive sample pair, the original material and its corresponding negative example material can be used as a negative sample pair, and the original material and the positive or negative example material corresponding to other original materials can also be used as a negative sample pair.
[0162] For example, the training sample set may include triples. These represent the original data, the corresponding positive example data, and the corresponding negative example data, respectively. It can be used as a positive sample pair. These can be used as negative sample pairs. Additionally, the original material x... s The generated material corresponding to any other original material (positive example material) and negative example material ) can also form negative sample pairs, for example, and All samples are negative pairs (when s ≠ k). During training, the loss function can be expressed as:
[0163]
[0164] Where N is the quantity of raw materials in a batch, h s , x s and eigenvectors, and They are respectively and The eigenvectors are sim(), which is used to represent the similarity between the two eigenvectors within the parentheses, and ι is the temperature coefficient.
[0165] By using the loss function described above, the feature vectors of the materials in positive sample pairs can be brought closer together, while the feature vectors of the materials in negative sample pairs can be pushed further apart, thus enabling the trained model to accurately extract the feature vectors of the materials to be processed.
[0166] Optionally, different weights can be assigned to different sample pairs. Specifically, during contrastive learning, any original target material and its corresponding positive example material constitute a positive sample pair; the original target material and its corresponding negative example material constitute a first-class negative sample pair; and the original target material and the positive or negative examples corresponding to other original materials constitute a second-class negative sample pair. The total loss value of the model training is calculated from the loss values of each positive sample pair and each negative sample pair, where the weight of the loss value of the first-class negative sample pair is greater than the weight of the loss value of the second-class negative sample pair.
[0167] Using the previous example, It can be used as a type I negative sample pair. and These can be used as second-type negative sample pairs. The weight of first-type negative sample pairs can be greater than the weight of second-type negative sample pairs because, given the original material x... s Generated negative example material and x s It has a strong contradictory relationship, while other original materials are positive examples. Or negative example material With x s The contradictory relationship is usually not as good as Therefore, increasing the weight of the negative examples generated by the training itself can better represent the actual spatial location of each example and improve the accuracy of training.
[0168] By assigning different weights to the first and second negative sample pairs, the summation operation in the denominator of the above formula can be replaced with a weighted summation operation to obtain the total loss value.
[0169] In practical applications, the sample pairs constructed using the above method may contain invalid negative sample pairs. This is because a certain original material may be semantically similar to the positive and negative examples of other original materials, but they are combined into a negative sample pair. To eliminate the harm caused by invalid negative sample pairs, materials with similar meanings can be masked.
[0170] The following example uses sentences as source material, with positive and negative examples representing implied and contradictory sentences, respectively. It combines the training sample construction stage and the model training stage to explain why unqualified negative sample pairs appear and provides specific solutions.
[0171] Figure 7This is a schematic diagram illustrating the principle of a model training method provided in an embodiment of this application. Figure 7 As shown, in order to train the base model, three stages can be set up, where stages one and two are used to build training samples, and stage three is used to implement fine-tuning training.
[0172] The original material library contains multiple original statements. In Phase 1, the first model can generate corresponding implied and contradictory statements based on each original statement.
[0173] For example, the first original statement is: "two menstanding outside wearing jackets and caps", the implied statement obtained by the first model is: "two dressed men are standing outside", and the paradoxical statement is: "two men are driving outdoor".
[0174] The second original statement is: "Four children are standing to pose for a photo." The implied statement obtained through the first model is: "Four children are posing for a photo." The paradoxical statement is: "Four women are standing for a photo."
[0175] The third original sentence is: "Two mendressed jackets and caps are standing on a terrace." The implied sentence obtained through the first model is: "Two men in jackets are outside." The paradoxical sentence is: "A child in shorts is outside."
[0176] The fourth original sentence is: "A group of four kids stand in front of a statue of a large animal." The implied sentence obtained through the first model is: "The kids are playing with a large animal." The contradictory sentence is: "The kids are sitting on a large animal."
[0177] In Phase Two, the semantic awareness capabilities of the second model can be utilized as a filter to assess the semantic similarity between the generated sentences and the original sentences, filtering out "low-quality" sentence pairs. For example, the fourth implied sentence generated in Phase One, "The children are playing with a large animal," is an inadequate implied sentence; therefore, both this implied sentence and its corresponding contradictory sentence will be filtered out. Through this filtering, only three of the four sentence pairs generated in Phase One are used as model fine-tuning data for the next phase.
[0178] In stage three, the original statements and generated statements are paired to form positive and negative sample pairs. The diagram shows how the first original statement can be paired with the three retained pairs of generated statements. The generated statements enclosed in solid lines (i.e., the implied sentences generated from the first original statement) represent those used to form positive sample pairs with the first original statement; these can be labeled as positive examples. The generated statements enclosed in dashed lines represent those used to form negative sample pairs with the first original statement; these can be labeled as negative examples. The contradictory sentences derived from the first original statement have a strong contradictory relationship with the first original statement and are farther apart in the vector space; therefore, they can be considered first-type negative examples and used to form first-type negative sample pairs. The implied and contradictory sentences corresponding to the other original statements have a similarity to the first original statement that is between positive examples and first-type negative examples; these can be considered second-type negative examples and used to form second-type negative sample pairs. As mentioned earlier, the weight of the second-type negative sample pairs can be less than the weight of the first-type negative sample pairs.
[0179] In the second type of negative sample pairs, there may be unqualified negative sample pairs. As shown in the figure, the implied sentence corresponding to the third original sentence, "two men wearing jackets are outside," is similar to the first original sentence, "two men are standing outside, wearing jackets and hats." If the two are used as a negative sample pair, the model may learn incorrect information. Therefore, this negative sample pair can be masked during fine-tuning.
[0180] In practical applications, multiple original materials can be selected from the training sample set to obtain a batch sample set; wherein, the number of the multiple original materials is the number required for one training batch, and the batch sample set includes the selected multiple original materials and corresponding generated materials to form positive sample pairs and negative sample pairs; in the batch sample set, the second type of negative sample pairs that meet the preset conditions are masked, and the basic model is trained by contrastive learning based on the batch sample set obtained after the masking operation; wherein, the preset condition is: the similarity between the two materials in the negative sample pair is greater than a preset threshold.
[0181] For example, the training sample set constructed through Phase 1 and Phase 2 contains 10,000 original materials. During the fine-tuning training process, 100 original materials and their corresponding generated materials can be randomly selected from the training sample set in each batch to adjust the parameters of the basic model. In this way, it is only necessary to calculate whether the similarity between the 100 original materials and their corresponding generated materials is greater than a preset threshold, without having to consider the remaining 9,900 original materials, which effectively reduces the amount of computation and improves the overall training efficiency of the model.
[0182] Optionally, the basic model can be trained based on the batch sample set obtained after the masking operation, which can be implemented in several ways.
[0183] In one alternative implementation, only the unmasked sample pairs can be input into the base model to obtain the corresponding output, and the total loss value can be calculated based on the output. The parameters of the base model can then be updated based on the total loss value.
[0184] In another alternative implementation, all sample pairs in the batch sample set can be input into the base model; however, the loss values of the masked sample pairs can be ignored when calculating the total loss value.
[0185] Optionally, in the batch sample set, second-type negative sample pairs that meet preset conditions are masked, including:
[0186] The feature vectors corresponding to each material in the batch sample set are extracted using the third model;
[0187] Traverse the second type of negative sample pairs corresponding to the batch sample set. For any negative sample pair traversed, if the similarity between the feature vector of the original material contained in the negative sample pair and the feature vector of the generated material is greater than a preset threshold, then mask the negative sample pair so that the masked negative sample pair is ignored when calculating the total loss value.
[0188] The third model is trained in an unsupervised manner using the dataset. During the unsupervised training process, any material in the dataset forms a positive sample pair with itself and a negative sample pair with other materials in the dataset.
[0189] Specifically, a third model can be used to extract feature vectors from each original and generated material in the batch sample set. Based on the feature vectors, the original and generated materials with high similarity can be masked so that masked negative sample pairs can be ignored during fine-tuning training.
[0190] Optionally, an indicator can be used to indicate the mask. For example, and The indicator can be calculated as follows:
[0191]
[0192] Where, sim η () indicates the similarity between the two feature vectors within the parentheses, determined by the third model. The value is or σ is a preset threshold. Thus, negative sample pairs with high semantic similarity are considered invalid and will be filtered out during training. Correspondingly, the following loss function can be used to fine-tune the base model:
[0193]
[0194] Where, the range of values for y is... It includes both + and - cases.
[0195] For example, such as Figure 7 As shown in the lower right corner, original statements selected from the original material library and generated statements selected from the generated material library form a second type of negative sample pair, which is then input into the third model. For any original and generated statement in a negative sample pair, the third model can extract the feature vectors of the original and generated statements. Based on the feature vectors, the similarity between the two can be determined. If the similarity is greater than a preset threshold, the corresponding indicator is represented by the number 0; if the similarity is less than the preset threshold, the corresponding indicator is represented by the number 1 (the indicator for positive sample pairs and first type of negative sample pairs can be set to 1 by default). In this way, by processing multiple original and generated statements separately, a matrix composed of 0s and 1s can be obtained. Each row in the matrix corresponds to an original statement. Based on the number in that row, the masked negative sample pair can be determined, thus ignoring the negative sample pair during fine-tuning.
[0196] Specifically, during fine-tuning, the original and generated statements can be input into the base model, denoted by E in the diagram. For example, the first original statement is input into the base model, and the resulting feature vector is compared with the feature vectors obtained from inputting multiple generated statements into the base model. The parameters of the base model are then updated based on the comparison results. Since the similarity between the implied sentences corresponding to the first and third original statements is greater than a preset threshold, the indicator for the negative sample pair formed by them is 0, and this negative sample pair is ignored when calculating the total loss.
[0197] The above methods can mask negative sample pairs with high similarity, reducing the likelihood of the base model learning incorrect knowledge and improving the accuracy of model training. Furthermore, masking a batch of negative sample pairs during actual fine-tuning training, rather than masking during the construction of training samples, effectively reduces the workload of masking and improves the efficiency of fine-tuning training. In addition, using indicators for masking allows for quick and accurate labeling of negative sample pairs that need to be masked, which can then be applied to the loss function, further improving the overall efficiency and accuracy of training.
[0198] Alternatively, other methods can be used to mask negative sample pairs, such as directly deleting the relevant negative sample pairs.
[0199] Furthermore, the third model is trained in an unsupervised manner and possesses preliminary similarity discrimination capabilities. Utilizing this third model, the base model can be trained in a supervised manner, reducing the overall required labeled data and training time. Alternatively, the third model can be trained in a supervised manner using a small amount of labeled data.
[0200] In one or more embodiments of this application, optionally, the generated material corresponding to the original material in the training sample set further includes: neutral material, wherein the neutral material is material that has a neutral relationship with the original material. For example, when the original material is an original statement, the corresponding neutral material is a neutral sentence.
[0201] Any original data and its corresponding neutral data constitute a third type of negative sample pair. During contrastive learning, the weight of the loss value of the third type of negative sample pair is less than the weight of the loss value of the first type of negative sample pair. The relative order of the weights of the third type of negative sample pair and the weights of the second type of negative sample pair is not restricted.
[0202] By adding neutral materials, the number of sample pairs can be effectively expanded, increasing the sample size. Optionally, any original material can also form a third type of negative sample pair with neutral materials corresponding to other original materials, thereby expanding the number of negative sample pairs.
[0203] The above describes the handling schemes when the target relationship between the original and generated materials in the training sample set is implied, contradictory, or neutral. In other optional implementation schemes, the target relationship between the original and generated materials in the training sample set can be a preset similarity. Based on the preset similarity, the label of the sample pair composed of the original and generated materials can be determined. For example, when the label is 5, the sample pair is a positive sample pair; when the label is 0, the sample pair is a negative sample pair; or, when the label is 0, it can be a first type of negative sample pair, and when the label is 2.5, it can be a second type of negative sample pair. Subsequent processing schemes can refer to the foregoing embodiments.
[0204] In one or more embodiments of this application, optionally, during the model training phase, users can also configure the training process through an interactive interface.
[0205] Specifically, the reference information corresponding to the training process can be displayed to the user through an interactive interface; wherein, the reference information includes: multiple candidate preset thresholds and material examples corresponding to each candidate preset threshold, and / or, the reference information includes: the types of negative sample pairs that can be selected;
[0206] Obtain at least one of the following inputs by the user on the interactive interface based on the reference information: the preset threshold; the type of negative sample pairs used in the training process; and the weights of the loss values for each type of negative sample pair.
[0207] For example, when the candidate preset thresholds include 3 and 4, the reference information could be: "Please enter the preset threshold used when applying the similarity mask. The following information is available for reference: The similarity between sentence 1 and sentence 2 is 4. If the preset threshold is set to 4, the negative sample pairs formed by sentence 1 and sentence 2, as well as negative sample pairs with higher similarity, will be masked; the similarity between sentence 3 and sentence 4 is 3. If the preset threshold is set to 3, the negative sample pairs formed by sentence 3 and sentence 4, as well as negative sample pairs with higher similarity, will be masked." Users can choose the preset threshold actually used during the training phase from the candidate preset thresholds, or they can choose from outside the candidate preset thresholds; there is no restriction here.
[0208] For details on how to display reference information and allow users to input preset thresholds through an interactive interface, please refer to the interactive interface mentioned in the previous training sample construction phase.
[0209] Allows users to select the type and weight of negative sample pairs; see reference. Figure 8 . Figure 8 This is a schematic diagram of an interactive interface corresponding to the model training phase provided in an embodiment of this application. For example... Figure 8As shown, the interactive interface displays the available types of negative sample pairs, which can correspond to the first type of negative sample pair, the second type of negative sample pair, etc., mentioned above. When the user selects only negative sample pairs consisting of the original statement and its corresponding contradictory statement, the original statement and the implied or contradictory statements corresponding to other original statements are no longer used as negative sample pairs for training, in order to strive for the best training effect within a limited time.
[0210] In addition to the negative sample pair types shown in the above schemes, other negative sample pair types can be added. For example, a negative sample pair consisting of one original data and another original data can be selected as a new type of negative sample pair. However, in some cases, adding new negative sample pairs will increase training time without significantly improving model performance. Therefore, whether to apply this new type of negative sample pair to the training process can also be chosen by the user.
[0211] In addition to selecting the type of negative sample pair, users can also set weights for various types of negative sample pairs. For example, the weight of a negative sample pair consisting of the original material and its corresponding contradictory material can be adjusted to be higher, while the weight of a negative sample pair consisting of the original material and other original materials' corresponding positive or negative examples can be adjusted to be lower, so as to further weaken the contribution of the latter in the training process and meet the usage needs in different scenarios.
[0212] In this embodiment of the application, by providing users with various interactive interfaces, users can configure the relevant functions used in the training process, which can meet various actual needs of users, improve the overall efficiency and accuracy of the system in specific scenarios, and has strong flexibility and applicability.
[0213] In addition to the above functions, it also allows users to adjust the model's training strategy through an interactive interface, including but not limited to: model input, model output, model structure, and model training process.
[0214] For example, regarding model input, users can adjust the input format and modality, and add, modify, or filter materials in the training sample set. Regarding model output, users can adjust the output format and modality, and modify or filter labels. Regarding model structure, users can adjust the specific structure and number of parameters of the model, and add, remove, or modify one or more modules in the model. Regarding the model training process, users can plan the training stages of the model, select the training dataset and input / output strategies used in each stage, the loss function, and the stopping conditions for training.
[0215] Optionally, the interface can also display relevant information to assist users in making choices, such as the available options or detailed information about each option. Furthermore, it can show users various dynamic information during model training, such as intermediate training results, to facilitate timely strategy updates.
[0216] In addition to comparative learning, the scheme in this application embodiment can also be applied to other types of learning and training, such as classification training.
[0217] For example, sample pairs can be constructed, each containing two data points and corresponding labels, which can be implication, contradiction, or neutral. Specifically, the sample pair consisting of the original data point and its corresponding positive example data point is labeled as implication; the sample pair consisting of the original data point and its corresponding negative example data point is labeled as contradiction; and the sample pair consisting of the original data point and other original data points' corresponding positive or negative examples can be labeled as neutral. Based on the constructed sample pairs, classification training can be performed. After classification training is completed, the basic model also possesses a certain ability to extract feature vectors, which can be used for subsequent applications.
[0218] The above scheme utilizes the generation and evaluation capabilities of the first and second models to obtain a highly accurate training sample set without any manual data annotation. Based on this, fine-tuning of the base model yields a well-trained feature extraction model. The test results of the scheme provided in this application's embodiments are described below.
[0219] refer to Figure 7 The experimental results obtained on the standard text semantic similarity calculation test for the scheme shown are as shown in Table 1, when the material is a sentence and a three-stage processing flow is used.
[0220] Table 1
[0221]
[0222] In Table 1, TST12 to SICK-R represent different test sets. The upper part of Table 1 shows the experimental results of BERT-base, and the lower part shows the experimental results of roBERTa-base. That is, it represents the experimental results when the base model is BERT or roBERTa.
[0223] The first column of Table 1 lists the different training methods. In the experimental results of BERT-based, the results are divided into three columns from top to bottom by horizontal lines. The first column shows the existing methods, and the second and third columns show the methods adopted in this application. The parentheses after Qurs indicate the third model used in stage three. -W and -N represent the original source libraries used. The statements with -W are generally longer and provide detailed information about a specific topic, while the statements with -N are relatively shorter and are usually brief statements expressing the relationship between two entities or concepts.
[0224] In this embodiment, the generated implied sentences are used as positive examples, and contradictory sentences are used as negative examples. Since the generated sentences and the original sentences usually do not maintain the same length or even grammatical structure, fine-tuning the model based on the generated training sample set can effectively avoid the sampling bias problem mentioned above. Based on the experimental results in Table 1, the following conclusions can be drawn:
[0225] (1) When using only the original source library -W as the source of the original statements, the method of this application is significantly better than SimCSE-BERT and PromptBERT. When compared with SimCSE-RoBERT and PromptRoBERT, the method of this application is further improved, increasing the average Spearman correlation coefficient from 76.57% and 79.15% to 80.05% and 80.34%, respectively.
[0226] (2) When using the original source library-N as the source of the original sentences, a greater performance improvement can be observed compared to using the original source library-W alone. This may be because the sentences in the original source library-W are longer and more detailed, requiring a stronger language understanding ability to obtain the corresponding implied or contradictory sentences. The training sample set constructed by combining these two original source libraries enables the trained model to achieve better performance. The experimental results in this part demonstrate that the method of this application can be consistently applied to data in different domains, expanding the applicable data scenarios.
[0227] (3) The method of this application can achieve certain performance improvements when implemented based on SimCSE and PromptBERT models, which shows that the method of this application has strong generalization ability and can be applied to various scenarios and achieve ideal improvements.
[0228] In other alternative implementation schemes, improvements to only one or two of the three stages mentioned above can be retained. It is understandable that improvements to one or two stages may not be as effective as improvements to all three stages; however, in some cases, they may still be effective compared to existing solutions, and therefore can be used selectively.
[0229] For example, when the improvements in stage three are removed, the basic model is fine-tuned directly based on the training sample set constructed in stages one and two. Although the effect is lower than that in Table 1, it is still much better than the existing solutions.
[0230] Table 2
[0231]
[0232] Table 2 presents the ablation experiment results of the method used in this application. The results without semantic-aware filter, without omask indicator, and without generated corpus are the results after removing stages two and three, and stages one and two, respectively. SimCSERoBERTa is the base model, i.e., the results after removing stages one, two, and three. As can be seen from Table 2, improvements at each stage are crucial for achieving better results.
[0233] In addition, relevant tests were conducted on the evaluation capabilities of the model used in Phase 2, and the results are shown in Table 3.
[0234] Table 3
[0235]
[0236] In Table 3, Flan-T5-XL is the large language model that can be used in Stage 2. Table 3 shows that directly using a large language model to evaluate semantic similarity is unlikely to yield ideal results. However, the method provided in this application can leverage the evaluation capabilities offered by large language models to enhance the quality of the constructed training sample set, achieving a performance of 80.34%. This demonstrates that in today's era of large language models, the method provided in this application represents a reasonable application that does not overly rely on large language models.
[0237] The above uses the example of source material to illustrate the solution of this application in detail. Optionally, the source material may also include other modalities. The first model and the second model can be models with multimodal processing capabilities, such as generating images from images or converting images into text. Based on this, the multimodal processing capabilities of the models can be directly utilized to construct a training sample set.
[0238] Alternatively, if the first and second models themselves do not have multimodal processing capabilities, they can be trained with a small amount of labeled data to enable multimodal processing. Alternatively, a smaller model can be used to convert content from other modalities into text, and then a training sample set can be constructed using the first and second models, which have text processing capabilities.
[0239] Based on the model training methods provided in the above embodiments, this application further provides methods for applying the model and methods for training downstream tasks using the model. These will be described below.
[0240] On one hand, this application provides a feature extraction method, including: acquiring target information to be processed, inputting the target information into a feature extraction model, and obtaining a feature vector corresponding to the target information; wherein the feature extraction model is obtained by training a basic model using the method described in any of the foregoing embodiments.
[0241] Optionally, the target information can be a statement, or other types of text or other modal information. After the feature vector is extracted, subsequent tasks can be performed based on the feature vector, such as searching by the similarity of the feature vectors, or connecting to a classifier to complete the classification operation.
[0242] On the other hand, this application also provides a search processing method applied to e-commerce search scenarios. The method includes: obtaining search information corresponding to a user; inputting the search information into a feature extraction model to obtain a feature vector corresponding to the target information; searching in a product information database to obtain at least one product information, wherein the at least one product information is: product information whose feature vector and the feature vector of the search information have a similarity that meets a preset requirement; and determining the output search result based on the at least one product information found. The feature extraction model is obtained by training a basic model using the method described in any of the foregoing embodiments.
[0243] For details on the implementation process of the search processing method, please refer to [link / reference needed]. Figure 1 The implementation scheme shown.
[0244] On the other hand, this application also provides an information processing method applied to an intelligent customer service scenario. The method includes: acquiring query information to be processed; wherein the query information to be processed can be user input; searching for at least one piece of knowledge in a knowledge base based on a target model, wherein the at least one piece of knowledge is knowledge that has a target relationship with the query information; determining the output query result based on the at least one piece of knowledge found; wherein the target model is obtained by training a basic model using the method described in any of the foregoing embodiments.
[0245] Optionally, the target model can be a feature extraction model. Based on the target model, at least one piece of knowledge is searched in the knowledge base. This can include: inputting the query information into the feature extraction model to obtain the feature vector corresponding to the query information; and searching in the knowledge base to obtain at least one piece of knowledge, wherein the at least one piece of knowledge is knowledge whose similarity to the feature vector of the query information meets a preset requirement.
[0246] Optionally, the target model can also be a judgment model obtained through training, which can directly determine whether two input information have a target relationship. The query information and any knowledge in the knowledge base can be used as two input information to input into the judgment model to obtain the relationship between the query information and the knowledge.
[0247] Optionally, the specific implementation principle and process of the query processing method are similar to those of the aforementioned search processing method, and will not be repeated here.
[0248] Furthermore, embodiments of this application also provide model training methods applicable to enterprise office scenarios, such as translation, classification, and text-to-SQL conversion. These will be described below.
[0249] On the one hand, embodiments of this application also provide a training method for downstream tasks, applicable to any task processing scenario, such as a classification task. The method includes: acquiring sample information to be processed; inputting the sample information into a feature extraction model to obtain a feature vector corresponding to the sample information; inputting the feature vector into a task processing module; and updating the parameters of the task processing module according to the output information of the task processing module and the label corresponding to the sample information; wherein the feature extraction model is obtained by training a basic model using the method described in any of the above embodiments.
[0250] Optionally, the task processing module can be, for example, a classifier. During the training process of downstream tasks, the parameters of the feature extraction model can be fixed, and the parameters of the classifier can be adjusted to obtain a trained classifier that can be applied to subsequent classification tasks.
[0251] On the other hand, embodiments of this application also provide a training method for a downstream task, applied to a natural language scenario. The method includes: acquiring multilingual training sample pairs, the training sample pairs including: text corresponding to a first language, and text in a second language translated from the text in the first language; inputting the text in the first language into a feature extraction model of the first language to obtain a first feature vector; inputting the text in the second language into a feature extraction model of the second language to obtain a second feature vector; updating the parameters of the feature extraction model of the second language according to the similarity between the first feature vector and the second feature vector; wherein, the feature extraction model of the first language is obtained by training a basic model using the method described in any of the above embodiments.
[0252] Optionally, a base model can be trained using the training sample set of the first language to obtain a feature extraction model for the first language. Then, the parameters of the feature extraction model for the first language can be fixed to train a feature extraction model for the second language.
[0253] For example, the first language is English and the second language is a less commonly spoken language. Since it is difficult to obtain samples for the feature extraction model of the less commonly spoken language, the feature extraction model of English, as well as the sample pairs of English and the less commonly spoken language, can be used to realize the transfer of the feature extraction model from English to the less commonly spoken language.
[0254] In addition to achieving transfer between different languages, domain transfer can also be achieved by training on different domains sequentially. For example, the model can be trained by first constructing training samples using the -W original resource library, and then the domain transfer of the model can be achieved by using training samples constructed based on the -N original resource library.
[0255] Using the methods described above, the model trained in the embodiments of this application can be applied in scenarios such as product recommendation, intelligent customer service robots, classification tasks, and feature extraction of minority languages. In the product recommendation scenario, the model can be specifically used to extract semantic representations of text data such as product descriptions, reviews, and user history records in the product recommendation system, thereby achieving more accurate and personalized product recommendations. In the intelligent customer service scenario, it can also improve the understanding ability and accuracy of automatic replies of customer service robots. It also performs better in other tasks and can meet the usage needs of different scenarios.
[0256] The methods provided in the embodiments of this application can be executed in the cloud, on a terminal, or both. Furthermore, the above methods can also be implemented through a distributed cluster; this application does not limit this approach.
[0257] Corresponding to the above method, in one aspect, this application embodiment also provides a material construction apparatus, including: an acquisition module, used to acquire original materials and at least one generated material corresponding to a target relationship, wherein the generated material corresponding to any target relationship is a material generated by a first model that has the target relationship with the original materials; and a verification module, used to verify the relationship between the original materials and the generated materials based on a second model for any generated material, to obtain a material pair that has been verified to conform to the corresponding target relationship, wherein the material pair includes the original materials and the generated materials.
[0258] On the other hand, embodiments of this application also provide a model training apparatus, including: an acquisition module for acquiring a training sample set, wherein the training samples in the training sample set include material pairs obtained based on the method described in any of the foregoing embodiments; and a training module for training a base model based on the training sample set.
[0259] On the other hand, this application embodiment also provides a feature extraction device, including: an acquisition module, used to acquire target information to be processed, input the target information into a feature extraction model, and obtain a feature vector corresponding to the target information; wherein, the feature extraction model is a material pair obtained by the material generation method described in any of the foregoing embodiments, or obtained by training a basic model by the model training method described in any of the foregoing embodiments.
[0260] On the other hand, embodiments of this application also provide an information processing apparatus, including: an acquisition module for acquiring query information to be processed; a search module for searching for at least one piece of knowledge in a knowledge base based on a target model, wherein the at least one piece of knowledge is knowledge that has a target relationship with the query information; and an output module for determining the output query result based on the at least one piece of knowledge found; wherein the target model is a material pair obtained by the material generation method described in any of the foregoing embodiments, or obtained by training a basic model by the model training method described in any of the foregoing embodiments.
[0261] The specific implementation principle and effects of the device provided in this application embodiment can be found in the foregoing embodiments, and will not be repeated here.
[0262] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 9 As shown, the electronic device in this embodiment may include:
[0263] At least one processor 901; and a memory 902 communicatively connected to the at least one processor; wherein the memory 902 stores instructions executable by the at least one processor 901 to cause the electronic device to perform the method as described in any of the above embodiments. Optionally, the memory 902 may be standalone or integrated with the processor 901.
[0264] The implementation principle and technical effects of the electronic device provided in this embodiment can be found in the foregoing embodiments, and will not be repeated here.
[0265] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the method described in any of the foregoing embodiments.
[0266] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the methods described in any of the foregoing embodiments.
[0267] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not executed.
[0268] The integrated modules implemented as software functional modules described above can be stored in a computer-readable storage medium. These software functional modules, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of this application.
[0269] It should be understood that the aforementioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor. The memory may include high-speed RAM, and may also include non-volatile memory (NVM), such as at least one disk storage device, and may also be a USB flash drive, external hard drive, read-only memory, disk, or optical disc, etc.
[0270] The aforementioned storage medium can be implemented from any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium can be any available medium accessible to general-purpose or special-purpose computers.
[0271] An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Alternatively, the storage medium can be an integral part of the processor. Both the processor and the storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and storage medium can exist as discrete components in an electronic device or host device.
[0272] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0273] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0274] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0275] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A method for generating materials, characterized in that, include: Obtain original materials and at least one generated material corresponding to a target relationship, wherein the generated material corresponding to any target relationship is a material generated by the first model that has the target relationship with the original materials; For any generated material, the relationship between the original material and the generated material is verified based on the second model to obtain a material pair that has been verified to meet the corresponding target relationship. The material pair includes the original material and the generated material. The material pairs are used as training sample sets for comparative learning training of the base model. The comparative learning training includes: selecting multiple original materials from the training sample set to obtain a batch sample set; wherein the number of original materials is the number required for one training batch; the batch sample set includes the selected original materials and the corresponding generated materials; in the batch sample set, second-type negative sample pairs that meet preset conditions are masked, and the base model is trained using comparative learning based on the batch sample set obtained after the masking operation; wherein the preset conditions are: the similarity between the two materials in a negative sample pair is greater than a preset threshold; the second-type negative sample pair is a negative sample pair consisting of positive or negative examples of the target original material and other original materials; and the first model and the second model are the same model.
2. The method according to claim 1, characterized in that, The step of obtaining the original material and the generated material corresponding to at least one target relationship includes: obtaining the original material from the original material library; inputting the original material and the generation prompt information corresponding to any target relationship into the first model to obtain the generated material corresponding to the target relationship; wherein, the generation prompt information is used to prompt the first model to generate material that has the target relationship with the original material; And / or, The step of verifying the relationship between the original material and the generated material based on the second model to obtain a material pair that has been verified to meet the corresponding target relationship includes: inputting the original material, the generated material, and verification prompt information into the second model to obtain the relationship between the original material and the generated material; if the obtained relationship matches the target relationship, then the original material and the generated material are determined to be a material pair that has been verified to meet the corresponding target relationship; wherein, the verification prompt information is used to instruct the second model to determine the relationship between the original material and the generated material from a preset relationship range, and to provide the meaning of at least two preset relationships in the preset relationship range as a reference.
3. The method according to claim 1, characterized in that, When there are multiple target relationships, for any generated material, the relationship between the original material and the generated material is verified based on the second model to obtain material pairs that have been verified to conform to the corresponding target relationships, including: The relationship between the original materials and the generated materials is determined based on the second model; If the relationship between the original material and each generated material matches the corresponding target relationship, then the original material and each generated material are determined to constitute a material pair with a corresponding target relationship, and the material pair is added to the target material library.
4. The method according to claim 3, characterized in that, The at least one target relationship includes positive example relationships and negative example relationships, and the corresponding generated materials are positive example materials and negative example materials, respectively; the relationship between the original materials and the generated materials determined by the second model is represented by similarity. The determination of the relationship between the original materials and each generated material based on the second model includes: The first similarity between the original material and the positive example material, and the second similarity between the original material and the negative example material are determined based on the second model. If the relationship between the original material and each generated material matches the corresponding target relationship, then the original material and each generated material are determined to constitute material pairs with corresponding target relationships, and the material pairs are added to the target material library, including: If the first similarity is greater than the positive example threshold, the second similarity is less than the negative example threshold, and the difference between the first similarity and the second similarity is greater than the difference threshold, then the positive example material, the negative example material, and the original material are added to the target material library together. In the target material library, the original material and the corresponding positive example material constitute a positive sample pair, and the original material and the corresponding negative example material constitute a negative sample pair.
5. The method according to claim 4, characterized in that, Also includes: The interactive interface displays reference information corresponding to multiple values; wherein, the reference information corresponding to any value includes at least two material examples, and the similarity between the at least two material examples is the value. The system obtains at least one threshold input by the user through an interactive interface based on reference information corresponding to the multiple values. The at least one threshold includes at least one of the following: positive example threshold, negative example threshold, and difference threshold.
6. The method according to any one of claims 1-5, characterized in that, The method further includes at least one of the following: The system displays reference information corresponding to multiple candidate target relationships through an interactive interface; wherein, the reference information corresponding to any target relationship includes at least two material examples, and the relationship between the at least two material examples is the target relationship; the system obtains at least one target relationship input by the user through the interactive interface based on the reference information; The original materials and corresponding generated materials are displayed through an interactive interface, allowing users to confirm, modify, or filter the original materials or corresponding generated materials. Based on the materials confirmed, modified, or filtered by the user, material pairs that have been verified to meet the corresponding target relationship are obtained. The interactive interface displays material pairs that conform to the target relationship as verified by the second model, allowing users to confirm, modify, or filter the material pairs, and then adding the confirmed, modified, or filtered material pairs to the target material library. The interactive interface displays material pairs that conform to the target relationship as verified by the second model or material pairs from the target material library, allowing users to select material pairs for fine-tuning training. In response to the fine-tuning instructions input by the user, the pre-trained base model is fine-tuned based on the material pairs selected by the user.
7. A model training method, characterized in that, include: Obtain a training sample set, wherein the training samples in the training sample set include material pairs obtained based on the method of any one of claims 1-6; The base model is trained based on the training sample set.
8. The method according to claim 7, characterized in that, Based on the training sample set, the base model is trained, including: If the training sample set contains positive and negative examples corresponding to the original material, then the basic model is trained by comparison learning based on the training sample set. In the comparative learning process, any target original material in the training sample set and its corresponding positive example material constitute a positive sample pair, the target original material and its corresponding negative example material constitute a first type of negative sample pair, and the target original material and the positive or negative example material corresponding to other original materials constitute a second type of negative sample pair. The total loss value of model training is calculated from the loss values of each positive sample pair and each negative sample pair, wherein the weight of the loss value of the first type of negative sample pair is greater than the weight of the loss value of the second type of negative sample pair.
9. The method according to claim 8, characterized in that, Based on the training sample set, the base model is trained through contrastive learning, including: Multiple original materials are selected from the training sample set to obtain a batch sample set; wherein, the number of the multiple original materials is the number required for one training batch, and the batch sample set includes the selected multiple original materials and the generated materials corresponding to each original material; In the batch sample set, the second type of negative sample pairs that meet the preset conditions are masked, and the basic model is trained by comparison learning based on the batch sample set obtained after the masking operation. The preset condition is that the similarity between the two materials in the negative sample pair is greater than a preset threshold.
10. The method according to claim 9, characterized in that, In the batch sample set, second-type negative sample pairs that meet preset conditions are masked, including: The feature vectors corresponding to each material in the batch sample set are extracted using the third model; Traverse the second type of negative sample pairs corresponding to the batch sample set. For any negative sample pair traversed, if the similarity between the feature vector of the original material contained in the negative sample pair and the feature vector of the generated material is greater than a preset threshold, then mask the negative sample pair so that the masked negative sample pair is ignored when calculating the total loss value. The third model is trained in an unsupervised manner using the dataset. During the unsupervised training process, any material in the dataset forms a positive sample pair with itself and a negative sample pair with other materials in the dataset.
11. The method according to claim 9 or 10, characterized in that, The method further includes: The training process is displayed to the user through an interactive interface; wherein, the reference information includes: multiple candidate preset thresholds and material examples corresponding to each candidate preset threshold, and / or, the reference information includes: the types of negative sample pairs available; Obtain at least one of the following inputs by the user on the interactive interface based on the reference information: the preset threshold; the type of negative sample pairs used in the training process; and the weights of the loss values for each type of negative sample pair.
12. A feature extraction method, characterized in that, include: Obtain the target information to be processed, input the target information into the feature extraction model, and obtain the feature vector corresponding to the target information; The feature extraction model is a pair of materials obtained by the method described in any one of claims 1-6, or obtained by training a base model by the method described in any one of claims 7-11.
13. An information processing method, characterized in that, The method includes: Retrieve query information to be processed; Based on the target model, at least one piece of knowledge is obtained by searching the knowledge base, wherein the at least one piece of knowledge is: knowledge that has a target relationship with the query information; Based on at least one piece of knowledge retrieved, determine the output query results; The target model is a pair of materials obtained by the method described in any one of claims 1-6, or obtained by training a base model by the method described in any one of claims 7-11.
14. An electronic device, characterized in that, include: At least one processor; as well as A memory that is communicatively connected to the at least one processor; The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, cause the electronic device to perform the method of any one of claims 1-13.