Big language model equipment relation extraction method based on two-way retrieval and context learning
By employing a dual-path retrieval and contextual learning approach, the problem of insufficient identification of overlapping relationships in the equipment domain is solved, achieving efficient equipment relationship extraction, which is applicable to scenarios such as equipment knowledge graphs and intelligent question answering.
Patent Information
- Application Number
- CN202511417770.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-30
- Publication Date
- 2026-03-03
Smart Images

Figure CN121598951A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of relation extraction technology in natural language processing, specifically to a relation extraction method based on a large language model equipped with dual-path retrieval and context learning. Background Technology
[0002] Relation extraction is one of the core tasks of natural language processing, aiming to identify semantic relationships between instances in unstructured text and transform scattered information into structured knowledge. In the field of equipment, relation extraction needs to uncover complex relationships such as weapon system affiliation, manufacturer-product associations, and equipment collaborative combat capabilities. This knowledge is crucial for domain expert decision-making and the construction of equipment knowledge graphs.
[0003] However, the text in the equipment domain has significant particularities and complexities, mainly reflected in: prominent relationship overlap, including single instance overlap and instance pair overlap; the text contains a large number of professional terms and complex technical descriptions, making it difficult for general semantic models to accurately capture domain semantics; insufficient generalization ability in low-sample scenarios, and the traditional pre-training-fine-tuning paradigm requires large-scale labeled data, while high-quality labeled data is scarce in the equipment domain.
[0004] Existing general relation extraction methods have obvious limitations: deep learning-based models are insufficient in identifying overlapping relations in the equipment domain, are prone to missing main instance extraction, and do not effectively utilize main instance features; while methods based on pre-trained large language models can capture contextual semantics, the pre-trained semantic space is adapted to general text, making it difficult to model semantic relations specific to the equipment domain, and performance is limited in scenarios with few samples.
[0005] Therefore, there is an urgent need for a relation extraction method that can accurately handle overlapping relationships in the equipment domain, adapt to domain semantic features, and has strong generalization ability with few samples, so as to meet the actual needs of knowledge mining in the equipment domain. Summary of the Invention
[0006] The purpose of this invention is to provide a method for extracting equipment relationships based on a large language model using dual-path retrieval and contextual learning, in order to solve the problems of insufficient identification of overlapping relationships in the equipment domain, easy loss of main instance extraction, and ineffective utilization of main instance features by the deep learning-based models proposed in the background art; although the method based on pre-trained large language models can capture contextual semantics, the pre-trained semantic space is adapted to general text, making it difficult to model semantic relationships specific to the equipment domain, and performance is limited in scenarios with few samples.
[0007] To achieve the above objectives, the present invention provides the following technical solution: a method for extracting equipment relations based on a large language model using dual-path retrieval and context learning, comprising the following steps:
[0008] S1: Embedding model fine-tuning: Based on the pre-trained BGE-M3 embedding model, a domain-specific corpus and optimization target are introduced to perform domain-specific fine-tuning to obtain an embedding model adapted to the equipment domain.
[0009] S2: Construction of the retrieval example library: Using the adapted embedding model obtained in step S1, sentence-level embedding vectors and relation-level embedding vectors of the example text are generated, and the large language model is guided to generate example inference logic in combination with the relation inference template to construct a retrieval example library containing example text, sentence-level embedding vectors, relation-level embedding vectors and inference logic.
[0010] S3: Dual-path retrieval and relevance ranking: For the input equipment domain text, the sentence-level embedding vector and relation-level embedding vector are generated by the adaptation embedding model obtained in step S1. Based on the two types of vectors, relevant examples are recalled from the retrieval example library. Then, the RRF algorithm is used to fuse and rank the two retrieval results to obtain a highly relevant example set.
[0011] S4: Prompt word construction and relation extraction: Based on the highly relevant example set obtained in step S3, construct prompt words containing task description, context learning examples and input text, input the prompt words into the large language model, and output the equipment relation extraction results.
[0012] Preferably, the "domain-specific fine-tuning" in step S1 specifically includes:
[0013] S11: Contrastive learning is used to optimize the BGE-M3 embedding model, with the InfoNCE loss function as the objective, to bring positive sample vectors closer and push negative sample vectors further apart. The InfoNCE loss function is:
[0014]
[0015] Where, x i To query samples, For x i Relevant positive samples, x i For x i Irrelevant negative samples, τ is the temperature hyperparameter, and sim(·) is the cosine similarity;
[0016] S12: A domain-specific adaptation layer is introduced at the top layer of the BGE-M3 embedding model. This adaptation layer is a lightweight fully connected network, and its calculation process is as follows:
[0017] h = ReLU(W) 1·e +b1),
[0018] o = W²·h + b²,
[0019] Where e is the embedding vector output by BGE-M3, W1 and W2 are weight matrices, b1 and b2 are bias terms, h is the hidden layer output, and o is the domain adaptation output;
[0020] S13: Freeze the underlying Transformer parameters of BGE-M3 during fine-tuning, and only update the domain adaptation layer parameters.
[0021] Preferably, step S2, "relation-level embedding vector generation," specifically includes:
[0022] S21: The BERT-based relation extraction fine-tuning method is used to extract the main instance (SUB) and guest instance (OBJ) from the example text;
[0023] S22: Using the adapted embedding model obtained in step S1, generate the embedding vector U of the main instance respectively. sub Embedding vector U of guest instance obj ;
[0024] S23: U sub with U ojb Concatenate along the dimensions to obtain the relation-level embedding vector U. r ,Right now:
[0025]
[0026] Preferably, step S2, "example reasoning logic generation," specifically includes:
[0027] S2a: For example:
[0028] example i =(text,entity1,rntity2,relation),
[0029] Generate query suggestions i "In the sentence 'context', what clues indicate that the relationship between 'entity_1' and 'entity_2' is 'relation'?"
[0030] S2b: Query i Input the GPT-3.5 model and generate inference logic. i ;
[0031] S2c: Building an Enhanced Example:
[0032] Enhanced Example i =(text,entity1,entity2,relation,Inference i ),
[0033] And store it in the retrieval example library.
[0034] Preferably, the "dual-path retrieval" in step S3 specifically includes:
[0035] S31: Sentence-level embedding retrieval: Calculate the sentence-level embedding vector u of the input text. s The sentence-level embedding vector u of all examples in the retrieval example library si The cosine similarity is used to recall the k most semantically relevant examples. The similarity calculation formula is:
[0036]
[0037] S32: Relational-level Embedding Retrieval: Calculate the relational-level embedding vector u of the input text. r The relational embedding vector u of all examples in the retrieval example library ri The cosine similarity is used to recall the k most relevant instances in the instance relationship. The similarity calculation formula is:
[0038]
[0039] Preferably, the calculation formula for "RRF algorithm fusion sorting" in step S3 is:
[0040]
[0041] Where d is an example in the search example library, r(d) is the rank of example d in the nth search path, N is the number of search paths (N=2), and k is a constant greater than 1.
[0042] Preferably, the template for "prompt word construction" in step S4 is:
[0043] Task Description: {A predefined set of relation categories R and a description of the relation extraction task. Output the relations belonging to R; if no relation matches, output NULL.}
[0044] Context learning example: {A set of highly relevant examples sorted by RRF, each example containing inference logic and labeled with its relevance ranking to the input text}
[0045] Input: {Equipment domain text to be extracted}
[0046] Output: {Relation extraction result placeholder}.
[0047] Preferably, the relationship types of the equipment domain text include seven categories: manufacturing unit, equipment facility, user unit, producing country or region, user country or region, predecessor, and successor; the overlapping relationship types of the equipment domain text include:
[0048] Normal type: Instances have only one relation;
[0049] SEO type: The same instance forms different relationships with multiple instances;
[0050] EPO type: The same instance pair has multiple relationships.
[0051] Preferably, the large language model is GPT-3.5, and its hyperparameters are set as follows: Temperature = 0.8, Top_p = 0.7, Presence_penalty = 1.0, and Response_format is "json_object".
[0052] Preferably, in step S1, the "equipment-specific corpus" is derived from text data related to aircraft, tanks, missiles, guns, and equipment in Wikipedia, Baidu Encyclopedia, and Firearms Encyclopedia; in step S2, the "example text" is derived from the retrieval example set divided from the equipment-domain relation extraction dataset, which is divided into a test set and a retrieval example set in an 8:2 ratio.
[0053] The technical effects and advantages of this invention are as follows:
[0054] 1. This large language model equipment relation extraction method based on dual-path retrieval and context learning captures global semantics and local instance relations simultaneously through dual-path retrieval. It can effectively identify three types of overlapping relations in the equipment domain: Normal, SEO, and EPO. The F1 score is significantly improved compared with the existing best baseline model GPT-RE.
[0055] 2. This method for extracting equipment relations based on dual-path retrieval and contextual learning, through the BGE-M3 model optimized by comparative learning and domain adaptation layer, can accurately capture the semantic information of professional terms and technical descriptions in the equipment field, and solve the problem of insufficient domain adaptation of general models.
[0056] 3. This equipment relation extraction method based on dual-path retrieval and context learning, using a large language model, does not require large-scale fine-tuning and can extract equipment domain relations with only a few high-quality examples, thus reducing data dependence.
[0057] 4. This method for extracting equipment relationships based on a large language model using dual-path retrieval and contextual learning can be directly applied to scenarios such as equipment knowledge graph construction and intelligent question answering, providing structured knowledge support for equipment research and development, maintenance, and decision support. Moreover, the experimental environment is easy to implement, facilitating engineering implementation. Attached Figure Description
[0058] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0059] Figure 1 This is a schematic diagram of the framework for extracting equipment relationships from a large language model based on dual-path retrieval and context learning, as presented in this invention.
[0060] Figure 2 This is an example diagram illustrating the data extraction of overlapping relationships in the equipment field according to the present invention.
[0061] Figure 3 This is a diagram of the adaptation layer module architecture in the field of this invention;
[0062] Figure 4 This is a diagram illustrating the reasoning logic generation process of this invention. Detailed Implementation
[0063] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0064] This invention discloses a method for extracting equipment relations from a large language model based on dual-path retrieval and context learning, according to the appendix. Figures 1-4 As shown, it includes the following steps:
[0065] S1: Embedding model fine-tuning: Based on the pre-trained BGE-M3 embedding model, a domain-specific corpus and optimization target are introduced to perform domain-specific fine-tuning to obtain an embedding model adapted to the equipment domain.
[0066] S2: Construction of the retrieval example library: Using the adapted embedding model obtained in step S1, sentence-level embedding vectors and relation-level embedding vectors of the example text are generated, and the large language model is guided to generate example inference logic in combination with the relation inference template to construct a retrieval example library containing example text, sentence-level embedding vectors, relation-level embedding vectors and inference logic.
[0067] S3: Dual-path retrieval and relevance ranking: For the input equipment domain text, the sentence-level embedding vector and relation-level embedding vector are generated by the adaptation embedding model obtained in step S1. Based on the two types of vectors, relevant examples are recalled from the retrieval example library. Then, the RRF algorithm is used to fuse and rank the two retrieval results to obtain a highly relevant example set.
[0068] S4: Prompt word construction and relation extraction: Based on the highly relevant example set obtained in step S3, construct prompt words containing task description, context learning examples and input text, input the prompt words into the large language model, and output the equipment relation extraction results.
[0069] According to the appendix Figure 1 -- Figure 4 As shown, further, the "domain-specific fine-tuning" in step S1 specifically includes:
[0070] S11: Contrastive learning is used to optimize the BGE-M3 embedding model, with the InfoNCE loss function as the objective, to bring positive sample vectors closer and push negative sample vectors further apart. The InfoNCE loss function is:
[0071]
[0072] Where, x i To query samples, For x i Relevant positive samples, x i For x i Irrelevant negative samples, τ is the temperature hyperparameter, and sim(·) is the cosine similarity;
[0073] S12: A domain-specific adaptation layer is introduced at the top layer of the BGE-M3 embedding model. This adaptation layer is a lightweight fully connected network, and its calculation process is as follows:
[0074] h = ReLU(W) 1·e +b1),
[0075] o = W²·h + b²,
[0076] Where e is the embedding vector output by BGE-M3, W1 and W2 are weight matrices, b1 and b2 are bias terms, h is the hidden layer output, and o is the domain adaptation output;
[0077] S13: Freeze the underlying Transformer parameters of BGE-M3 during fine-tuning, and only update the domain adaptation layer parameters.
[0078] According to the appendix Figures 1-4 As shown, further, step S2, "relation-level embedding vector generation," specifically includes:
[0079] S21: The BERT-based relation extraction fine-tuning method is used to extract the main instance (SUB) and guest instance (OBJ) from the example text;
[0080] S22: Using the adapted embedding model obtained in step S1, generate the embedding vector U of the main instance respectively. subEmbedding vector U of guest instance obj ;
[0081] S23: U sub with U ojb Concatenate along the dimensions to obtain the relation-level embedding vector U. r ,Right now:
[0082]
[0083] According to the appendix Figures 1-4 As shown, specifically disclosed, the "example reasoning logic generation" in step S2 includes:
[0084] S2a: For example:
[0085] example i =(text,entity1,rntity2,relation),
[0086] Generate query suggestions i "In the sentence 'context', what clues indicate that the relationship between 'entity_1' and 'entity_2' is 'relation'?"
[0087] S2b: Query i Input the GPT-3.5 model and generate inference logic. i ;
[0088] S2c: Building an Enhanced Example:
[0089] Enhanced Example i =(text,entity1,entity2,relation,Inference i ),
[0090] And store it in the retrieval example library.
[0091] According to the appendix Figures 1-4 As shown, specifically disclosed, the "dual-path retrieval" in step S3 includes:
[0092] S31: Sentence-level embedding retrieval: Calculate the sentence-level embedding vector u of the input text. s The sentence-level embedding vector u of all examples in the retrieval example library si The cosine similarity is used to recall the k most semantically relevant examples. The similarity calculation formula is:
[0093]
[0094] S32: Relational-level Embedding Retrieval: Calculate the relational-level embedding vector u of the input text. r The relational embedding vector u of all examples in the retrieval example library ri The cosine similarity is used to recall the k most relevant instances in the instance relationship. The similarity calculation formula is:
[0095]
[0096] According to the appendix Figures 1-4 As shown, it is particularly important to emphasize that the calculation formula for "RRF algorithm fusion sorting" in step S3 is as follows:
[0097]
[0098] Where d is an example in the search example library, r(d) is the rank of example d in the nth search path, N is the number of search paths (N=2), and k is a constant greater than 1.
[0099] The template for "prompt word construction" in step S4 is as follows:
[0100] Task Description: {A predefined set of relation categories R and a description of the relation extraction task. Output the relations belonging to R; if no relation matches, output NULL.}
[0101] Context learning example: {A set of highly relevant examples sorted by RRF, each example containing inference logic and labeled with its relevance ranking to the input text}
[0102] Input: {Equipment domain text to be extracted}
[0103] Output: {Relation extraction result placeholder}.
[0104] According to the appendix Figures 1-4 As shown, it is particularly important to emphasize that the relationship types of the equipment-related texts include seven categories: manufacturing unit, equipment facility, user unit, country or region of production, country or region of use, predecessor, and successor; the overlapping relationship types of the equipment-related texts include:
[0105] Normal type: Instances have only one relation;
[0106] SEO type: The same instance forms different relationships with multiple instances;
[0107] EPO type: The same instance pair has multiple relationships.
[0108] According to the appendix Figures 1-4As shown, it is important to emphasize that the large language model is GPT-3.5, and its hyperparameters are set as follows: Temperature = 0.8, Top_p = 0.7, Presence_penalty = 1.0, and Response_format is "json_object".
[0109] According to the appendix Figures 1-4 As shown, it is particularly important to emphasize that the "equipment domain-specific corpus" in step S1 comes from text data related to aircraft, tanks, missiles, guns, and equipment in Wikipedia, Baidu Encyclopedia, and Firearms Encyclopedia; the "example text" in step S2 comes from the retrieval example set divided from the equipment domain relation extraction dataset, which is divided into a test set and a retrieval example set in an 8:2 ratio.
[0110] Example 1:
[0111] Step S1: Fine-tuning the embedded model
[0112] 1.1 Data Preprocessing: The equipment-specific corpus was cleaned, which contains texts about aircraft, tanks, missiles, etc. Invalid characters were removed, and the data was segmented into samples by sentence.
[0113] 1.2 Contrastive Learning Training: Using InfoNCE as the loss function, samples are input in batches. Each batch contains 1 query sample, 1 positive sample, and 16 negative samples. The training lasts for 10 epochs to optimize the BGE-M3 semantic space.
[0114] 1.3 Domain Adaptation Layer Addition: A fully connected network is added after the output layer of BGE-M3. The fully connected network has an input dimension of 768, a hidden layer of 512, and an output dimension of 768. It uses the ReLU activation function, is trained for 5 epochs, and only updates the adaptation layer parameters.
[0115] 1.4 Model Saving: Save the fine-tuned BGE-M3 model, including the domain adaptation layer, for subsequent embedding vector generation.
[0116] Step S2: Retrieval Example Library Construction
[0117] 2.1 Sample Text Filtering: Samples covering seven types of relationships and three overlapping types are filtered from the retrieved sample set to ensure representativeness;
[0118] 2.2 Sentence-level vector generation: Call the model saved in step S1, encode the example text into 768-dimensional sentence-level vectors, and store them in the example library;
[0119] 2.3 Relationship-level vector generation: The BERT fine-tuning model is used to extract the primary instance (SUB) and the guest instance (OBJ) in the example. The BERT fine-tuning model is a pre-trained BERT-base model fine-tuned with equipment domain data. The data is encoded as a 768-dimensional vector and then concatenated into a 1536-dimensional relationship-level vector, which is then stored in the example library.
[0120] 2.4 Reasoning Logic Generation: Generate query hints for each example, such as "In the sentence 'CVN-68 aircraft carrier was built by Newport News Shipbuilding in the United States...', which clues indicate that the relationship between 'CVN-68' and 'Newport News Shipbuilding' is 'manufacturing unit'?" Input the GPT-3.5 to generate reasoning logic, build enhanced examples, and add them to the example library.
[0121] Step S3: Dual-path retrieval and relevance ranking
[0122] 3.1 Input text processing: Obtain the equipment text from which the relationship to be extracted, such as "The M60 was the first main battle tank of the United States and has been in service with the U.S. military since 1962", and perform text cleaning;
[0123] 3.2 Sentence-level retrieval: The model in step S1 generates sentence-level vectors of the input text. Cosine similarity is calculated between these vectors and all sentence-level vectors in the example library. The top 10 highly similar examples are denoted as set G. sentence ;
[0124] 3.3 Relationship-level retrieval: The BERT fine-tuning model is used to extract the main instance "M60" and the guest instance "United States" from the input text, which are encoded as relation-level vectors. The cosine similarity is calculated between these vectors and the relation-level vectors in the example library. The top 10 highly similar examples are selected and denoted as set G. relation ;
[0125] 3.4 RRF Sort: For G sentence With G relation Examples in the example are scored according to the RRF formula, and the top 5 high-scoring examples are selected to form a highly relevant example set G.
[0126] Step S4: Prompt word construction and relation extraction
[0127] 4.1 Prompt Construction: Content is organized according to a template. The task description defines seven types of relations. "Predefined relations include manufacturing units and equipment facilities. Manufacturing units: main instance: aircraft / tank / missile / gun / equipment, guest instance: manufacturing plant; Equipment facilities: main instance: aircraft / tank / missile, guest instance: equipment... Output triples that match the relations, or NULL if none are found." Context examples are sorted by RRF ranking, such as "Example 1 (rank 1): text 'CVN-68 aircraft carrier was built by Newport News Shipbuilding in the United States...', inference logic '...', triples are: CVN-68, manufacturing unit and Newport News Shipbuilding...', input text is 'The M60 was the first main battle tank in the United States and has been in service with the US military since 1962';
[0128] 4.2 Relation Extraction: Input the prompt words into GPT-3.5, and the model outputs the extraction results: "(M60, Country or region of production, United States), (M60, Troops using, U.S. military)";
[0129] 4.3 Result Verification: Compare with the manually labeled results to confirm the accuracy of the extraction. If there are errors, the model can be optimized by supplementing examples and adjusting hyperparameters.
[0130] III. Experimental Results and Analysis
[0131] Comparative experiment: Compared with existing models on the test set, this method shows the best performance.
[0132]
[0133]
[0134] Ablation experiments: Verifying the effectiveness of dual-path retrieval:
[0135]
[0136] Experimental results show that this method significantly improves the accuracy and recall of equipment domain relationship extraction through dual-path retrieval and domain adaptation, especially in handling overlapping relationships.
[0137] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, 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. Without further limitations, 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 said element.
[0138] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the present invention as claimed. The scope of protection of this invention is defined by the appended claims and their equivalents.
Claims
1. A method for extracting equipment relations based on a large language model using dual-path retrieval and context learning, characterized in that: Includes the following steps: S1: Embedding model fine-tuning: Based on the pre-trained BGE-M3 embedding model, a domain-specific corpus and optimization target are introduced to perform domain-specific fine-tuning to obtain an embedding model adapted to the equipment domain. S2: Construction of the retrieval example library: Using the adapted embedding model obtained in step S1, sentence-level embedding vectors and relation-level embedding vectors of the example text are generated, and the large language model is guided to generate example inference logic in combination with the relation inference template to construct a retrieval example library containing example text, sentence-level embedding vectors, relation-level embedding vectors and inference logic. S3: Dual-path retrieval and relevance ranking: For the input equipment domain text, the sentence-level embedding vector and relation-level embedding vector are generated by the adaptation embedding model obtained in step S1. Based on the two types of vectors, relevant examples are recalled from the retrieval example library. Then, the RRF algorithm is used to fuse and rank the two retrieval results to obtain a highly relevant example set. S4: Prompt word construction and relation extraction: Based on the highly relevant example set obtained in step S3, construct prompt words containing task description, context learning examples and input text, input the prompt words into the large language model, and output the equipment relation extraction results.
2. The method for extracting equipment relations based on dual-path retrieval and context learning in a large language model according to claim 1, characterized in that, The "domain-specific fine-tuning" in step S1 specifically includes: S11: Contrastive learning is used to optimize the BGE-M3 embedding model, with the InfoNCE loss function as the objective, to bring positive sample vectors closer and push negative sample vectors further apart. The InfoNCE loss function is: Where, x i To query samples, For x i Relevant positive samples, x i For x i Irrelevant negative samples, τ is the temperature hyperparameter, and sim(·) is the cosine similarity; S12: A domain-specific adaptation layer is introduced at the top layer of the BGE-M3 embedding model. This adaptation layer is a lightweight fully connected network, and its calculation process is as follows: h=ReLU(W 1·e +b1), o = W²·h + b², Where e is the embedding vector output by BGE-M3, W1 and W2 are weight matrices, b1 and b2 are bias terms, h is the hidden layer output, and o is the domain adaptation output; S13: Freeze the underlying Transformer parameters of BGE-M3 during fine-tuning, and only update the domain adaptation layer parameters.
3. The method for extracting equipment relations based on a large language model using dual-path retrieval and context learning as described in claim 1, characterized in that, The "relation-level embedding vector generation" in step S2 specifically includes: S21: The BERT-based relation extraction fine-tuning method is used to extract the main instance (SUB) and guest instance (OBJ) from the example text; S22: Using the adapted embedding model obtained in step S1, generate the embedding vector U of the main instance respectively. sub Embedding vector U of guest instance obj ; S23: U sub with U ojb Concatenate along the dimensions to obtain the relation-level embedding vector U. r ,Right now:
4. The method for extracting equipment relations based on dual-path retrieval and context learning from a large language model according to claim 1, characterized in that, The "example reasoning logic generation" in step S2 specifically includes: S2a: For example: example i =(text,entity1,rntity2,relation), Generate query suggestions i "In the sentence 'context', what clues indicate that the relationship between 'entity_1' and 'entity_2' is 'relation'?" S2b: Query i Input the GPT-3.5 model and generate inference logic. i ; S2c: Building an Enhanced Example: EnhancedExample i =(text,entity1,entity2,relation,Inference i ) And store it in the retrieval example library.
5. The method for extracting equipment relations based on dual-path retrieval and context learning in a large language model according to claim 1, characterized in that, The "dual-path retrieval" in step S3 specifically includes: S31: Sentence-level embedding retrieval: Calculate the sentence-level embedding vector u of the input text. s The sentence-level embedding vector u of all examples in the retrieval example library si The cosine similarity is used to recall the k most semantically relevant examples. The similarity calculation formula is: S32: Relational-level Embedding Retrieval: Calculate the relational-level embedding vector u of the input text. r The relational embedding vector u of all examples in the retrieval example library ri The cosine similarity is used to recall the k most relevant instances in the instance relationship. The similarity calculation formula is:
6. The method for extracting equipment relations based on dual-path retrieval and context learning from a large language model according to claim 1, characterized in that, The calculation formula for "RRF algorithm fusion sorting" in step S3 is as follows: Where d is an example in the search example library, r(d) is the rank of example d in the nth search path, N is the number of search paths (N=2), and k is a constant greater than 1.
7. The method for extracting equipment relations based on dual-path retrieval and context learning in a large language model according to claim 1, characterized in that, The template for "prompt word construction" in step S4 is as follows: Task Description: {A predefined set of relation categories R and a description of the relation extraction task. Output the relations belonging to R; if no relation matches, output NULL.} Context learning example: {A set of highly relevant examples sorted by RRF, each example containing inference logic and labeled with its relevance ranking to the input text} Input: {Equipment domain text to be extracted} Output: {Relation extraction result placeholder}.
8. The method for extracting equipment relations based on dual-path retrieval and context learning in a large language model according to claim 1, characterized in that, The relationship types of the equipment field text include seven categories: manufacturing unit, equipment facility, user force, producing country or region, user country or region, predecessor, and successor. The types of overlapping relationships in the equipment domain text include: Normal type: Instances have only one relation; SEO type: The same instance forms different relationships with multiple instances; EPO type: The same instance pair has multiple relationships.
9. The method for extracting equipment relations based on dual-path retrieval and context learning in a large language model according to claim 1, characterized in that, The large language model is GPT-3.5, and its hyperparameters are set as follows: Temperature = 0.8, Top_p = 0.7, Presence_penalty = 1.0, and Response_format is "json_object".
10. The method for extracting equipment relations based on dual-path retrieval and context learning in a large language model according to claim 1, characterized in that, In step S1, the "Equipment Domain-Specific Corpus" is derived from text data related to aircraft, tanks, missiles, guns, and equipment in Wikipedia, Chinese Baidu Encyclopedia, and Firearms Encyclopedia. In step S2, the "Example Text" is derived from the retrieval example set divided from the equipment domain relation extraction dataset. The dataset is divided into a test set and a retrieval example set in an 8:2 ratio.