A steel industry document question and answer pair extraction method, device, equipment and medium
By performing format preprocessing and semantic association on documents in the steel industry, and using a large language model to extract question-answer pairs, the problems of poor table adaptability and information fragmentation in existing technologies have been solved, achieving efficient and accurate question-answer pair extraction and providing data support for the intelligent knowledge system of the steel industry.
Patent Information
- Application Number
- CN202611335823.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-31
- Publication Date
- 2026-11-27
AI Technical Summary
Existing technologies for extracting question-and-answer pairs from documents in the steel industry suffer from problems such as poor table adaptability, low accuracy in identifying technical terms, information fragmentation, and parameter mismatch, making it difficult to extract structured knowledge efficiently and accurately.
By preprocessing the format of documents in the steel industry, semantic relationships between text blocks and tables are established. Intelligent segmentation and question-answer pair extraction are performed using large language models and semantic models to ensure that the generated question-answer pairs conform to industry standards, eliminate redundant content, and integrate them into a structured dataset.
It enables efficient and accurate extraction of question-and-answer pairs from documents in the steel industry, reduces formatting and parameter matching errors, and provides solid data support for the construction of intelligent knowledge systems.
Smart Images

Figure CN123178552A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of natural language processing technology, and in particular to a method, apparatus, equipment and medium for extracting question-and-answer pairs from documents in the steel industry. Background Technology
[0002] With the continuous advancement of intelligent transformation in the steel industry, intelligent question-answering assistants for production, process, and technical services have been widely developed and applied. Their performance heavily relies on high-quality structured question-answer pairs; therefore, extracting structured knowledge from industry-specific documents has become a core necessity. Technical manuals, process regulations, and professional books in the steel industry contain key knowledge such as process parameters, equipment specifications, and operational points for core processes like steelmaking, continuous casting, rolling, and heat treatment. These documents are characterized by complex structures, numerous specialized tables, dense technical terminology, and strong data correlations. Currently, question-answer pair extraction in the steel industry primarily employs three mainstream technologies: rule-based or template-based semi-automatic extraction methods, end-to-end generative methods based on large language models, and extraction methods based on knowledge graphs or retrieval enhancement.
[0003] The three existing technologies all have significant shortcomings in practical applications within the steel industry. Rule-based template methods are suitable for simple, fixed-format documents, but they are poorly adapted to the complex and ever-changing tables used in the industry, have high manual maintenance costs, and struggle to handle the semantic relationships between text and tables. While large language model-based generative methods can handle complex documents, their specialized adaptation capabilities are insufficient, leading to formatting errors, parameter mismatches, and content duplication. They are particularly prone to missing key information and parameter errors in multi-row, multi-column parameter tables. Knowledge graph or retrieval enhancement methods rely on existing structured prior knowledge, making it difficult to directly parse raw unstructured documents and understand the inherent logic between steel process parameters. Overall, existing technologies have weak understanding of merged cell tables, low accuracy in recognizing industry terminology and parameter units, and lack a systematic processing mechanism for mixed text and table structures, rendering the generated results unsuitable for direct use in building industry knowledge bases.
[0004] Therefore, how to efficiently and accurately extract question-and-answer pairs from documents in the steel industry has become a problem to be solved. Summary of the Invention
[0005] This application provides a method, apparatus, equipment, and medium for extracting question-and-answer pairs from documents in the steel industry. Addressing the complex structure and diverse formats of documents in the steel industry, it first performs unified format preprocessing on complex documents, removing irrelevant information, and then intelligently segments long documents into semantically complete text blocks and table blocks based on the document's semantic structure, laying a data foundation for subsequent extraction. Recognizing the high correlation between text descriptions and table parameters in steel industry documents, it establishes semantic relationships between text blocks and corresponding tables, ensuring that text and tables can be understood collaboratively and avoiding parameter mismatches or omissions of key information due to information fragmentation. Question-and-answer pairs are extracted by combining the semantic information of text blocks and related text-table blocks, ensuring that the generated question-and-answer pairs conform to steel industry standards in terms of format specifications, parameter matching, and the use of professional terminology, significantly reducing formatting and parameter matching errors. Finally, the extracted text and table question-and-answer pairs are processed to eliminate redundant content and integrated and output in a structured manner, forming a high-quality question-and-answer pair dataset that can be directly used for industry knowledge base construction or model training. This application uses the above-mentioned solution to efficiently and accurately extract question-and-answer pairs from documents in the steel industry, fully adapting to the application needs of intelligent knowledge services in the steel industry, and providing solid data support for the construction of an intelligent knowledge system and the intelligent application of the steel industry.
[0006] In a first aspect, embodiments of this application provide a method for extracting question-and-answer pairs from documents in the steel industry, the method comprising: Obtain steel industry documents and perform format parsing and cleaning to obtain standardized steel industry documents; Standardized steel industry documents are processed to obtain text blocks, table blocks, and text-table linked blocks; Process the text blocks and table blocks to obtain the association mapping table; Based on the large language model, the predefined domain constraint prompt word templates and text blocks are extracted to obtain text question-answer pairs; The table blocks are processed based on the large language model, first-stage prompt words, and second-stage prompt words to obtain table question-answer pairs; By performing intra-group associations on text question-and-answer pairs and table question-and-answer pairs based on text table association blocks and association mapping tables, a structured question-and-answer pair dataset is obtained.
[0007] Furthermore, the standardized steel industry documents are processed to obtain text blocks, table blocks, and text-table linked blocks, including: Standardized steel industry documents are inspected and located to obtain multiple table blocks; each table block includes the table structure and marker positions; the marker positions include the table area location, table number, table title, table header, and table notes. Replace the continuation table title in the table header with the preceding valid title; Based on a domain keyword database and semantic model, standardized steel industry documents are identified, resulting in multiple text blocks; each text block includes a process description paragraph. Based on the principles of semantic similarity and location proximity, each table block is associated with a text block to construct a text-table association block.
[0008] Further processing of text blocks and table blocks yields an association mapping table, including: Text blocks and table blocks are encoded based on semantic models to obtain text semantic vectors and table semantic vectors; The association strength score is obtained by calculating the semantic similarity of the text semantic vector and the table semantic vector. A correlation mapping table is constructed based on the correlation strength score.
[0009] Furthermore, text blocks and table blocks are encoded based on a semantic model to obtain text semantic vectors and table semantic vectors, including: Input text blocks and table blocks into the corresponding word segmenter and encoder in the semantic model, output the hidden layer representation based on the model output, and generate block-level semantic vectors based on CLS vector extraction; Normalize the block-level semantic vectors to obtain text semantic vectors and table semantic vectors in a unified vector space.
[0010] Furthermore, based on the large language model, first-stage prompts, and second-stage prompts, the table blocks are processed to obtain table question-answer pairs, including: Based on the prompts in the first stage, the table structure of the table block is analyzed, the row and column coverage list and table topic are extracted, and related text information is injected to obtain the first table result; Based on the prompts in the second stage, the results in the first table are analyzed to obtain the results in the second table. The results of the second table are processed based on the large language model to obtain table question-answer pairs.
[0011] Furthermore, it also includes: The table question-answer pairs are encoded based on the BGE model to obtain the encoded table question-answer pairs; The encoded question-and-answer pairs are deduplicated to obtain the deduplicated question-and-answer pairs.
[0012] Furthermore, based on the text-table association blocks and association mapping table, intra-group associations are performed on text question-answer pairs and table question-answer pairs to obtain a structured question-answer pair dataset, including: Based on the text table association block and the association mapping table, text question-answer pairs and table question-answer pairs from the same text table association block are associated within the group to obtain multiple question-answer groups, and semantic topics and coverage integrity scores are labeled for each question-answer group. A structured question-answer pair dataset is obtained from each question-answer group.
[0013] Secondly, embodiments of this application provide a document question-and-answer pair extraction device for the steel industry, the device comprising: The preprocessing module is used to acquire steel industry documents and perform format parsing and cleaning to obtain standardized steel industry documents. The data segmentation module is used to process standardized steel industry documents to obtain text blocks, table blocks, and text-table related blocks; The semantic association module is used to process text blocks and table blocks to obtain an association mapping table; The first generation module is used to extract predefined domain constraint prompt word templates and text blocks based on a large language model to obtain text question-answer pairs; The second generation module is used to process the table blocks based on the large language model, the first-stage prompt words, and the second-stage prompt words to obtain table question-answer pairs; The integration module is used to perform intra-group associations on text question-answer pairs and table question-answer pairs based on text table association blocks and association mapping tables, resulting in a structured question-answer pair dataset.
[0014] Thirdly, embodiments of this application provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it performs the steps of a steel industry document question-and-answer pair extraction method as described in any of the above embodiments.
[0015] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of a steel industry document question-and-answer pair extraction method as described in any of the above embodiments.
[0016] In summary, compared with the prior art, the beneficial effects of the technical solution provided in this application include at least the following: This application provides a method for extracting question-and-answer pairs from documents in the steel industry. Addressing the complex structure and diverse formats of steel industry documents, the method first performs unified format preprocessing to remove irrelevant information. Then, based on the document's semantic structure, it intelligently segments long documents into semantically complete text blocks and table blocks, laying a data foundation for subsequent extraction. Recognizing the high correlation between text descriptions and table parameters in steel industry documents, it establishes semantic relationships between text blocks and corresponding tables, ensuring that text and tables can be understood collaboratively and avoiding parameter mismatches or omissions of key information due to information fragmentation. Question-and-answer pairs are extracted by combining the semantic information of text blocks and related text-table blocks, ensuring that the generated question-and-answer pairs conform to steel industry standards in terms of format specifications, parameter matching, and the use of professional terminology, significantly reducing formatting and parameter matching errors. Finally, the extracted text and table question-and-answer pairs are processed to eliminate redundant content and integrated and output in a structured manner, forming a high-quality question-and-answer pair dataset that can be directly used for industry knowledge base construction or model training. This application uses the above-mentioned solution to efficiently and accurately extract question-and-answer pairs from documents in the steel industry, fully adapting to the application needs of intelligent knowledge services in the steel industry, and providing solid data support for the construction of an intelligent knowledge system and the intelligent application of the steel industry. Attached Figure Description
[0017] Figure 1 A flowchart illustrating a method for extracting question-and-answer pairs from documents in the steel industry, provided as an exemplary embodiment of this application.
[0018] Figure 2 This is a structural diagram of a document question-and-answer pair extraction device for the steel industry, provided as an exemplary embodiment of this application. Detailed Implementation
[0019] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.
[0020] Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0021] Please see Figure 1 This application provides a method for extracting question-and-answer pairs from documents in the steel industry. The method specifically includes the following steps: Step S1: Obtain steel industry documents and perform format parsing and cleaning to obtain standardized steel industry documents.
[0022] In one feasible implementation, complex documents in the steel industry include, but are not limited to, professional textbooks, process manuals, technical standards and specifications, and equipment parameter tables. These documents can be in formats such as scanned PDF documents, Word technical manuals, or standard HTML pages. The collected complex documents from the steel industry undergo format parsing and cleaning, uniformly converting them into structured Markdown format. This process preserves the original semantic elements such as heading levels, table structures, and lists, while also standardizing the text and removing redundant information (including textbook publication information and references) to ensure the structural consistency and parsability of the input data, resulting in standardized steel industry documents. Specifically, data cleaning includes operations such as format parsing, table extraction, text standardization, and redundant information removal.
[0023] This document processing method can adapt to the differentiated formatting styles of steel industry documents from various sources. By using a unified Markdown format, it fully preserves the content layout logic of the original data, eliminating data reading obstacles caused by the disorganization of different document formats at the source. Removing redundant content allows for the selection and retention of relevant and effective content in the steel industry, preventing invalid content from consuming storage resources. Standardized steel industry documents can then be used directly, saving the work of repeatedly sorting out the original draft and reducing the time spent on initial content preprocessing.
[0024] Step S2: Process the standardized steel industry documents to obtain text blocks, table blocks, and text-table association blocks.
[0025] In some embodiments, standardized steel industry documents are processed to obtain text blocks, table blocks, and text-table associated blocks, including: Standardized steel industry documents are inspected and located to obtain multiple table blocks; each table block includes the table structure and marker positions; the marker positions include the table area location, table number, table title, table header, and table notes. Replace the continuation table title in the table header with the preceding valid title; Based on a domain keyword database and semantic model, standardized steel industry documents are identified, resulting in multiple text blocks; each text block includes a process description paragraph. Based on the principles of semantic similarity and location proximity, each table block is associated with a text block to construct a text-table association block.
[0026] In one feasible implementation, the Markdown document is first subjected to table detection and location, identifying all table structures and marking their positions. The table structures include one or more of the following: standard rule tables, wireless tables, merged cell tables, multi-level header tables, and pagination continuation tables. The marked positions include one or more of the following: table area position, table number, table title, table header, and table footer.
[0027] Furthermore, the table titles are processed by replacing the continuation table titles with preceding valid titles. A continuation table title refers to a continuing title used when the same table continues to be displayed in a later position due to pagination or length limitations (e.g., Continuation 1.1); a preceding valid title refers to the most recent non-continuing table title that appears before the continuation table title and can fully represent the subject matter of the table (e.g., Table 1.1 Chemical Composition of Low Alloy Steel in the Original Standard (TOCT 19281-1989) (Unit: %)).
[0028] Furthermore, a domain keyword library (such as "ironmaking," "rolling," "heat treatment," and "temperature control") and a semantic model (such as BERT) are used to identify standardized steel industry documents, resulting in multiple text blocks. These text blocks can include process description paragraphs. Process description paragraphs describe the production process, process steps, process conditions, equipment operation requirements, process parameter control logic, or process connection relationships. Key process stages include core processing stages, parameter control stages, or process connection stages that have a significant impact on product quality, process stability, energy consumption control, production safety, or the effectiveness of subsequent processes. Further, correlation data is calculated based on semantic similarity and proximity principles. The correlation data ranges from 0 to 1, with 0 indicating the least relevant and 1 indicating the most relevant. Each table block is then associated with its most relevant text block to construct a text table correlation block.
[0029] In one feasible implementation, consecutive process description segments can be associated based on semantic similarity to avoid interruptions at critical process stages. The semantic similarity can be the cosine similarity of semantic vectors. Specifically, a threshold is preset, and the calculated value of the semantic vector cosine similarity is compared with this threshold. If the calculated value of the semantic vector cosine similarity is greater than the threshold, the current process description segments are merged.
[0030] Optionally, an adaptive segmentation method based on sentence boundaries and topic segmentation is used for non-related texts to ensure that each text is semantically independent and of appropriate length.
[0031] This application optimizes the content segmentation logic of standardized documents in the steel industry, unifies the title content of various paginated continuation tables, and fills in missing thematic information in continuation tables. Based on a domain keyword database and semantic model, it generates text blocks by dividing content according to the process flow, avoiding the problem of core process content being unreasonably split and broken. It generates text-table association blocks by binding corresponding table blocks and text blocks according to semantic similarity and positional proximity, realizing the content binding of process text and accompanying parameter tables. When building an industry knowledge base later, associated content can be retrieved synchronously, eliminating the extra step of separately matching text and tables, effectively accelerating the overall progress of steel industry data structuring, and reducing the manpower input required for manually sorting document content.
[0032] Step S3: Process the text block and table block to obtain the association mapping table.
[0033] In some embodiments, text blocks and table blocks are processed to obtain an association mapping table, including: Text blocks and table blocks are encoded based on semantic models to obtain text semantic vectors and table semantic vectors; The association strength score is obtained by calculating the semantic similarity of the text semantic vector and the table semantic vector. A correlation mapping table is constructed based on the correlation strength score.
[0034] In some embodiments, text blocks and table blocks are encoded based on a semantic model to obtain text semantic vectors and table semantic vectors, including: Input text blocks and table blocks into the corresponding word segmenter and encoder in the semantic model, output the hidden layer representation based on the model output, and generate block-level semantic vectors based on CLS vector extraction; Normalize the block-level semantic vectors to obtain text semantic vectors and table semantic vectors in a unified vector space.
[0035] In one feasible implementation, the semantic model is a semantic representation model that can map text blocks and table blocks to a unified semantic vector space, and can be one or more of BERT, Sentence-BERT, SimCSE, E5, BGE, m3e, and TaBERT.
[0036] Alternatively, CLS vector extraction can be replaced by average pooling or weighted pooling.
[0037] Specifically, semantic similarity calculation employs a weighted comprehensive scoring method, which comprehensively considers both vector similarity and positional distance: ; in, Represents a semantic vector. This indicates the distance between text and tables within the document. , These are the weighting coefficients.
[0038] This application employs a semantic model to convert text blocks into table blocks via vectors. Normalization ensures that the text and table semantic vectors are aggregated into the same vector space. Then, a correlation mapping table is generated based on the quantified correlation strength score. This entire process replaces the traditional manual comparison method with quantified numerical values, mitigating the matching bias caused by subjective human judgment. The generated correlation mapping table strengthens the correspondence between the two types of data. When retrieving steel industry data, this mapping table can be used to quickly complete content matching, simplifying the computational process in the knowledge base retrieval stage and reducing resource consumption during system operation.
[0039] Step S4: Extract the preset domain constraint prompt word template and text block based on the large language model to obtain text question-answer pairs.
[0040] In one feasible implementation, a domain-constrained prompt template is constructed, explicitly requiring the model to extract answerable professional question-and-answer pairs based on the original text, avoiding common-sense questions. A locally deployed large language model (such as Qwen or DeepSeek) is invoked, inputting text blocks and prompts to generate structured text question-and-answer pairs. The generated text question-and-answer pairs are then filtered for validity, removing entries with empty questions or answers, and undergoing basic format checks. The basic format refers to the question-and-answer pairs conforming to preset data organization specifications, such as key-value pair format, JSON object format, or JSON array format.
[0041] Specifically, the extraction scope of the large language model is limited by domain-constrained prompts, guiding the model to generate content around text blocks related to the steel industry and avoiding redundant output of irrelevant common-sense questions and answers. The extraction process utilizes a locally deployed large language model, eliminating the need for external transmission of raw industry data and ensuring data retention during the data flow process. Invalid entries are removed and format verification is performed on the generated content to select compliant and usable text question-and-answer pairs. These filtered and organized text question-and-answer pairs can be directly imported into the industry knowledge base, significantly reducing the workload of manually compiling and editing question-and-answer content and shortening the construction cycle of intelligent question-and-answer resources for the steel industry.
[0042] Step S5: Process the table block based on the large language model, the first-stage prompt words, and the second-stage prompt words to obtain table question-answer pairs.
[0043] In some embodiments, the table blocks are processed based on a large language model, first-stage prompt words, and second-stage prompt words to obtain table question-answer pairs, including: Based on the prompts in the first stage, the table structure of the table block is analyzed, the row and column coverage list and table topic are extracted, and related text information is injected to obtain the first table result; Based on the prompts in the second stage, the results in the first table are analyzed to obtain the results in the second table. The results of the second table are processed based on the large language model to obtain table question-answer pairs.
[0044] In one feasible implementation, a two-stage collaborative extraction strategy is adopted to address the problem of semantic separation between tables and text. First, the associated text information corresponding to the table blocks is obtained as supplementary information for table semantics. Second, two-stage prompt words are constructed: the first-stage prompt words guide the model to analyze the table structure, extract the row and column coverage list and table topic, and inject associated text information to enhance understanding; the second-stage prompt words generate table question-answer pairs row by row, and enhance the question expression by combining associated text semantics to avoid ambiguity; the local large language model is called to generate table question-answer pairs in stages, and the generated results are filtered for validity and marked with sources.
[0045] This approach employs a two-stage prompting word approach combined with a large language model to process table blocks step by step, splitting the workflow between table parsing and question-and-answer generation. It also incorporates related text to supplement the semantic information missing from the table itself, effectively resolving the semantic disconnect that occurs when tables are parsed independently. This step-by-step processing mode refines the logic of table content interpretation layer by layer, optimizing the relevance of question-and-answer content.
[0046] Step S6: Perform intra-group associations on text question-and-answer pairs and table question-and-answer pairs based on text table association blocks and association mapping tables to obtain a structured question-and-answer pair dataset.
[0047] In some embodiments, text question-answer pairs and table question-answer pairs are associated within groups based on text table association blocks and association mapping tables to obtain a structured question-answer pair dataset, including: Based on the text table association block and the association mapping table, text question-answer pairs and table question-answer pairs from the same text table association block are associated within the group to obtain multiple question-answer groups, and semantic topics and coverage integrity scores are labeled for each question-answer group. A structured question-answer pair dataset is obtained from each question-answer group.
[0048] The structured question-answering dataset can include metadata such as questions, answers, source types, and confidence levels, supporting subsequent knowledge base construction and model training.
[0049] In some embodiments, it also includes: The table question-answer pairs are encoded based on the BGE model to obtain the encoded table question-answer pairs; The encoded question-and-answer pairs are deduplicated to obtain the deduplicated question-and-answer pairs.
[0050] Specifically, duplicates can be filtered out by setting a similarity threshold (such as 0.9).
[0051] The above embodiments provide a method for extracting question-and-answer pairs from documents in the steel industry. Addressing the complex structure and diverse formats of steel industry documents, the method first performs unified format preprocessing to remove irrelevant information. Then, based on the document's semantic structure, it intelligently segments long documents into semantically complete text blocks and table blocks, laying a data foundation for subsequent extraction. Recognizing the high correlation between text descriptions and table parameters in steel industry documents, it establishes semantic relationships between text blocks and corresponding tables, ensuring that text and tables can be understood collaboratively and avoiding parameter mismatches or omissions of key information due to information fragmentation. Question-and-answer pairs are extracted by combining the semantic information of text blocks and associated text-table blocks, ensuring that the generated question-and-answer pairs conform to steel industry standards in terms of format specifications, parameter matching, and the use of professional terminology, significantly reducing formatting and parameter matching errors. Finally, the extracted text and table question-and-answer pairs are processed to eliminate redundant content and integrated and output in a structured manner, forming a high-quality question-and-answer pair dataset that can be directly used for industry knowledge base construction or model training. This application uses the above-mentioned solution to efficiently and accurately extract question-and-answer pairs from documents in the steel industry, fully adapting to the application needs of intelligent knowledge services in the steel industry, and providing solid data support for the construction of an intelligent knowledge system and the intelligent application of the steel industry.
[0052] In one feasible implementation, the following detailed description of a question-and-answer pair construction method for complex documents in the steel industry proposed in this application is provided in conjunction with specific embodiments.
[0053] This embodiment uses a complex document (containing text, tables, and continuation table structures) from a steel industry textbook as an example input, including: section titles, continuous explanatory text, enumerated clauses, table titles, tables, continuation table titles, table notes, and explanatory notes after the tables. The steps of the method shown in this invention are explained.
[0054] S1: Document format standardization and preprocessing example.
[0055] In this embodiment, the input document is a PDF scanned textbook, which, after parsing, yields the following structural fragment (excerpt): "####1.3.2 Basic criteria for classifying steel according to chemical composition...see Table 1.3-2...continued Table 1.3-2...".
[0056] First, use MinerU or an equivalent parsing tool to convert the PDF document to Markdown format, resulting in the following structure: Title level: ####1.3.2; Main text paragraphs: Text content retained; Table structure: HTML
[0057]
[0058]
[0059] Tag format is retained; Table title: Table 1.3-2 Specified content limits of alloying elements in non-alloy steel, low-alloy steel and alloy steel; Continued table label: Continued Table 1.3-2; Subsequently, data cleaning is performed to obtain a structured Markdown document, providing a foundation for subsequent semantic processing. S2: Intelligent semantic block processing example. S21: Table detection and marking. Tables are identified through regular expressions and HTML parsing methods: Detection rules: ... ; Table number extraction rule: table\s*\d+(\.\d+)*; Continuation rule: Continuation table \s*\d+(\.\d+)*; For example, after identification, the following is obtained: Table ID: Table_01; Table title: Table 1.3-2 Non-alloy steel, low-alloy steel...; Table structure type: Multi-level header table + paginated continuation table; Table notes: Note 1, Note 2.
[0060] S22: Continuous table header processing.
[0061] The phrase "Continued from Table 1.3-2" was detected. Therefore, the most recent valid title was traced back to: "Table 1.3-2 Specified Limits for Alloy Element Content in Non-Alloy Steel, Low-Alloy Steel, and Alloy Steel". The continued tables were then uniformly replaced with this title, and the numbering was removed, retaining only the subject title: "Specified Limits for Alloy Element Content in Non-Alloy Steel, Low-Alloy Steel, and Alloy Steel".
[0062] S23: Process segment identification and merging.
[0063] First, the processed text is split into "paragraph particles".
[0064] The paragraphs are numbered P1-P10. P1 classifies steel according to its chemical composition, not arbitrarily defining it based on any single content value of alloying elements. P2 clarifies that the criteria for determining the specified content of alloying elements include multiple provisions. P3, P4, P5, and P6 correspond to the minimum value specified by the standard, the maximum value specified by the standard, and the detailed rules regarding the non-use of residual element content when no standard exists, respectively. P7 provides supplementary explanations to the previous four provisions, highlighting that these four provisions mainly revolve around the content of P3. P8 explains the basic meaning of residual element content. P9 introduces the sources of residual elements. P10 discusses the relevant effects of residual elements on performance.
[0065] After using BERT / BGE encoding, the cosine similarity between adjacent segments is calculated; after calculation, the merging threshold is set to 0.85. Therefore, the merged result is: TextBlock_A: P1-P7 (Rules for determining the content of gold elements); TextBlock_B: P8-P10 (Definition of participating elements and their influencing mechanisms).
[0066] This division ensures that "rules + explanations" are in the same semantic unit, preventing subsequent question-and-answer generation from being broken.
[0067] S24: Text-table association (taking Table 1.3-2 as an example).
[0068] In this step, the text content that has a direct descriptive relationship with the table and the table itself are jointly segmented into an independent semantic block. Taking the complex document example, the following table title was detected: Table 1.3-2 Specified limits for the content of alloying elements in non-alloy steel, low-alloy steel and alloy steel.
[0069] Before the table, there is the following descriptive statement: "Specified content limits for alloying elements in non-alloy steel, low-alloy steel, and alloy steel, see Table 1.3-2." This statement contains the explicit table reference "see 1.3-2," therefore it is identified as the preceding descriptive text. Subsequently, "Continued Table 1.3-2" is detected. Since this continued table has the same number as the aforementioned table, it is not segmented separately but incorporated into the same table semantic block. Simultaneously, the notes following the table: Note 1: La-series element content, which can also be the total content of mixed rare earth elements. Note 2: "—" in the table indicates not specified and is not used as a basis for division. These are explanations of the table fields and their meanings, and are also incorporated into this text-table association block. Ultimately, an independent semantic block is formed.
[0070] S25: Adaptive text chunking implementation example.
[0071] After completing the semantic merging in step S23 and the construction of the text table association blocks in step S24, the remaining text content that was not merged or not included in the text table association blocks is processed using an adaptive block segmentation method based on sentence boundaries and topic changes.
[0072] First, the sample text content is segmented according to sentence boundaries to obtain the smallest semantic unit: the same embedding model (such as BGE) as in step S23 is used to encode the sentence and reverse the line, and the semantic similarity between adjacent semantic blocks is calculated: the following adaptive segmentation parameters are set: the similarity threshold is 0.80; the minimum block length is 150 characters; and the maximum block length is 500 characters.
[0073] The segmentation strategy is as follows: when the similarity between adjacent sentences is ≥0.80, they are merged into the same text block; when the similarity is <0.80, it is considered a topic change and segmentation is performed; if the block length exceeds the maximum length, it is forcibly split; if the block length is less than the minimum length, it is merged forward or backward.
[0074] Based on the above rules, the following text block division results are obtained: TextBlock_C: S1-S2 (boundary value definition and classification principle); TextBlock_D: S3-S4 (differences between different standards and division basis); TextBlock_E: S5-S6 (boundary value source and comparison with international standards).
[0075] It should be noted that step S23 has already merged regular paragraphs with strong semantic dependencies, and step S25 will no longer process such paragraphs, but will only apply to "splittable but still complete descriptive text".
[0076] S3: Example of establishing semantic association between text and table.
[0077] After step S2, the document has been divided into the following three semantic units: rule semantic blocks: TextBlock_A (P1-P7); residual element interpretation blocks: TextBlock_B (P8-P10); text-table association blocks: TextTableBlock_01 (related content of Table 1.3-2); and descriptive text blocks: TextBlock_C, TextBlock_D, and TextBlock_E (obtained from S25). Based on the above semantic blocks, this step constructs structured semantic representations and associations for subsequent question-answering generation and retrieval enhancement.
[0078] S31: Semantic vector encoding.
[0079] Two semantic blocks are selected for example illustration: TextBlock_A: the rule system for determining the content of alloying elements (P1-P7); TextTableBlock_01: the limit values of the content of alloying elements in non-alloy steel, low-alloy steel, and alloy steel (including tables and annotations); encoded using the BRG model (768 dimensions), the following is the truncated representation of the example vectors: TextVector_A=BGE(TextBlock_A)=[0.12,-0.08,0.33,...,0.27]; TableVector_01=BGE(Linearized_Table)=[0.10,-0.05,0.30,...,0.25]. The vectors are normalized to ensure that all vectors reside in a unified semantic space.
[0080] S32: Semantic similarity calculation, using cosine similarity.
[0081] S33: Semantic association structure construction.
[0082] With the association threshold set to 0.8, the following structure was ultimately established: {"TextBlock_A":["TextTableBlock_01"],"TextBlock_B":["TextTableBlock_01"],"TextBlock_C":[],"TextBlock_D":[],"TextBlock_E":[]} At the same time, establish a reverse mapping: {"TextTableBlock_01":["TextBlock_A","TextBlock_B"]} Finally, based on semantic content, the relationship type is automatically labeled, not only establishing index relationships but also embedding related information into the chunks: {"block_id":"TextTableBlock_01","related_text_blocks":["TextBlock_A","TextBlock_B"],"relation_types":["rule definition","data support"]} S4: Example of extracting text block question-and-answer pairs.
[0083] S41: Example of a prompt word.
[0084] Set the following prompts (including but not limited to the following key content): You are an expert in the field of steel metallurgy. Please extract high-quality question-and-answer pairs from the following text. Requirements: 1. The questions must be specific and professional. 2. Vague references such as "this" or "the above" are not allowed. 3. Output JSON formatted text: {text block content}.
[0085] S42: Model generation example.
[0086] The following question-and-answer pairs are generated after inputting TextBlock_A: Q: When determining the specified content of an alloying element, how should we handle situations where only the highest value is given? Answer (A): The prescribed content should be 0.7 times the highest value.
[0087] S43: Filtering rules.
[0088] Delete the generated question-and-answer pair if any of the following conditions are met: Q or A is empty; length is less than 10 characters; or it contains "modify image" or "this table".
[0089] S5: Example of collaborative extraction of table block question-and-answer pairs.
[0090] First, the content of TextBlock_02 is concatenated to the table input. Then, the table fields are identified: element, non-alloy steel, low-alloy steel, and alloy steel. Finally, based on the identified fields, the table is traversed row by row to generate question-answer pairs. Finally, the filtered results are output according to the specified format.
[0091] S6: Example of deduplication and integration of question-answer pairs.
[0092] S61: Perform semantic deduplication on the generated question-answer pairs. Use BGE encoding to calculate semantic similarity. When the similarity is greater than 0.9, it is determined to be semantic duplicate, and the question-answer pair is deleted.
[0093] S62: Calculate coverage. Group the generated question-and-answer pairs according to the text table question-and-answer blocks. Calculate the coverage of each block.
[0094] Therefore, this application effectively solves the semantic fragmentation problem caused by fixed segmentation in traditional question-answering pair extraction techniques by using intelligent semantic segmentation and a text-table collaborative processing mechanism. It achieves semantic linkage extraction between text and tables, ensuring the integrity and coherence of knowledge units, and laying a technical foundation for high-quality question-answering pair extraction from complex documents in the steel industry. Through two-stage table extraction and associated text enhancement, the accuracy, completeness, and interpretability of question-answering pairs are significantly improved, making the extraction results more reliable in terms of parameter matching and logical consistency, and effectively reducing problems such as formatting errors, parameter matching errors, and omissions of key information. This method is applicable to various professional documents in the steel industry, especially for process parameter tables with complex table structures and dense technical terms, achieving high extraction and accuracy rates, and providing high-quality data support for the construction of steel industry knowledge bases and model fine-tuning.
[0095] Please see Figure 2 Another embodiment of this application provides a document question-and-answer pair extraction device for the steel industry, the device comprising: The preprocessing module 101 is used to acquire steel industry documents and perform format parsing and cleaning to obtain standardized steel industry documents.
[0096] The data segmentation module 102 is used to process standardized steel industry documents to obtain text blocks, table blocks, and text-table association blocks.
[0097] The semantic association module 103 is used to process text blocks and table blocks to obtain an association mapping table.
[0098] The first generation module 104 is used to extract the preset domain constraint prompt word template and text block based on the large language model to obtain text question-answer pairs.
[0099] The second generation module 105 is used to process the table blocks based on the large language model, the first-stage prompt words, and the second-stage prompt words to obtain table question-answer pairs.
[0100] The integration module 106 is used to perform intra-group association of text question-and-answer pairs and table question-and-answer pairs based on the text table association block and the association mapping table to obtain a structured question-and-answer pair dataset.
[0101] The specific limitations of the document question-and-answer pair extraction device for the steel industry provided in this embodiment can be found in the embodiment of the document question-and-answer pair extraction method for the steel industry described above, and will not be repeated here. Each module in the above-described document question-and-answer pair extraction device for the steel industry can be implemented entirely or partially through software, hardware, or a combination thereof. Each module can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0102] This application provides a computer device that may include a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it causes the processor to perform the steps of a steel industry document question-and-answer pair extraction method as described in any of the above embodiments.
[0103] The working process, working details, and technical effects of the computer equipment provided in this embodiment can be found in the embodiment of a method for extracting question-and-answer pairs from documents in the steel industry described above, and will not be repeated here.
[0104] This application provides a computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the steps of a steel industry document question-and-answer pair extraction method as described in any of the above embodiments. The computer-readable storage medium refers to a data storage medium, which may include, but is not limited to, floppy disks, optical disks, hard disks, flash memory, USB flash drives, and / or memory sticks. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
[0105] The working process, working details, and technical effects of the computer-readable storage medium provided in this embodiment can be found in the embodiment of a question-and-answer pair extraction method for steel industry documents described above, and will not be repeated here.
[0106] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0107] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0108] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A method for extracting question-and-answer pairs from documents in the steel industry, characterized in that, The method includes: Obtain steel industry documents and perform format parsing and cleaning to obtain standardized steel industry documents; The standardized steel industry documents are processed to obtain text blocks, table blocks, and text-table association blocks; The text block and the table block are processed to obtain an association mapping table; Based on the large language model, the preset domain constraint prompt word template and the text block are extracted to obtain text question-answer pairs; The table block is processed based on the large language model, first-stage prompt words, and second-stage prompt words to obtain table question-answer pairs; Based on the text table association block and the association mapping table, the text question-answer pairs and the table question-answer pairs are associated within groups to obtain a structured question-answer pair dataset.
2. The method for extracting question-and-answer pairs from documents in the steel industry according to claim 1, characterized in that, The process of processing the standardized steel industry documents to obtain text blocks, table blocks, and text-table association blocks includes: The standardized steel industry documents are subjected to table detection and location to obtain multiple table blocks; each table block includes a table structure and marker positions; the marker positions include table area location, table number, table title, table header, and table notes; Replace the continuation table title in the table header with the preceding valid title; Based on a domain keyword library and semantic model, the standardized steel industry documents are identified to obtain multiple text blocks; each text block includes a process description paragraph. Based on the principles of semantic similarity and location proximity, each table block is associated with a text block to construct a text-table association block.
3. The method for extracting question-and-answer pairs from documents in the steel industry according to claim 1, characterized in that, The process of processing the text block and the table block to obtain the association mapping table includes: The text block and the table block are encoded based on a semantic model to obtain a text semantic vector and a table semantic vector; The semantic similarity of the text semantic vector and the table semantic vector is used to calculate the association strength score. A correlation mapping table is constructed based on the correlation strength score.
4. The method for extracting question-and-answer pairs from documents in the steel industry according to claim 3, characterized in that, The encoding of the text block and the table block based on the semantic model to obtain the text semantic vector and the table semantic vector includes: The text block and the table block are input into the corresponding word segmenter and encoder in the semantic model. The hidden layer representation is output based on the model, and block-level semantic vectors are generated based on CLS vector extraction. The block-level semantic vectors are normalized to obtain text semantic vectors and table semantic vectors in a unified vector space.
5. The method for extracting question-and-answer pairs from documents in the steel industry according to claim 1, characterized in that, The table block is processed based on a large language model, first-stage prompt words, and second-stage prompt words to obtain table question-answer pairs, including: Based on the prompts in the first stage, the table structure of the table block is analyzed, the row and column coverage list and the table topic are extracted, and related text information is injected to obtain the first table result; Based on the prompts in the second stage, the results in the first table are analyzed to obtain the results in the second table. The results of the second table are processed based on the large language model to obtain table question-answer pairs.
6. The method for extracting question-and-answer pairs from documents in the steel industry according to claim 1, characterized in that, Also includes: The table question-answer pairs are encoded based on the BGE model to obtain the encoded table question-answer pairs. The encoded table question-and-answer pairs are deduplicated to obtain deduplicated table question-and-answer pairs.
7. The method for extracting question-and-answer pairs from documents in the steel industry according to claim 1, characterized in that, The step of performing intra-group associations on the text question-and-answer pairs and the table question-and-answer pairs based on the text table association blocks and the association mapping table to obtain a structured question-and-answer pair dataset includes: Based on the text table association block and the association mapping table, text question-answer pairs and table question-answer pairs from the same text table association block are associated within a group to obtain multiple question-answer groups, and semantic topics and coverage integrity scores are labeled for each question-answer group. A structured question-answer pair dataset is obtained based on each of the aforementioned question-answer groups.
8. A document question-and-answer pair extraction device for the steel industry, characterized in that, The device includes: The preprocessing module is used to acquire steel industry documents and perform format parsing and cleaning to obtain standardized steel industry documents. The data segmentation module is used to process the standardized steel industry documents to obtain text blocks, table blocks, and text-table association blocks; A semantic association module is used to process the text block and the table block to obtain an association mapping table; The first generation module is used to extract the preset domain constraint prompt word template and the text block based on the large language model to obtain text question-answer pairs; The second generation module is used to process the table block based on the large language model, the first-stage prompt words, and the second-stage prompt words to obtain table question-answer pairs; The integration module is used to perform intra-group association of the text question-answer pairs and the table question-answer pairs based on the text table association block and the association mapping table to obtain a structured question-answer pair dataset.
9. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the steel industry document question-and-answer pair extraction method as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the steel industry document question-and-answer pair extraction method as described in any one of claims 1 to 7.
