Image-based question segmentation method, apparatus, device, and storage medium
By acquiring the text blocks and detection box coordinates of the test question image, and combining semantic relevance to adjust the sorting and grouping model, the problem of low accuracy in individual test question segmentation is solved, achieving efficient and accurate test question segmentation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HANGZHOU ZHIJUAN PLANET TECHNOLOGY CO LTD
- Filing Date
- 2026-05-26
- Publication Date
- 2026-06-26
AI Technical Summary
Existing technologies suffer from low accuracy in individual question segmentation when test question layout is complex, which can easily lead to reading order disorder, question fragmentation, and the need for manual intervention, resulting in low efficiency and high error rate.
By acquiring the target test question image, extracting text blocks and detection box coordinates, adjusting the sorting based on semantic relevance, using a grouping model to group text blocks, and retaining the last group in the cache queue to prevent test questions from breaking across pages, the segmentation window is dynamically adjusted.
It improves the accuracy and efficiency of individual question segmentation, avoids manual correction, adapts to different layout styles, and ensures that the segmentation results conform to human reading habits.
Smart Images

Figure CN122290130A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to an image-based method, apparatus, device, and storage medium for individualizing test questions. Background Technology
[0002] Test question digitization refers to the process of inputting test questions from teaching materials (such as workbooks and test papers) into a database. After digitization, the test questions in the database can be reorganized according to actual needs to obtain various different test question sets. For example, test questions can be recombined according to students or teaching plans to form test booklets or test papers that are more suitable for the current teaching scenario.
[0003] When digitizing test questions, the first step is to segment the questions into individual units. This segmentation involves breaking down multiple questions in teaching materials into separate, independent units. Currently, some technologies primarily use models or blank area detection methods for this segmentation. These techniques are only suitable for simple question layouts. When the layout is complex (e.g., mixed text and images, irregular layouts, or questions spanning multiple pages), the accuracy of individual unit segmentation is low, requiring manual segmentation or manual splicing and proofreading of questions spanning multiple pages, which is inefficient. Therefore, a method to improve the accuracy of individual unit segmentation is urgently needed. Summary of the Invention
[0004] This application provides an image-based method, apparatus, computer device, and readable storage medium for individual test item segmentation, which achieves the technical effect of improving the accuracy of individual test item segmentation.
[0005] To achieve the above objectives, the main technical solutions adopted in this application include: In a first aspect, embodiments of this application provide an image-based method for individualizing test questions, the method comprising: Acquire a target test question image to be processed, wherein the target test question image includes at least one test question; Extract text blocks and the coordinates of the detection boxes of the text blocks from the target test question image; Based on the coordinates of the detection box, the text blocks are sorted to obtain the first sorting queue; Based on the semantic relationships between text blocks, the order of text blocks in the first sorting queue is adjusted to obtain the second sorting queue; The text blocks in the second sorting queue are loaded into the cache queue of the grouping model. The grouping model is used to divide the text blocks belonging to the same question in the cache queue into a group and output the first grouping result. Based on the semantic relationship between adjacent groups, the first group result is verified, and if the verification passes, the text block in the last group is retained in the cache queue, and other text blocks outside the last group are deleted; The next test question image is obtained after the target test question image, and the sorted text blocks extracted from the next test question image are loaded into the cache queue, so that the grouping model outputs a second grouping result based on the text blocks of the next test question image and the retained text blocks in the cache queue; Based on the grouping results, the individual item segmentation results are obtained.
[0006] Secondly, embodiments of this application provide a test item segmentation device, the device comprising: An image acquisition module is used to acquire a target test question image to be processed, wherein the target test question image includes at least one test question; An extraction module is used to extract text blocks and the coordinates of the detection boxes of the text blocks from the target test question image; The sorting module is used to sort the text blocks according to the coordinates of the detection box to obtain a first sorting queue; The adjustment module is used to adjust the order of text blocks in the first sorting queue based on the semantic relationship between text blocks to obtain a second sorting queue. The first grouping module is used to load text blocks from the second sorting queue into the cache queue of the grouping model. The grouping model is used to divide text blocks belonging to the same question in the cache queue into a group and output the first grouping result. The cache management module is used to verify the first group result based on the semantic relationship between adjacent groups, and if the verification passes, retain the text block in the last group in the cache queue and delete other text blocks outside the last group. The second grouping module is used to obtain the next test question image after the target test question image, and load the sorted text blocks extracted from the next test question image into the cache queue, so that the grouping model outputs the second grouping result based on the text blocks of the next test question image and the retained text blocks in the cache queue; The results generation module is used to obtain the individualized segmentation results of test items based on the grouping results.
[0007] Thirdly, embodiments of this application provide a computer device, including: The memory and the processor are communicatively connected, the memory stores computer instructions, and the processor executes the computer instructions to perform the image-based question segmentation method as described in any of the preceding claims.
[0008] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer instructions that cause a computer to perform the image-based question segmentation method as described in any of the preceding claims.
[0009] In some embodiments of this application, the technical solutions firstly sort the text blocks according to the coordinates of the detection boxes, and then adjust the order of the text blocks based on the semantic correlation between them. This improves the accuracy of text block sorting, prevents semantic jumps between text blocks, and ensures that the sorting of text blocks conforms to human reading habits. Secondly, text blocks in the last group are retained in the cache queue, and grouped based on the text blocks of the next question image and the retained text blocks in the cache queue. This prevents question breakage due to question spanning multiple pages, eliminating the need for manual correction. Finally, by grouping text blocks using a grouping model, the model can learn the features of text blocks belonging to the same question, dynamically adjust the text block grouping logic and segmentation window, etc., without requiring manual parameter setting. Thus, while improving the efficiency of question individualization segmentation, it also overcomes the problem of inaccurate segmentation caused by rigid question individualization segmentation logic and fixed segmentation windows in some other technologies. Based on the above aspects, the method of this application can improve the accuracy and efficiency of question individualization segmentation. Attached Figure Description
[0010] To more clearly illustrate the technical solutions in the specific embodiments of this application or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0011] Figure 1 A first test question layout diagram provided for some embodiments of this application; Figure 2 A second test question layout diagram provided for some embodiments of this application; Figure 3 A flowchart illustrating a test item segmentation method provided for some embodiments of this application; Figure 4 A schematic diagram illustrating a first typesetting method provided for some embodiments of this application; Figure 5 A schematic diagram illustrating a second typesetting method provided for some embodiments of this application; Figure 6 A schematic diagram illustrating a third typesetting method provided for some embodiments of this application; Figure 7A schematic diagram illustrating a fourth typesetting method provided for some embodiments of this application; Figure 8 for Figure 7 A diagram illustrating the text block cache queue in the image; Figure 9 A schematic diagram illustrating the association between different test question images provided for some embodiments of this application; Figure 10 for Figure 9 A diagram illustrating the text block of the next question image in the test, after it has been loaded into the cache queue; Figure 11 A schematic diagram of the question individualization segmentation process of the question individualization segmentation system provided for some embodiments of this application; Figure 12 Schematic diagram of a test item individualization and segmentation device provided for some embodiments of this application; Figure 13 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0012] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of 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, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0013] Currently, the following problems still exist in some digital test technology: 1) The logic of individual question segmentation is rigid and lacks adaptability. For example, some individual question segmentation logics determine whether the spacing between two lines of text reaches a preset fixed value. If so, the two lines of text are considered to belong to different questions; otherwise, they are considered to belong to the same question. Based on this rigid individual question segmentation logic, the resulting individual question segmentation is inaccurate and has low precision when the question layout is diverse, irregular, or the font / spacing is inconsistent.
[0014] 2) Relying solely on the coordinate sorting of text detection boxes for individual question segmentation. In complex layout scenarios such as semantic line breaks, cross-regional questions, and mixed text and images, this segmentation method can easily lead to reading order confusion. For example, when combined with references... Figure 1 This is a schematic diagram of the first test question layout provided for some embodiments of this application. Figure 1In this scenario, the test questions are located within a workbook. The question stem is divided into an upper and lower section, with options A and B interspersed between them. To segment the test questions into individual units, the workbook pages can be scanned to obtain the question images. Then, based on OCR (Optical Character Recognition) technology, the images can be generated. Figure 1 The dashed box indicates that the text detection box divides the text region in the test question image into multiple sub-regions and extracts the text blocks and text detection box coordinates of each sub-region. Based on the text detection box coordinates, the text blocks are sorted to obtain the following text content: 1. The total number of apples and pears is 20.
[0015] A. The number of pears is 10. B. The number of pears is 5. If the number of apples is 15, find the number of pears.
[0016] Clearly, this text suffers from semantic skipping and a disordered reading order. The correct reading order should be: The total number of apples and pears is 20. If the number of apples is 15, find the number of pears.
[0017] A. The number of pears is 10. B. The number of pears is 5. 3) Segmenting questions using a fixed dividing window. This method easily divides the same question into multiple questions or merges multiple questions into a single question. For example, assuming the dividing window is 200 characters, if question a has 400 characters, it will be divided into two questions. If question b has 50 characters and question c has 60 characters, they will be merged into a single question.
[0018] 4) When the same question spans two pages, a question breakage issue may occur, requiring manual intervention to adjust. For example, when referring to... Figure 2 This is a second test question layout diagram provided for some embodiments of this application. Figure 2In this scenario, suppose the question stem is located on page 1 of a workbook, and the options are located on page 2. When digitizing the questions, images P1 (page 1) and P2 (page 2) can be obtained through scanning. Then, using OCR technology, images P1 and P2 can be segmented independently into individual question units, meaning the content in images P1 and P2 is not integrated. Thus, the question stem of question a can be extracted from image P1 as question a1, and the options of question a can be extracted from image P2 as question a2. In the database, questions a1 and a2 are stored as two independent questions. This results in a break in question a, requiring manual splicing of questions a1 and a2.
[0019] 5) Before digitizing test questions, manual parameter setting is relied upon, which is inefficient and has a high error rate. Specifically, manual parameter setting refers to staff manually identifying features such as the layout and spacing of each test question image, and then manually setting parameters such as the layout format and spacing in the test question digitization system. After the test question images are input into the digitization system, the system performs individual question segmentation based on the set parameters. This method is inefficient and has a high error rate. For example, when digitizing millions of test questions, if the layout and spacing of the test questions are different between images, parameter setting is required before inputting each image into the digitization system, resulting in low efficiency. In addition, manual parameter setting is prone to errors, leading to inaccurate individual question segmentation and a high error rate.
[0020] Based on the above description, some current test item digitization technologies suffer from problems such as fragmented test items, disordered reading order, and low accuracy in individual item segmentation. Furthermore, they also exhibit poor adaptability and low efficiency.
[0021] Therefore, this application provides an image-based question segmentation method that can improve the accuracy and efficiency of question segmentation. This question segmentation method can be applied to electronic devices, including but not limited to tablets, desktop computers, laptops, and servers. (See also...) Figure 3 This is a flowchart illustrating a test item segmentation method provided in some embodiments of this application. Figure 3 In this paper, the method for segmenting test items into individual units includes the following steps: Step S301: Obtain the target test question image to be processed. The target test question image includes at least one test question.
[0022] Specifically, the target test question image can be a partial image of a test question from supplementary teaching materials. For example, an image of a specific page in a workbook, or a front or back image of a test paper.
[0023] In practical applications, if the teaching materials are in print or other non-electronic formats, the target test question images can be obtained by taking photos or scanning them. If the teaching materials are in electronic format, the target test question images can be obtained by taking screenshots, exporting the page, etc. The test questions in the target test question images can include text, tables, question images, etc.
[0024] In addition to the test questions, the target test question image may also include non-test question content such as answer instructions, answer requirements, and score descriptions.
[0025] Step S302: Extract the text block and the coordinates of the detection box of the text block from the target test question image.
[0026] Specifically, for the text region in the target test question image, the text region can be divided into multiple sub-regions, and the text content in each sub-region can be used as a text block. For example, assuming the text content in sub-region A1 is "Please solve the following equation", then the text block extracted from sub-region A1 is "Please solve the following equation".
[0027] For non-text areas in the target test question image, these areas can be divided into multiple sub-regions. Text blocks are generated based on the content of each sub-region. The non-text areas include at least one of image areas and table areas, and the text blocks describe the content of each sub-region. Based on these text blocks, the content of each sub-region can be recovered. For example, assuming sub-region A2 contains two circles of different sizes, the text block extracted from sub-region A2 can include: the radii of the two circles and the coordinates of their centers in the target test question image. Thus, based on the text blocks of sub-region A2, the circles in sub-region A2 can be recovered.
[0028] For any sub-region, after extracting a text block from it, the bounding box coordinates of that sub-region can be used as the detection box coordinates of the corresponding text block. Here, the bounding box coordinates refer to the coordinates of the bounding box of the sub-region within the target test question image. For example, after extracting text block D1 from sub-region A1, the bounding box coordinates of sub-region A1 can be used as the detection box coordinates of text block D1. In this way, based on the detection box coordinates, the position of each text block can be located.
[0029] Based on the coordinates of the detection boxes of each text block, the relative positional relationship of text, images, and tables in the target test question image can be analyzed, thereby ensuring the accuracy of subsequent test question individual segmentation.
[0030] Step S303: Sort the text blocks according to the coordinates of the detection boxes to obtain the first sorting queue.
[0031] In this embodiment, the layout of the target test question image can be determined based on the distribution characteristics of the detection box coordinates. Based on the layout, the text blocks can be sorted to obtain a first sorting queue. The layout can include, but is not limited to, single-column layout, two-column layout, multi-column layout, mixed text and image layout, horizontal layout, and vertical layout.
[0032] For ease of understanding, please refer to the following: Figure 4 This is a schematic diagram illustrating a first typesetting method provided for some embodiments of this application. Figure 4 The layout is a two-column format. The detection box coordinates in a two-column layout have the following distribution characteristics: the detection box coordinates are distributed in the left and right regions of the question image, while the middle region of the two columns may not contain detection box coordinates. Simultaneously, within each column, the detection box coordinates on the left side (i.e., the region containing the question number in each column) are relatively aligned, and the spacing between questions can be greater than the text line spacing within the same question.
[0033] If the coordinates of the detection box in the target test question image exist in a similar way... Figure 4 The distribution characteristics shown indicate that the target test question image is a two-column layout. In a two-column layout, the test questions are typically arranged from the left column to the right column, and within each column, the questions are arranged from top to bottom. Based on the test question layout characteristics of a two-column layout, Figure 4 The initial sorting of the text blocks can be: text block D1>text block D3>text block D5>text block D7>text block D2>text block D4>text block D6>text block D8.
[0034] See also Figure 5 This is a schematic diagram illustrating a second typesetting method provided for some embodiments of this application. Figure 5 In the image, the layout is a single-column layout. The detection box coordinates of the single-column layout have the following distribution characteristics: the left side of the image can have more detection box coordinates, the right side can have fewer detection box coordinates, and the detection box coordinates in the left side can be relatively aligned.
[0035] If the coordinates of the detection box in the target test question image exist in a similar way... Figure 5 The distribution characteristics shown indicate that the target test question image is a single-column layout. In a single-column layout, the test questions are arranged sequentially from top to bottom. Based on the characteristics of single-column test question layout, Figure 5 The initial sorting of the text blocks can be: text block D1>text block D2>text block D3>text block D4>text block D5>text block D6>text block D7>text block D8.
[0036] Step S304: Based on the semantic relationship between text blocks, adjust the order of text blocks in the first sorting queue to obtain the second sorting queue.
[0037] Specifically, when the layout of the target test question image is complex, relying solely on the detection box coordinates in step S303 may lead to sorting errors. For example, referring to... Figure 6 This is a schematic diagram illustrating a third typesetting method provided in some embodiments of this application. From Figure 6 It can be seen that the top area of the target test question image is a single-column layout, but the area below the top area is a two-column layout. Under this layout, based on the detection box coordinate distribution features in step S303, the layout may be determined to be a two-column layout, resulting in the initial text block order as: text block D1>text block D3>text block D5>text block D7>text block D9>text block D11>text block D2>text block D4>text block D6>text block D8>text block D10>text block D12. In this order, text blocks D1, D3, and D5 are arranged together, but their semantics are not coherent. Similarly, text blocks D2, D4, and D6 are arranged together, but their semantics are also not coherent. At the same time, text blocks D1 to D4 are semantically coherent sentences, but in this order, text blocks D1 to D4 are not arranged in adjacent positions. Therefore, in step S304, the order of text blocks in the first sorting queue can be fine-tuned based on the semantic relationships between text blocks, so that the semantics between text blocks in the resulting second sorting queue are coherent, thereby preventing the problem of text block sorting errors. For example, in step S304, the text blocks can be sorted... Figure 6 The text blocks are sorted as follows: text block D1>text block D2>text block D3>text block D4>text block D5>text block D7>text block D9>text block D11>text block D6>text block D8>text block D10>text block D12.
[0038] Step S305: Load the text blocks in the second sorting queue into the cache queue of the grouping model. The grouping model is used to divide the text blocks belonging to the same question in the cache queue into a group and output the first grouping result.
[0039] Specifically, when loading text blocks into the grouping model's cache queue, they need to be sorted according to the text blocks in the second sorting queue, and then loaded into the cache queue sequentially. In other words, the sorting of text blocks in the cache queue needs to be the same as the sorting of text blocks in the second sorting queue. This maintains the semantic coherence between text blocks. It can be understood that after the sorting in step S304, text blocks of the same question should be in adjacent positions in the cache queue.
[0040] The grouping model is a pre-trained large language model that can filter out target text blocks belonging to the test questions from the cache queue, and then group text blocks belonging to the same test question into a group based on the semantic correlation between adjacent text blocks.
[0041] For ease of understanding, please refer to the following: Figure 7 and Figure 8 . Figure 7 A schematic diagram illustrating a fourth typesetting method provided for some embodiments of this application. Figure 8 for Figure 7 A diagram illustrating the text block cache queue. The grouping model is based on... Figure 8 The cache queue shown can filter text blocks D5 to D12 as target text blocks. Among the target text blocks D5 to D12, since text blocks D5 and D6 have a relatively high semantic correlation, while text blocks D6 and D7 have a relatively low semantic correlation, text blocks D5 and D6 can be grouped together, indicating that text blocks D5 and D6 belong to the same question. Following a similar principle, the grouping model can output a total of four groups: (D5, D6), (D7, D8), (D9, D10), and (D11, D12). Each group of text blocks can constitute a question. Thus, the individualized segmentation of questions is achieved.
[0042] Step S306: Based on the semantic relationship between adjacent groups, the result of the first group is verified, and if the verification passes, the text block in the last group is retained in the cache queue, and other text blocks outside the last group are deleted.
[0043] In this embodiment, the text blocks of each group can be input into the trained verification model. The verification model outputs a verification result representing whether the verification passed or failed through semantic analysis. Specifically, in the groups obtained in step S305, if there is a group whose text blocks do not belong to the same test question, the verification fails. Otherwise, the verification passes.
[0044] If the validation of the first grouping result fails, the first grouping result can be deleted, while all text blocks in the cache queue are retained. Then, the text blocks in the cache queue are regrouped to correct the first grouping result. This further improves the grouping accuracy.
[0045] If the validation of the first group result passes, the results of all other groups except the last group can be saved. The text blocks from the last group are retained in the cache queue, and all other text blocks except the last group are deleted. The last group refers to the last group at the end of the cache queue. For example, Figure 8D11 and D12 can be considered as end groups. The text blocks in the end groups may have semantic relevance to the text blocks in the next question image. The next question image is the question image located after the target question image. For example, the target question image could be the question image on page 1 of the workbook, and the next question image could be the question image on page 2 of the workbook.
[0046] For ease of understanding, please refer to the following: Figure 9 This is a schematic diagram illustrating the relationship between different test question images provided in some embodiments of this application. Figure 9 As can be seen, after loading the text blocks from the target question image into the cache queue, the grouping model can output a total of 5 groups: (D5, D6), (D7, D8), (D9, D10), (D11, D12), and (D13). The final group (D13) contains only one text block, D13, and this text block D13, together with the text block D14 from the next question image, forms a single question; that is, text blocks D13 and D14 are semantically related. Logically, text blocks D13 and D14 should be grouped into the same group, but since text block D14 is located in the next question image, the group (D13, D14) cannot be obtained solely based on the text blocks from the target question image. Therefore, text block D13 from the final group can be retained in the cache queue so that after the text blocks from the next question image are loaded into the cache queue, text block D13 can be grouped with the text blocks from the next question image, thus obtaining the complete question group (D13, D14). Meanwhile, the text blocks in other groups (D5,D6), (D7,D8), (D9,D10), and (D11,D12) are no longer missing, so these text blocks can be deleted from the cache queue. Additionally, non-question text blocks (such as D1–D4) can also be deleted from the cache queue. Thus, after grouping the target question image, the cache queue only contains the text blocks of the last group.
[0047] Step S307: Obtain the next test question image after the target test question image, and load the sorted text blocks extracted from the next test question image into the cache queue, so that the grouping model can output the second grouping result based on the text blocks of the next test question image and the retained text blocks in the cache queue.
[0048] Specifically, the text blocks of the next test question image can be extracted and sorted in a similar way to the target test question image, and the sorted text blocks can be loaded into the cache queue.
[0049] See also Figure 10 ,for Figure 9 This is a diagram illustrating the text block of the next question image after it has been loaded into the cache queue. From Figure 10As can be seen, because the last group (D13) of the target question image remains in the cache queue, text block D13 in the target question image and text blocks D14 to D20 in the next question image form a new text block cache queue. Based on this new text block cache queue, the grouping model can group text blocks D13 and D14 together. This can solve the question breakage problem that occurs when questions span multiple pages in some technologies.
[0050] Step S308: Based on the grouping results, obtain the individual item segmentation results.
[0051] Specifically, for any given test question image, after removing the last group from the text block groups of the test question image, the remaining groups can be used as the single-item segmentation result extracted from the test question image. For example, using... Figure 9 For example, in the target test question image, group (D5,D6), (D7,D8), (D9,D10), (D11,D12), and (D13), group (D13) can be removed, and group (D5,D6), (D7,D8), (D9,D10), and (D11,D12) can be used as the test question individual segmentation result extracted from the target test question image.
[0052] A test question can be constructed based on the text blocks in each group. When a test question includes an image or table, the groups for that test question can include text blocks describing the image or table. Based on these text blocks, the image or table can be recovered, and thus the test question can be constructed.
[0053] In summary, in the technical solutions of some embodiments of this application, firstly, after sorting the text blocks according to the coordinates of the detection boxes, the order of the text blocks is adjusted based on the semantic correlation between them. This can improve the accuracy of text block sorting, prevent semantic jumps between text blocks, and ensure that the sorting of text blocks conforms to human reading habits. Secondly, retaining the text blocks in the last group in the cache queue, and grouping them based on the text blocks of the next question image and the retained text blocks in the cache queue, can prevent the question breakage problem caused by question spanning pages, without the need for manual correction. Finally, grouping text blocks through a grouping model allows the grouping model to learn the features of text blocks belonging to the same question, dynamically adjust the text block grouping logic and segmentation window, etc., without the need for manual parameter setting. Thus, while improving the efficiency of question individual segmentation, it can also overcome the problem of inaccurate segmentation caused by rigid question individual segmentation logic and fixed segmentation windows in some technologies. Based on the above aspects, the method of this application can improve the accuracy and efficiency of question individual segmentation.
[0054] In some embodiments, loading text blocks from the second sorting queue into the cache queue of the grouping model includes: The total number of tokens is determined based on the total length of the text blocks in the second sorting queue. If the total number of tokens is greater than the maximum number of tokens allowed by the grouping model, then based on the maximum number of tokens, the first number of text blocks are extracted from the second sorting queue and loaded into the cache queue. Remove text blocks that have been loaded into the cache queue from the second sorting queue, and determine the number of remaining tokens based on the remaining text blocks in the second sorting queue; If the remaining number of tokens is greater than the maximum number of tokens allowed by the grouping model, then continue to extract the second number of text blocks from the second sorting queue based on the maximum number of tokens, and load the second number of text blocks into the cache queue; If the number of remaining tokens is not greater than the maximum number of tokens allowed by the grouping model, then all remaining text blocks in the second sorting queue will be loaded into the cache queue.
[0055] The total text length refers to the number of texts included in the second sorting queue. The total text length can be determined based on the total number of text blocks in the second sorting queue and the number of texts in each text block. There can be a conversion relationship between the total text length and the number of tokens. For example, 3 texts equal 1 token. Based on this conversion relationship, the total number of tokens in the second sorting queue can be obtained.
[0056] If the total number of tokens exceeds the maximum number of tokens allowed by the grouping model, the text blocks in the second sorting queue can be divided into multiple batches, and the text blocks can be loaded into the cache queue in batches. Conversely, if the total number of tokens does not exceed the maximum number of tokens, all text blocks in the second sorting queue can be loaded into the cache queue at once.
[0057] Among them, loading text blocks into the cache queue in batches means loading the text blocks of the previous batch into the cache queue, and after the grouping model completes the grouping of the text blocks of the previous batch, loading the text blocks of the next batch into the cache queue.
[0058] Specifically, when loading text blocks from the second sorting queue into the cache queue in batches, the number of text blocks that the cache queue can hold can be determined based on the maximum number of tokens allowed by the grouping model and the number of text blocks included in each text block in the second sorting queue. Then, according to the determined number of text blocks, the corresponding number of text blocks are extracted from the second sorting queue into the cache queue. After each batch of text blocks is extracted, the remaining text length in the second sorting queue can be calculated based on the remaining text blocks in the second sorting queue, and the remaining text length can be converted into the remaining number of tokens. If the remaining number of tokens is greater than the maximum number of tokens allowed by the grouping model, the remaining text blocks are continued to be loaded into the cache queue in batches. If the remaining number of tokens is not greater than the maximum number of tokens allowed by the grouping model, all remaining text blocks in the second sorting queue can be loaded into the cache queue at once.
[0059] It should be noted that since different text blocks may contain different amounts of text, the number of text blocks in different batches may also be different. That is, the first and second quantities mentioned above may be different.
[0060] In the above embodiments, on the one hand, when the number of tokens corresponding to the second sorting queue is greater than the maximum number of tokens allowed by the grouping model, controlling the number of text blocks that can be cached in the cache queue based on the maximum number of tokens can ensure the inference accuracy of the grouping model, thereby ensuring the grouping accuracy of text blocks. On the other hand, when the number of tokens corresponding to the second sorting queue is not greater than the maximum number of tokens allowed by the grouping model, loading all text blocks in the second sorting queue into the cache queue can improve the grouping efficiency of text blocks. That is, it is possible to ensure both the grouping accuracy and grouping efficiency of text blocks.
[0061] In some embodiments, when loading text blocks from the second sorting queue into the cache queue in batches, the above-mentioned retention of text blocks in the last group and deletion of other text blocks outside the last group in the cache queue includes: After the grouping model completes the grouping of the first number of text blocks, it retains the text blocks in the last group in the cache queue and deletes other text blocks outside the last group. After the remaining text blocks in the second sorting queue are loaded into the cache queue, the grouping model continues to group based on the remaining text in the second sorting queue and the retained text blocks in the cache queue.
[0062] Specifically, after the text blocks in the second sorting queue are divided into multiple batches, retaining the last grouped text blocks of each batch in the cache queue can prevent questions from breaking within the same question image. For example, refer to... Figure 9 Suppose that in the target question image, text blocks D1–D7 are divided into the first batch, and text blocks D8–D13 are divided into the second batch. If the last group of text blocks (D7) from the first batch is not retained in the cache queue, the stem and options of question 2 will be divided into two groups, resulting in question fragmentation. Conversely, if the last group of text blocks (D7) from the first batch is retained in the cache queue, then after loading the text blocks from the second batch into the cache queue, the stem and options of question 2 can be divided into the same group, thus improving the accuracy of question segmentation.
[0063] It should be noted that when retaining the last group of text blocks from the previous batch in the cache queue, the number of text blocks in the next batch can be determined as follows: Determine the number of tokens corresponding to the last group of text blocks in the previous batch; The target number of tokens is obtained by subtracting the number of tokens corresponding to the last group of text blocks in the previous batch from the maximum number of tokens allowed by the grouping model. The number of text blocks in the next batch is determined based on the target token count.
[0064] This is to prevent the number of tokens in the cache queue from exceeding the maximum number of tokens allowed by the grouping model.
[0065] In some embodiments, before the grouping model performs text block grouping, the method of this application further includes: Obtain the attribute characteristics of the test questions; Based on the characteristics of the test items, prompt words are constructed and input into the grouping model so that the grouping model can group the text blocks in the cache queue based on the characteristics of the test items.
[0066] Specifically, the attribute features of test questions can include the starting features and structure of the questions. For example, assuming that each question starts with an Arabic numeral and each question includes two options, then the prompt phrase "the questions start with Arabic numerals and each question includes two options" can be constructed. After inputting this prompt phrase into the grouping model, the grouping model can use this prompt phrase as a reference, thereby improving the accuracy of text block grouping.
[0067] In some embodiments, each text block has a text block identifier; the method of this application further includes: For any text block, concatenate the text block, the coordinates of the detection box of the text block, and the text block identifier to obtain the first concatenated content of the text block; The first concatenated content of multiple text blocks is input into the sorting model, so that the sorting model outputs the first sorting result of the text block identifiers based on the detection box coordinates, which serves as the first sorting queue; For any text block, concatenate the text block and its identifier to obtain the second concatenated content of the text block; According to the text block order of the first sorting queue, the second concatenation content of each text block is input into the adjustment model so that the adjustment model outputs the second sorting result of the text block identifier, which is used as the second sorting queue; Following the text block order of the second sorting queue, the second concatenation content of each text block is input into the grouping model so that the grouping model outputs the grouping result of the text block identifier as the grouping result of the text block.
[0068] Specifically, the ranking and adjustment models can be the trained large language model. After inputting the text block identifiers and their concatenated contents into the model, the model can be prompted to rank them based on the text block identifiers. For example, assuming the text block identifiers of text blocks D1 to D7 are 1, 2, 3, 4, 5, 6, and 7 respectively, the ranking result of text blocks D1 to D7 can be represented as 1>3>2>7>4>5>6. In this way, the model can be prevented from modifying the text blocks during the ranking process.
[0069] See also Figure 11 This is a schematic diagram of the test item segmentation process of a test item segmentation system provided in some embodiments of this application. Figure 11 The test item segmentation system comprises an image preprocessing module, a ranking model, an adjustment model, a buffer queue, and a grouping model. The image preprocessing module extracts text blocks and their bounding box coordinates from the test item images. The ranking model sorts the text blocks based on their bounding box coordinates, outputting a first ranked queue to the adjustment model. The adjustment model adjusts the order of text blocks in the first ranked queue based on semantic relationships between them, obtaining a second ranked queue, and then loads the text blocks from the second ranked queue into the buffer queue. The grouping model groups the text blocks in the buffer queue and outputs the grouping results for each test item image.
[0070] In practical applications, multiple test question images P1 to Pn can be obtained from teaching materials, and each test question image can be input into the individual test question segmentation system in the order they appear. The individual test question segmentation system can automatically segment each test question image without manual intervention and can avoid problems such as broken test questions and segmentation errors.
[0071] Corresponding to the method, this application also provides an image-based test item segmentation device. (See also...) Figure 12 This is a schematic diagram of a test question segmentation device provided in some embodiments of this application. The test question segmentation device includes: Image acquisition module 121 is used to acquire a target test question image to be processed, the target test question image including at least one test question; Extraction module 122 is used to extract text blocks and the coordinates of the detection boxes of the text blocks from the target test question image; The sorting module 123 is used to sort the text blocks according to the coordinates of the detection box to obtain the first sorting queue; The adjustment module 124 is used to adjust the order of text blocks in the first sorting queue according to the semantic relationship between text blocks to obtain the second sorting queue; The first grouping module 125 is used to load text blocks from the second sorting queue into the cache queue of the grouping model. The grouping model is used to divide text blocks belonging to the same question in the cache queue into a group and output the first grouping result. The cache management module 126 is used to verify the result of the first group based on the semantic relationship between adjacent groups, and if the verification passes, to retain the text block in the last group in the cache queue and delete other text blocks outside the last group. The second grouping module 127 is used to obtain the next test question image after the target test question image, and load the sorted text blocks extracted from the next test question image into the cache queue, so that the grouping model outputs the second grouping result based on the text blocks of the next test question image and the retained text blocks in the cache queue; The result generation module 128 is used to obtain the individualized segmentation results of the test items based on the grouping results.
[0072] In some embodiments, the extraction module 122 is specifically used for: For the non-text area in the target test question image, the non-text area is divided into multiple sub-regions, and text blocks are generated based on the content of each sub-region. The text blocks are used to describe the content of the sub-regions, and the non-text area includes at least one of the image area and the table area. For the text region in the target test question image, the text region is divided into multiple sub-regions, and the text content in each sub-region is taken as a text block.
[0073] In some embodiments, the first grouping module 125 is further configured to: The total number of tokens is determined based on the total length of the text blocks in the second sorting queue. If the total number of tokens is greater than the maximum number of tokens allowed by the grouping model, then based on the maximum number of tokens, the first number of text blocks are extracted from the second sorting queue and loaded into the cache queue. Remove text blocks that have been loaded into the cache queue from the second sorting queue, and determine the number of remaining tokens based on the remaining text blocks in the second sorting queue; If the remaining number of tokens is greater than the maximum number of tokens allowed by the grouping model, then continue to extract the second number of text blocks from the second sorting queue based on the maximum number of tokens, and load the second number of text blocks into the cache queue; If the number of remaining tokens is not greater than the maximum number of tokens allowed by the grouping model, then all remaining text blocks in the second sorting queue will be loaded into the cache queue.
[0074] In some embodiments, the cache management module 126 is further configured to: After the grouping model completes the grouping of the first number of text blocks, it retains the text blocks in the last group in the cache queue and deletes other text blocks outside the last group. After the remaining text blocks in the second sorting queue are loaded into the cache queue, the grouping model continues to group based on the remaining text in the second sorting queue and the retained text blocks in the cache queue.
[0075] In some embodiments, if the validation of the first grouping result fails, the cache management module 126 is further configured to: Delete the first group result and retain all text blocks in the cache queue; The text blocks in the cache queue are regrouped to correct the results of the first grouping.
[0076] In some embodiments, before the grouping model groups text blocks, the first grouping module 125 is further configured to: Obtain the attribute characteristics of the test questions; Based on the characteristics of the test items, prompt words are constructed and input into the grouping model so that the grouping model can group the text blocks in the cache queue based on the characteristics of the test items.
[0077] In some embodiments, each text block has a text block identifier; The sorting module 123 is specifically used to concatenate the text block, the detection box coordinates of the text block, and the text block identifier for any text block to obtain the first concatenated content of the text block, and input the first concatenated content of multiple text blocks into the sorting model so that the sorting model outputs the first sorting result of the text block identifier based on the detection box coordinates, as the first sorting queue; The adjustment module 124 is specifically used to concatenate the text block and the text block identifier of any text block to obtain the second concatenated content of the text block, and input the second concatenated content of each text block into the adjustment model according to the text block order of the first sorting queue, so that the adjustment model outputs the second sorting result of the text block identifier as the second sorting queue; The first grouping module 125 is specifically used to input the second concatenation content of each text block into the grouping model according to the text block order of the second sorting queue, so that the grouping model outputs the grouping result of the text block identifier as the grouping result of the text block.
[0078] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0079] In this embodiment, the test item segmentation device is presented in the form of a functional unit. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.
[0080] Please see Figure 13 , Figure 13 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application, such as... Figure 13 As shown, the computer device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 13 Take a processor 10 as an example.
[0081] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GPA), or any combination thereof.
[0082] The memory 20 stores instructions executable by at least one processor 10 to cause the at least one processor 10 to perform the method shown in the above embodiments.
[0083] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the computer device. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0084] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0085] This application provides a computer program product including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the method of any embodiment of this application.
[0086] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. An image-based question segmentation method, characterized in that, The method includes: Acquire a target test question image to be processed, wherein the target test question image includes at least one test question; Extract text blocks and the coordinates of the detection boxes of the text blocks from the target test question image; Based on the coordinates of the detection box, the text blocks are sorted to obtain the first sorting queue; Based on the semantic relationships between text blocks, the order of text blocks in the first sorting queue is adjusted to obtain the second sorting queue; The text blocks in the second sorting queue are loaded into the cache queue of the grouping model. The grouping model is used to divide the text blocks belonging to the same question in the cache queue into a group and output the first grouping result. Based on the semantic relationship between adjacent groups, the first group result is verified, and if the verification passes, the text block in the last group is retained in the cache queue, and other text blocks outside the last group are deleted; The next test question image is obtained after the target test question image, and the sorted text blocks extracted from the next test question image are loaded into the cache queue, so that the grouping model outputs a second grouping result based on the text blocks of the next test question image and the retained text blocks in the cache queue; Based on the grouping results, the individual item segmentation results are obtained.
2. The method according to claim 1, characterized in that, Extracting text blocks from the target test question image includes: For the non-text area in the target test question image, the non-text area is divided into multiple sub-regions, and a text block is generated based on the content of each sub-region. The text block is used to describe the content of the sub-region, and the non-text area includes at least one of the image area and the table area. For the text region in the target test question image, the text region is divided into multiple sub-regions, and the text content in each sub-region is taken as a text block.
3. The method according to claim 1, characterized in that, The step of loading text blocks from the second sorting queue into the cache queue of the grouping model includes: The total number of tokens is determined based on the total length of the text blocks in the second sorting queue. If the total number of tokens is greater than the maximum number of tokens allowed by the grouping model, then based on the maximum number of tokens, a first number of text blocks are extracted from the second sorting queue, and the first number of text blocks are loaded into the cache queue; Remove the text blocks that have been loaded into the cache queue from the second sorting queue, and determine the number of remaining tokens based on the remaining text blocks in the second sorting queue; If the remaining number of tokens is greater than the maximum number of tokens allowed by the grouping model, then based on the maximum number of tokens, a second number of text blocks are extracted from the second sorting queue, and the second number of text blocks are loaded into the cache queue; If the number of remaining tokens is not greater than the maximum number of tokens allowed by the grouping model, then all remaining text blocks in the second sorting queue are loaded into the cache queue.
4. The method according to claim 3, characterized in that, The step of retaining text blocks in the end group of the cache queue and deleting other text blocks outside the end group includes: After the grouping model completes the grouping of the first number of text blocks, it retains the text blocks in the last group in the cache queue and deletes other text blocks outside the last group. After the remaining text blocks in the second sorting queue are loaded into the cache queue, the grouping model continues to group based on the remaining text in the second sorting queue and the retained text blocks in the cache queue.
5. The method according to claim 1, characterized in that, If the verification of the first grouping result fails, the method further includes: Delete the first grouping result and retain all text blocks in the cache queue; The text blocks in the cache queue are regrouped to correct the first grouping result.
6. The method according to claim 1, characterized in that, Before the grouping model performs text block grouping, the method further includes: Obtain the attribute features of the test questions; Based on the test question attribute features, prompt words are constructed and input into the grouping model so that the grouping model can group the text blocks in the cache queue based on the test question attribute features.
7. The method according to claim 1, characterized in that, Each of the text blocks has a text block identifier; the method further includes: For any of the text blocks, the text block, the coordinates of the detection box of the text block, and the text block identifier are concatenated to obtain the first concatenated content of the text block; The first concatenated content of multiple text blocks is input into the sorting model, so that the sorting model outputs the first sorting result of the text block identifier based on the detection box coordinates, which serves as the first sorting queue; For any of the text blocks, the text block and its text block identifier are concatenated to obtain the second concatenated content of the text block; According to the text block order of the first sorting queue, the second concatenation content of each text block is input into the adjustment model so that the adjustment model outputs the second sorting result of the text block identifier as the second sorting queue; According to the text block order of the second sorting queue, the second concatenation content of each text block is input into the grouping model so that the grouping model outputs the grouping result of the text block identifier as the grouping result of the text block.
8. An image-based test item segmentation device, characterized in that, The device includes: An image acquisition module is used to acquire a target test question image to be processed, wherein the target test question image includes at least one test question; An extraction module is used to extract text blocks and the coordinates of the detection boxes of the text blocks from the target test question image; The sorting module is used to sort the text blocks according to the coordinates of the detection box to obtain a first sorting queue; The adjustment module is used to adjust the order of text blocks in the first sorting queue based on the semantic relationship between text blocks to obtain a second sorting queue. The first grouping module is used to load text blocks from the second sorting queue into the cache queue of the grouping model. The grouping model is used to divide text blocks belonging to the same question in the cache queue into a group and output the first grouping result. The cache management module is used to verify the first group result based on the semantic relationship between adjacent groups, and if the verification passes, retain the text block in the last group in the cache queue and delete other text blocks outside the last group. The second grouping module is used to obtain the next test question image after the target test question image, and load the sorted text blocks extracted from the next test question image into the cache queue, so that the grouping model outputs the second grouping result based on the text blocks of the next test question image and the retained text blocks in the cache queue; The results generation module is used to obtain the individualized segmentation results of test items based on the grouping results.
9. A computer device, characterized in that, include: A memory and a processor are communicatively connected, the memory storing computer instructions, and the processor executing the computer instructions to perform the image-based test item segmentation method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to perform the image-based test item segmentation method according to any one of claims 1 to 7.