Method and system for financial numerical format verification oriented to large model output
By locating, stripping, identifying, and backfilling financial data, combined with differentiated formatting rules and compliance verification, the problem of chaotic formatting and semantic ambiguity in financial data generated by large language models has been solved, achieving high-precision financial data formatting and compliance verification.
Patent Information
- Application Number
- CN202611547399.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-08
- Publication Date
- 2026-11-06
AI Technical Summary
Financial data generated by large language models lacks a unified standard in natural language contexts, leading to format chaos and semantic ambiguity. Existing technologies struggle to achieve refined formatting and compliance verification.
By locating and extracting the text span of financial numerical values, semantic type recognition is performed, differentiated formatting rules are applied, and the text is backfilled based on the contextual skeleton. Combined with compliance review, a formatted response text is generated.
It enables differentiated and refined formatting of financial data and compliance review, ensuring that the embedded data results in complete sentence structure and semantic coherence, meeting financial compliance requirements.
Smart Images

Figure CN123048827A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of financial application technology of large language models, and more specifically, to a method and system for formatting and validating financial numerical data for large model outputs. Background Technology
[0002] With the widespread deployment of large language models in the financial field, various financial values frequently appear in the response text generated for financial query requests, including monetary amounts, interest rates, ratios, terms, and other forms. The standardization of the format of these values directly affects the accuracy of financial information transmission and regulatory compliance.
[0003] However, the raw response text generated by large models typically embeds financial numerical values into natural language contexts, presenting them in free text form. Formatting elements such as decimal separation, decimal precision, unit notation, and thousands separators often lack standardized specifications, leading to risks of formatting inconsistencies or semantic ambiguity. Existing financial text post-processing methods usually employ fixed rules based on regular expressions or keyword matching to uniformly scan and replace the entire text. These methods treat the text as an indiscriminate sequence of characters, failing to distinguish the structural differences between financial numerical values and ordinary contextual text. They also lack methods for extracting financial numerical values from the contextual text and independently performing semantic type identification and differentiated format constraints, resulting in a lack of specificity and refinement in formatting constraints for numerical values of different semantic types. Furthermore, existing technologies typically do not perform backfilling and compliance verification based on the contextual skeleton after numerical formatting, making it difficult to ensure that the formatted response text simultaneously meets financial compliance requirements in terms of numerical precision and contextual consistency. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a method and system for formatting and verifying financial numerical data for large model outputs.
[0005] According to a first aspect of this application, a method for formatting and validating financial numerical data for large model outputs is provided, the method comprising: Obtain the original response text sequence generated by the large model for the financial query request, locate and extract the text span occupied by financial values from the original response text sequence to obtain the numerical text fragment sequence and the context skeleton text sequence after extracting the values. Perform a numerical semantic type recognition operation on each numerical text fragment in the numerical text fragment sequence to obtain the numerical semantic type label corresponding to each numerical text fragment, and construct a numerical semantic type label sequence; Based on the numerical semantic type tag sequence, the formatting constraints corresponding to each numerical semantic type tag are retrieved from the preset financial formatting rule base. Based on the formatting constraints, the corresponding numerical text segments in the numerical text segment sequence are formatted and reshaped to generate a formatted numerical segment sequence. Using the contextual skeleton text sequence as the contextual constraint benchmark, the formatted numerical fragments in the formatted numerical fragment sequence are backfilled one by one into the corresponding text span range in the contextual skeleton text sequence to generate an initial formatted response text sequence; The initial formatted response text sequence is subjected to financial numerical compliance review processing to generate a review result identifier sequence. The review result identifier sequence contains a format compliance status flag for each text span interval. Based on the review result identifier sequence, the initial formatted response text sequence is determined to be a verified financial response text sequence.
[0006] According to a second aspect of this application, a formatted verification system for financial numerical data output to large model output is provided. The formatted verification system for financial numerical data output to large model output includes a machine-readable storage medium and a processor. The machine-readable storage medium stores machine-executable instructions. When the processor executes the machine-executable instructions, the formatted verification system for financial numerical data output to large model output implements the aforementioned formatted verification method for financial numerical data output to large model output.
[0007] Based on any of the above aspects, the technical effect of this application is as follows: First, the text span occupied by financial numerical values is located and extracted, separating the sequence of numerical text fragments from the extracted contextual skeleton text sequence. Then, semantic type recognition is performed on each numerical text fragment, generating a semantic type label sequence. This allows different types of financial numerical values to retrieve formatted constraints from a pre-defined rule base that precisely match their semantic characteristics, achieving differentiated and refined reshaping. Next, using the contextual skeleton text sequence as the contextual constraint benchmark, the formatted numerical fragments are backfilled one by one, ensuring the completeness of the sentence structure and semantic coherence after numerical embedding. Finally, a segment-by-segment compliance review is performed on the initial formatted response text sequence, generating a review result identifier sequence and identifying the verified financial response text sequence. This integrates numerical semantic type perception, differentiated format rule-driven approach, contextual constraint backfilling, and compliance review, improving upon the limitations of traditional fixed-rule scanning that ignores numerical semantic differences and contextual consistency, thus facilitating high-precision compliance applications of large-scale financial model outputs. Attached Figure Description
[0008] Figure 1 The diagram illustrates a flowchart of a financial numerical formatting verification method for large model outputs provided in an embodiment of this application.
[0009] Figure 2 This is a schematic diagram of a scenario involving numerical localization and contextual skeleton reconstruction of a large-scale financial response text provided in an embodiment of this application.
[0010] Figure 3 This is a schematic diagram of a scenario for financial formatting rule matching, numerical reshaping, and compliance review provided in the embodiments of this application.
[0011] Figure 4 This is a schematic diagram of the cross-modal output adaptation and formatting operation backtracking and rule adaptive evolution scenario provided in the embodiments of this application. Detailed Implementation
[0012] Figure 1 This paper illustrates a flowchart of a financial numerical formatting verification method for large model outputs provided in an embodiment of this application. The detailed steps include: Step S110: Obtain the original response text sequence generated by the large model for the financial query request, locate and extract the text span range occupied by financial values from the original response text sequence, and obtain the numerical text fragment sequence and the contextual skeleton text sequence after extracting the values.
[0013] Step S111: Perform a character-level granular scan on the original response text sequence to identify character subsequences that conform to the characteristics of financial numerical writing, wherein the financial numerical writing characteristics include currency symbol introductory characters, thousands separators, decimal point positioning characters, and percent sign ending characters.
[0014] The original response text sequence is a Unicode-encoded character array, with each character occupying one array element position, and the array indices are numbered consecutively starting from 0. Character-level granular scanning is performed using a finite state automaton. The finite state automaton contains seven states: initial state ST0, currency symbol state ST1, integer accumulation state ST2, separator state ST3, decimal point state ST4, decimal accumulation state ST5, and percent sign state ST6. A currency symbol set CurrencySet is defined, containing the characters "¥", "$", "€", "£", and "¥". A number set DigitSet is defined, containing the characters "0" to "9". The scanning process starts from array index 0, let the current index be idx, the current character be ch, and the current state be ST, with ST initially set to ST0. For each idx, perform the following state transition judgment: If ST equals ST0 and ch belongs to CurrencySet, then ST transitions to ST1, and the starting index of this match is recorded as idx; if ST equals ST0, ST1, ST2, or ST3 and ch belongs to DigitSet, then ST transitions to ST2; if ST equals ST2 and ch equals the comma character ",", then ST transitions to ST3; if ST equals ST2 and ch equals the decimal point character ".", then ST transitions to ST4; if ST equals ST4 or ST5 and ch belongs to DigitSet, then ST transitions to ST5; if ST equals ST5 and ch equals the percent sign character "%", then ST transitions to ST6. When ST equals ST6 and the next character does not meet any transition conditions or has reached the end of the array, the character range from the starting index to idx is recorded as a financial numeric character subsequence, and ST is reset to ST0. After scanning the entire array, a list ListNum of all financial numeric character subsequences is obtained.
[0015] Step S112: Perform boundary expansion processing on the identified character subsequences that conform to the characteristics of financial numerical writing. Include the text units that are immediately before the character subsequence and have the function of limiting modification into the numerical context boundary, and include the text units that are immediately after the character subsequence and have the function of dimension labeling into the numerical context boundary, forming a complete numerical text span range.
[0016] Construct a dictionary DictA for qualifying modifiers. The keys of DictA are strings of qualifying modifiers, and the values are fixed Boolean values of True. The key set of DictA includes: approximately, about, nearly, more than, less than, not exceeding, at least, at most, up to, and as low as. Construct a dictionary DictB for dimensional units. The keys of DictB are strings of dimensional units, and the values are fixed Boolean values of True. The key set of DictB includes: yuan, ten thousand yuan, one hundred million yuan, US dollar, euro, pound sterling, percentage sign, percentage point, base point, BP, day, day, month, quarter, year, share, stock, lot, and contract. For each financial numerical character subsequence Nu in ListNum, obtain the first character index NuStart and the last character index NuEnd of Nu in the original response text sequence. Forward Expansion Processing: The initial value of the expansion start position ExtStart is NuStart. Starting from NuStart-1, read characters forward one by one, up to a maximum of D0 characters. Concatenate the read consecutive characters into a string. Check if this string has an exact match in the key set of DictA. If it does, update ExtStart to the index of the first character of the string and continue reading forward. If not, stop forward expansion. Forward Expansion Processing: The initial value of the expansion end position ExtEnd is NuEnd+1. Starting from NuEnd+1, read characters backward one by one, up to a maximum of D0 characters. Concatenate the read consecutive characters into a string. Check if this string has an exact match in the key set of DictB. If it does, update ExtEnd to the index of the last character of the string + 1 and continue reading forward. If not, stop backward expansion. The final numeric text span interval starts at ExtStart and ends at ExtEnd. Store all numeric text span intervals in a list ListSpan.
[0017] Step S113: Mark the start position offset and end position offset for each numerical text span interval to generate a span interval position index pair sequence. Each span interval position index pair in the span interval position index pair sequence contains a start offset value and an end offset value.
[0018] The total character length of the original response text sequence is L, where L is a positive integer greater than 0. Iterate through each numeric text span interval in ListSpan, setting the starting index of the i-th interval to P1(i) and the ending index to P2(i), with i numbered sequentially starting from 1. The index pair sequence is an array ArrIdxPair of length K, where K is the total number of intervals in ListSpan, and the i-th element of ArrIdxPair is a tuple (P1(i), P2(i)). Reorder ArrIdxPair in ascending order of P1(i), and then reassign the index numbers i to K in ascending order of P1(i).
[0019] Step S114: Based on the span interval position index pair sequence, extract the text content corresponding to each numerical text span interval from the original response text sequence one by one, and assemble the extracted text content into a numerical text fragment sequence according to the original order of appearance.
[0020] Initialize a string array S1 with length K. For i from 1 to K, perform the following: Take the tuple (P1(i), P2(i)) of the i-th element of ArrIdxPair, call the substring extraction operation on the original response text sequence to extract all characters within the index range [P1(i), P2(i)), and assign the extracted result to the i-th element of S1. After extraction, S1 is a sequence of numerical text fragments.
[0021] Step S115: While extracting the text content corresponding to each numerical text span interval from the original response text sequence, retain the remaining text content after removing all numerical text span intervals from the original response text sequence, and splice the remaining text content in the original order to form the contextual skeleton text sequence after removing the numerical values.
[0022] Initialize an empty string S2. Set the auxiliary variable E0 to its initial value of 0. Perform the following operations sequentially on i from 1 to K: First, append the substrings within the index range [E0, P1(i)) of the original response text sequence to the end of S2; second, append the placeholder string PH(i) to the end of S2, where PH(i) is formatted as "[NUM_" concatenated with the decimal representation of i and then concatenated with "]"; third, update the value of E0 to P2(i). After the loop completes, append the substrings within the index range [E0, L) of the original response text sequence to the end of S2. Finally, S2 becomes the context skeleton text sequence.
[0023] Step S116: Bidirectionally bind and associate each numerical text fragment in the numerical text fragment sequence with the corresponding span interval position index pair in the span interval position index pair sequence to generate a numerical fragment position binding mapping table. Each mapping record in the numerical fragment position binding mapping table contains a numerical text fragment, a start offset value, and an end offset value.
[0024] Construct a hash table M1 as a forward mapping table. The key of M1 is the number i, where i ranges from 1 to K. The value corresponding to the i-th key in M1 is a record object containing three fields: field T stores the string S1(i), field S stores the integer P1(i), and field E stores the integer P2(i). Simultaneously, construct another hash table M2 as a reverse mapping table. The key of M2 is a concatenated string formed by joining P1(i) and P2(i) using a separator. The concatenation format is to sequentially connect the decimal string of P1(i), the vertical bar character "|", and the decimal string of P2(i). The value of M2 is the number i. M1 and M2 together constitute a complete numerical fragment position binding mapping table.
[0025] For example, such as Figure 2 As shown, before processing the original response text sequence generated by the large model for financial query requests, the original response text sequence first undergoes identification and stripping of numerical text span intervals. Specific character subsequences conforming to the characteristics of financial numerical writing are located in the original response text sequence, and their boundaries are expanded to incorporate text units with limiting and modifying functions into the numerical context boundaries, forming complete numerical text span intervals, such as... Figure 1 The content highlighted by the dashed box is shown. For each identified numerical text span interval, its starting offset value and ending offset value are marked respectively, forming a sequence of span interval position index pairs.
[0026] like Figure 2 As shown, based on the span interval position index pair sequence, each numerical text span interval is segmented from the original response text sequence, and its text content is extracted to form a numerical text fragment sequence. Simultaneously, the remaining text content after removing all numerical text span intervals from the original response text sequence is concatenated to form a contextual skeleton text sequence. The figure displays the specific content of each numerical text fragment in the numerical text fragment sequence as arranged cards, and the contextual skeleton text sequence is displayed as text bars with placeholders. To further ensure data accuracy, a numerical fragment position binding mapping table is also constructed in the figure. Each mapping record in the table binds a numerical text fragment to its starting offset value and ending offset value in the original sequence.
[0027] Step S120: Perform a numerical semantic type recognition operation on each numerical text fragment in the numerical text fragment sequence to obtain the numerical semantic type label corresponding to each numerical text fragment, and construct a numerical semantic type label sequence.
[0028] like Figure 2As shown, for each extracted numerical text fragment, the corresponding contextual semantic units before and after it are extracted from the contextual skeleton text sequence. The figure uses dashed arrows to illustrate the relationship between the extracted contextual semantic units and numerical type indicators. For example, identifying the text units before and after the numerical value determines whether the value belongs to a monetary amount, interest rate, percentage, term, or share category. The identified tags are then aggregated into a numerical semantic type tag sequence, such as... Figure 1 As shown in the tag cloud on the right, the final generated semantic type tag sequence must be consistent with the order in which the original numerical text fragments appear.
[0029] Step S121: Obtain the starting offset value and ending offset value from the numerical fragment position binding mapping table associated with each numerical text fragment in the numerical text fragment sequence.
[0030] For each i from 1 to K, perform a hash lookup operation in M1 using i as the key to obtain the corresponding record object. Read the value P1(i) of field S and the value P2(i) of field E from the record object. Store P1(i) and P2(i) in a temporary variable for use in subsequent steps.
[0031] Step S122: Based on the starting offset value and ending offset value corresponding to each numerical text segment, extract the context semantic unit from the corresponding offset neighborhood interval of the context skeleton text sequence. The context semantic unit consists of the preceding text segment located within a preset character span before the starting offset value and the following text segment located within a preset character span after the ending offset value in the context skeleton text sequence.
[0032] The preset character span is a constant D1, where D1 is a positive integer greater than 0. For each i, first locate the starting index of the placeholder PH(i) in S2. Since the string format of PH(i) in S2 is unique, the first occurrence of PH(i) in S2 is found using a string matching algorithm, and this starting index is set to Q(i). The extraction method for the preceding text fragment is as follows: calculate the starting index A1 = Q(i) - D1, and if A1 < 0, then set A1 = 0; calculate the ending index A2 = Q(i); take the substring within the index range [A1, A2) in S2 as the preceding text fragment. The extraction method for the subsequent text fragment is as follows: Calculate the starting index B1 = Q(i) + len(PH(i)), where len(PH(i)) is the string length of PH(i); calculate the ending index B2 = B1 + D1; if B2 > len(S2), then set B2 = len(S2); take the substring within the index range [B1, B2) in S2 as the subsequent text fragment. Concatenate the preceding and subsequent text fragments in order into a complete string, which is the context semantic unit U(i).
[0033] Step S123: Perform semantic feature parsing processing on the context semantic unit and extract the numerical type indicator words contained in the context semantic unit. The numerical type indicator words are used to distinguish between monetary values, interest rate values, percentage values, term values, and share values.
[0034] Construct a dictionary of indicator words, DictC, which is a hash table where the keys are indicator word strings and the values are integer values corresponding to the type numbers. Type number 1 represents the amount class, with the corresponding key set including: amount, balance, principal, interest, handling fee, redemption amount, subscription amount, transaction amount, and transaction volume. Type number 2 represents the interest rate class, with the corresponding key set including: interest rate, annualized yield, seven-day annualized yield, yield per 10,000 units, discount rate, and rate of return. Type number 3 represents the percentage class, with the corresponding key set including: percentage, proportion, percentage, fee rate, tax rate, and discount rate. Type number 4 represents the term class, with the corresponding key set including: term, number of days, number of months, number of years, remaining term, duration, and maturity date. Type number 5 represents the share class, with the corresponding key set including: share, held shares, redeemable shares, frozen shares, and subscribed shares. Perform word segmentation on U(i) using the inverse maximum matching word segmentation algorithm based on DictC, and the segmentation result is a word sequence WordSeq. Iterate through each word in WordSeq, performing a hash lookup operation in DictC using that word as the key. If a match is found, record the matched word and its corresponding type number. If multiple matched words exist in WordSeq, calculate the character starting position of each matched word in U(i), and select the matched word with the smallest absolute value of the difference between its character starting position and the character starting position in PH(i) as the best matching indicator, recording its type number. If no matched word exists in WordSeq, the type number takes the default value of 1.
[0035] Step S124: Match the numerical type indicator words with a preset financial semantic type mapping table. The preset financial semantic type mapping table contains the correspondence between numerical type indicator words and numerical semantic type tags. Determine the numerical semantic type tag corresponding to each numerical text fragment based on the matching results.
[0036] The financial semantic type mapping table is the DictC constructed in step S123. Let the type number corresponding to the best matching indicator obtained in step S123 be Tid. Define the mapping function MapLabel(Tid) to the label string: if Tid equals 1, return the string "AMOUNT"; if Tid equals 2, return the string "RATE"; if Tid equals 3, return the string "PERCENT"; if Tid equals 4, return the string "TERM"; if Tid equals 5, return the string "SHARE". The numerical semantic type label Lb(i) = MapLabel(Tid). If WordSeq has no match word in step S123, Lb(i) takes the default value "AMOUNT".
[0037] Step S125: Assign a semantic confidence weight to the numerical semantic type label corresponding to each numerical text segment. The semantic confidence weight is jointly determined by the word frequency position parameter of the numerical type indicator word in the context semantic unit and the syntactic distance parameter between the numerical type indicator word and the numerical text segment. Based on the numerical semantic type label corresponding to each numerical text segment and the semantic confidence weight, sort the semantic labels of all numerical text segments in the numerical text segment sequence to generate a numerical semantic type label sequence. The arrangement order of the numerical semantic type label sequence is consistent with the arrangement order of the numerical text segment sequence.
[0038] Let Cw be the number of occurrences of the best matching indicator word in WordSeq, and Nw be the total number of words in WordSeq. The word frequency position parameter F(i) = Cw ÷ Nw. Let Pw be the word position index of the best matching indicator word in U(i) (counting from 1), and Pp be the word position index of PH(i) in U(i). The syntactic distance parameter D(i) = |Pw - Pp|. The semantic confidence weight W(i) = α × F(i) + (1 - α) × 1 ÷ (1 + D(i)), where α is a preset fusion coefficient constant, ranging from 0 to 1. Lb(i) and W(i) are grouped into a tuple and stored sequentially in array S3 in order from 1 to K. The i-th element of S3 is the tuple (Lb(i), W(i)), and S3 is the numerical semantic type label sequence.
[0039] Step S130: Based on the numerical semantic type label sequence, retrieve the formatting constraints corresponding to each numerical semantic type label from the preset financial formatting rule library, and perform formatting reshaping processing on the corresponding numerical text fragments in the numerical text fragment sequence based on the formatting constraints to generate a formatted numerical fragment sequence.
[0040] Step S131: Perform a traversal operation on the numerical semantic type label sequence one by one, and extract the currently traversed numerical semantic type label as the target semantic type label.
[0041] Set the traversal index i, which starts from 1 and increments sequentially to K. In each traversal iteration, take the first element Lb(i) of the i-th tuple from S3 and assign it to the string variable TLb as the target semantic type label.
[0042] Step S132: Perform a rule retrieval operation in the preset financial formatting rule base according to the target semantic type tag. The preset financial formatting rule base includes formatting constraints of amount, interest rate, percentage, term and share. The rule retrieval operation outputs the target formatting constraints that precisely match the target semantic type tag.
[0043] The default financial formatting rule base is a dictionary data structure, RuleDict. RuleDict contains five key-value pairs: the key "AMOUNT" corresponds to the amount constraint object ObjA; the key "RATE" corresponds to the interest rate constraint object ObjB; the key "PERCENT" corresponds to the percentage constraint object ObjC; the key "TERM" corresponds to the term constraint object ObjD; and the key "SHARE" corresponds to the share constraint object ObjE. Each constraint object contains five integer fields: field P1 indicates the number of decimal places to retain; field P2 indicates the thousands separator flag (0 for no comma separator, 1 for comma separator); field P3 indicates the sign flag (0 for negative numbers, 1 for positive numbers); field P4 indicates the number of leading zeros to padded (0 for no leading zeros, non-zero for padding the integer part to the specified number of places); and field P5 indicates the trailing zeros flag (0 for removing trailing zeros, 1 for retaining the specified number of precision points). The retrieval method is to perform a direct hash lookup in RuleDict using TLb as the key, and the search result is the target formatted constraint object Robj.
[0044] Step S133: Parse the numerical precision digit constraint parameters, thousands separator usage constraint parameters, plus / minus sign display constraint parameters, leading zero padding constraint parameters, and trailing zero retention constraint parameters specified in the target formatting constraints.
[0045] Read the value of field P1 from Robj and store it in variable V1, read the value of field P2 and store it in variable V2, read the value of field P3 and store it in variable V3, read the value of field P4 and store it in variable V4, and read the value of field P5 and store it in variable V5. V1, V2, V3, V4, and V5 are all integer types.
[0046] Step S134: Locate the target numeric text fragment corresponding to the target semantic type tag from the sequence of numeric text fragments, and extract the original character sequence of the target numeric text fragment.
[0047] According to the current traversal index i, take the i-th element from the array S1 and assign it to the string variable Str0. Str0 is exactly the original character sequence of the target numeric text fragment currently being processed.
[0048] Step S135: Apply the numeric precision digit constraint parameter, thousands separator usage constraint parameter, sign display constraint parameter, leading zero padding constraint parameter, and trailing zero retention constraint parameter to the original character sequence, and perform decimal point position alignment processing, separator insertion position calculation processing, sign bit replacement processing, leading zero character addition processing, and trailing zero character trimming processing on the original character sequence, so as to generate a reshaped numeric text fragment that meets all constraint requirements of the target formatting constraint condition.
[0049] Step S135 is implemented through steps S1351 to S1357.
[0050] Step S1351: Separate the currency symbol prefix from Str0. Construct a currency symbol string array CurrArr, which includes common currency representations such as "¥", "$", "€", "£", "¥", "CNY", and "USD". Traverse each currency symbol in CurrArr, check whether Str0 starts with the currency symbol. If the match is successful, the currency symbol is stored as the currency prefix CurrPre, and the remaining part of Str0 after removing the prefix is assigned to StrRem; if Str0 does not start with any currency symbol, CurrPre is an empty string, and StrRem is equal to Str0.
[0051] Step S1352: Separate the dimensional unit suffix from Str0. Construct a dimensional unit string array UnitArr, which includes units such as "Yuan", "Ten Thousand Yuan", "Hundred Million Yuan", "%", "percentage points", "BP", "day", "month", "year", "copy", and "share". Traverse each unit in UnitArr, check whether StrRem ends with the unit. If the match is successful, the unit is stored as the dimensional suffix UnitSuf, and the remaining part of StrRem after removing the suffix is retained; if StrRem does not end with any unit, UnitSuf is an empty string.
[0052] Step S1353: Extract the main numerical part from StrRem. Iterate through each character in StrRem, keeping only the characters belonging to the set {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "-"}, and concatenate the retained characters in their original order to form a pure numeric string StrNum. Record whether there is a minus sign "-" in StrNum. If it exists, set the sign flag SignFlag to -1 and remove the minus sign from StrNum; otherwise, set SignFlag to 1.
[0053] Step S1354: Convert StrNum to a double-precision floating-point number Val by calling the standard string-to-floating-point function. Perform precision rounding on Val: Val2 = round(Val × (10^V1)) ÷ (10^V1), where round is the rounding function and 10^V1 represents 10 raised to the power of V1. Convert Val2 to a regular decimal string representation, let's call this string StrVal.
[0054] Step S1355: Parse StrVal, dividing it into an integer part IntStr and a decimal part DecStr using the decimal point "." as the separator. If StrVal does not contain a decimal point, then IntStr equals StrVal, and DecStr is an empty string. Perform thousands separator processing on IntStr: If V2 equals 1, insert a comma "," every 3 characters from the left, starting from the last character of IntStr. The insertion positions are between the 3rd and 4th characters from the right, between the 6th and 7th characters from the right, and so on, to obtain the processed integer part IntStr2; if V2 equals 0, then IntStr2 equals IntStr. Perform leading zero padding on IntStr2: If V4 is greater than 0 and the length of IntStr2 is less than V4, then pad IntStr2 with zeros on the left, the number of zeros equal to the difference between V4 and the length of IntStr2, to obtain IntStr3; otherwise, IntStr3 equals IntStr2. Perform terminating null processing on DecStr: If V5 equals 0, check each character starting from the end of DecStr. If the last character is "0", delete that character and continue checking forward until the last character is not "0" or DecStr is empty. If V5 equals 1, keep DecStr unchanged. If the length of DecStr is less than V1, pad DecStr with "0" characters to make its length equal to V1. The processed DecStr is denoted as DecStr2.
[0055] Step S1356: Perform sign processing on IntStr3. If SignFlag equals -1, add a minus sign "-" to the left of IntStr3. If SignFlag equals 1 and V3 equals 1, add a plus sign "+" to the left of IntStr3. If SignFlag equals 1 and V3 equals 0, IntStr3 remains unchanged.
[0056] Step S1357: Concatenate CurrPre, the processed IntStr3, the decimal point "." (if DecStr2 is not empty), DecStr2 (if not empty), and UnitSuf in order to form the final reshaped numeric text fragment Str2. If DecStr2 is an empty string, do not concatenate the decimal point.
[0057] Step S136: After traversing all numerical semantic type tags in the numerical semantic type tag sequence and generating the corresponding reshaped numerical text fragments, arrange all the reshaped numerical text fragments according to the original order of the numerical semantic type tag sequence to generate a formatted numerical fragment sequence.
[0058] Traverse indices i from 1 to K, executing steps S131 to S135 to obtain K reshaped numerical text fragments Str2. Store these Str2 fragments in a string array S4 in ascending order of i. The i-th element of S4 is the i-th reshaped numerical text fragment. S4 is the formatted numerical fragment sequence.
[0059] For example, such as Figure 3 As shown, when performing formatting and reshaping processing based on numerical semantic type tags, a rule retrieval operation is first performed in the financial formatting rule base according to the target semantic type tag. This financial formatting rule base is displayed in the form of a database cylinder, which internally stores formatting constraints for amount, interest rate, percentage, term, and share categories in a logical hierarchy. The specific flow of the rule base retrieval operation is indicated by dashed arrows in the figure.
[0060] like Figure 3As shown, multiple constraint parameters from the financial formatting rule base are applied to the extracted original character sequence. The figure clearly shows the original character sequence "1234567.89", with multiple arrows pointing to the numerical precision digit constraint parameter, thousands separator usage constraint parameter, plus / minus sign display constraint parameter, leading zero padding constraint parameter, and trailing zero retention constraint parameter. These parameters converge in the formatting constraint condition unit represented by the gear symbol, collectively reshaping the original numerical value. After reshaping, a reshaped numerical text fragment conforming to the constraint requirements is obtained. The figure illustrates the reshaping result "+1, 234, 567.890", and displays the complete output of the formatted numerical fragment sequence through multiple reshaped cards.
[0061] like Figure 3 As shown, after generating the formatted numerical fragment sequence, a financial numerical compliance review process is performed. This review process includes four checks: character-by-character consistency comparison, precision digit matching comparison, delimiter usage matching comparison, and symbol display matching comparison. The diagram uses double cards side-by-side with bidirectional arrows to indicate character-by-character comparison, a magnifying glass symbol pointing to the decimal place to indicate precision digit verification, an arrow pointing to the thousands delimiter to indicate delimiter verification, and positive and negative signs to indicate symbol display verification. Each comparison result is marked with a checkmark or cross and summarized in the review result identifier sequence. The diagram uses alternating checkmarks and crosses to indicate the compliance and non-compliance status of each text span range.
[0062] like Figure 3 As shown, after review and processing, the final output, namely the verified financial response text sequence, is displayed in the graph. Meanwhile, the closed-loop process shown in the lower right corner of the graph illustrates the anomaly handling scheme: for non-compliant numerical fragments discovered during the review, secondary formatting and reshaping, generation of corrected formatted numerical fragments, and replacement and backfilling operations will be performed sequentially to ensure that the final output financial response text meets all format compliance requirements.
[0063] Step S140: Using the contextual skeleton text sequence as the contextual constraint benchmark, fill the formatted numerical fragments in the formatted numerical fragment sequence one by one into the corresponding text span range in the contextual skeleton text sequence to generate an initial formatted response text sequence.
[0064] Step S141: Obtain the starting offset value and ending offset value contained in each mapping record in the numerical fragment position binding mapping relationship table, and determine the boundary range of the text substring to be replaced in the context skeleton text sequence based on the starting offset value and ending offset value.
[0065] For i from 1 to K, perform a hash lookup in M1 using i as the key to obtain the record object. Read the value P1(i) of field S and the value P2(i) of field E from the record object. Find the starting index of the placeholder PH(i) in the context skeleton text sequence S2. Since the placeholders in S2 do not overlap, Q(i) can be obtained directly through a pre-computed auxiliary array. The boundary range of the text substring to be replaced is [Q(i), Q(i) + len(PH(i))).
[0066] Step S142: Determine the formatted numerical fragments in the formatted numerical fragment sequence that correspond to the current mapping record as the formatted numerical fragments to be backfilled.
[0067] Take the i-th element S4(i) from the formatted numeric fragment sequence S4 and assign it to the string variable Str3. Str3 is the formatted numeric fragment to be backfilled.
[0068] Step S143: Construct a reconstructed text unit, which is formed by sequentially splicing together the first part of the text in the context skeleton text sequence before the starting offset value, the formatted value fragment to be backfilled, and the second part of the text in the context skeleton text sequence after the ending offset value.
[0069] The first part of the text is a substring of the index range [0, Q(i)) in S2, denoted as Part1. The second part of the text is a substring of the index range [Q(i) + len(PH(i)), len(S2)) in S2, denoted as Part2. The recombined text unit NewText = Part1 + Str3 + Part2, where the plus sign indicates a string concatenation operation.
[0070] Step S144: Use the recombined text unit to replace the content in the context skeleton text sequence from the starting offset value to the ending offset value, and generate an updated context skeleton text sequence.
[0071] Update the value of string variable S2 to NewText constructed in step S143.
[0072] Step S145: Perform boundary determination, reorganization unit construction, and interval content replacement operations on all mapping records in the numerical fragment position binding mapping relationship table in reverse order of their original appearance order. After all mapping records have been processed, a complete text sequence with continuous context is obtained.
[0073] A reverse traversal method is used, traversing indices i from K to 1. During the reverse traversal, since the position of each PH(i) in S2 is pre-recorded before processing and there is no overlap between placeholders, a single replacement will not affect the index position of subsequent placeholders to be processed. Steps S141 to S144 are executed sequentially for each i. After all K replacements are completed, all placeholders in S2 are replaced with the corresponding formatted numerical fragments.
[0074] Step S146: Perform a global character position index consistency check on the context-continuous complete text sequence, traverse the position index of each character unit in the complete text sequence, rearrange the position indices in a continuously increasing order starting from the starting position, and generate an initial formatted response text sequence.
[0075] Check if any residual placeholder strings in S2, formatted as left square brackets followed by NUM and underscores, still exist. If any remainders are found, mark them as an anomaly. If the check passes, assign S2 to the string variable S5, which becomes the initial formatted response text sequence.
[0076] Step S150: Perform financial numerical compliance review processing on the initial formatted response text sequence to generate a review result identifier sequence. The review result identifier sequence contains a format compliance status flag for each text span interval. Based on the review result identifier sequence, the initial formatted response text sequence is determined as a verified financial response text sequence.
[0077] Step S151: Extract the formatted numerical fragments backfilled within each text span interval from the initial formatted response text sequence, and perform a character-by-character consistency comparison between the extracted formatted numerical fragments and the corresponding original formatted numerical fragments in the formatted numerical fragment sequence to obtain the character-by-character consistency comparison result.
[0078] For i from 1 to K, locate the position of the i-th backfill fragment in S5 and extract the string StrA of that backfill fragment. Compare StrA with the string StrB of the i-th element S4(i) in S4 character by character. The character-by-character comparison method is as follows: obtain the length LA of StrA and the length LB of StrB. If LA is not equal to LB, the comparison fails and R1(i)=0; if LA is equal to LB, then for index j from 0 to LA-1, compare whether the Unicode code point value of the j-th character of StrA is equal to the Unicode code point value of the j-th character of StrB. If they are all equal, then R1(i)=1; if there is any inequality, then R1(i)=0.
[0079] Step S152: Extract the numerical semantic type label corresponding to the formatted numerical fragments backfilled within each text span interval from the initial formatted response text sequence, and retrieve the formatting constraint conditions corresponding to the numerical semantic type labels from the preset financial formatting rule base as the review benchmark constraint conditions.
[0080] Retrieve the first element Lb(i) of the i-th tuple from S3. Perform a hash lookup in RuleDict using Lb(i) as the key to obtain the verification baseline constraint object RobjRef.
[0081] Step S153: Compare the formatted numerical fragments backfilled within each text span interval with the numerical precision bit constraint parameters specified in the verification benchmark constraint conditions to obtain the precision bit consistency comparison results.
[0082] Parse the decimal part from StrA, and let the sequence of characters after the decimal point be DecSeq. Calculate the length of DecSeq as the actual precision value V1a. Read the value V1r of field P1 from RobjRef. If V1a equals V1r, then the precision bit matching result R2(i) = 1; otherwise, R2(i) = 0.
[0083] Step S154: Compare the formatted numerical fragments backfilled within each text span interval with the thousands separator usage constraint parameters specified in the verification benchmark constraint conditions to obtain the separator usage matching result.
[0084] Parse the integer part from StrA, let the parsed integer part string be IntSeq. Check the insertion position of commas "," in IntSeq. There should be a comma between every 3 numeric characters from right to left. The leftmost group can be 1 to 3 numeric characters. Read the value V2r of field P2 from RobjRef. If V2r is equal to 0 and there are no commas in IntSeq, then R3(i) = 1; if V2r is equal to 1 and the comma insertion position in IntSeq exactly conforms to the rule of grouping every 3 characters, then R3(i) = 1; otherwise, R3(i) = 0.
[0085] Step S155: Compare the formatted numerical fragments backfilled within each text span interval with the positive and negative sign display constraint parameters specified in the verification benchmark constraint conditions to obtain the sign display matching result.
[0086] Check the first character of StrA. Read the value V3r of field P3 from RobjRef. If the value Val2 corresponding to StrA is non-negative (Val2≥0), and V3r equals 0 and the first character of StrA is a plus sign "+", then R4(i)=0; if Val2≥0 and V3r equals 1 and the first character of StrA is not a plus sign "+", then R4(i)=0; if Val2<0 and the first character of StrA is not a minus sign "-", then R4(i)=0; otherwise, R4(i)=1.
[0087] Step S156: Perform a comprehensive judgment on the character-by-character consistency comparison results, precision bit matching results, delimiter matching results, and symbol display matching results for each text span interval. If all comparison results indicate a matching state, generate a format compliance status mark representing format compliance. If any comparison result indicates a non-matching state, generate a format compliance status mark representing format non-compliance.
[0088] The comprehensive judgment logic is: F(i) = R1(i) × R2(i) × R3(i) × R4(i). F(i) equal to 1 indicates that the format is compliant, and F(i) equal to 0 indicates that the format is non-compliant.
[0089] Step S157: Arrange the format compliance status markers of all text span intervals according to the order in which the text span intervals appear in the initial formatted response text sequence to generate a review result identifier sequence.
[0090] Create an integer array S6 of length K. For each i from 1 to K, store the value of F(i) into the i-th element of S6. S6 is the sequence of verification result identifiers.
[0091] Step S158: Traverse the review result identifier sequence. If all format compliance status markers in the review result identifier sequence are in a format compliance state, then determine the initial formatted response text sequence as the verified financial response text sequence and terminate the review process.
[0092] Iterate through each element in S6, initializing the compliance counter C1 to 0. For each element i from 1 to K, if the i-th element of S6 equals 1, increment C1 by 1. After iteration, if C1 equals K, then S5 is identified as the verified financial response text sequence S7, and the review process terminates normally. If C1 is less than K, then a non-compliant item is marked, and S5 and S6 are output together for subsequent exception handling. Data collection and processing throughout the verification process comply with financial data security standards. The original response text sequence output by the large model has undergone sensitive information de-identification processing before entering this method and does not contain user personal identification information.
[0093] Step S210: Locate all text span intervals from the verified financial response text sequence, obtain the numerical semantic type label corresponding to each text span interval, and construct a semantic type label adjacency pair sequence according to the order in which the text span intervals appear in the verified financial response text sequence. Each semantic type label adjacency pair in the semantic type label adjacency pair sequence contains a previous numerical semantic type label and a next numerical semantic type label.
[0094] In the verified financial response text sequence S7, the start and end positions of each text span interval are tracked using the auxiliary positioning array recorded during backfilling. Let the starting index of the i-th text span interval in S7 be R1(i) and the ending index be R2(i). Take the first element Lb(i) of the i-th tuple from S3 as the numerical semantic type label corresponding to this interval. Construct an adjacency pair sequence in order from 1 to K: the j-th adjacency pair is (Lb(j), Lb(j+1)), where the value of j ranges from 1 to K-1. The adjacency pair sequence is stored as an array ArrPair of length K-1, where the j-th element of ArrPair is the tuple (Lb(j), Lb(j+1)).
[0095] like Figure 4 As shown, after generating the verified financial response text sequence, this embodiment supports cross-modal output adaptation. The verified financial response text sequence box in the figure leads to three independent modal branches: voice broadcast modality (corresponding to a word-by-word pronunciation sequence), table presentation modality (corresponding to cell alignment format), and chart rendering modality (corresponding to visualization mapping coordinates). The figure unifies the conversion outputs of the three modalities into the cross-modal format mapping text sequence box at the bottom, achieving synchronous adaptation mapping from single-source text to multi-modal formats.
[0096] Step S220: For each semantic type label adjacent relationship pair in the semantic type label adjacent relationship pair sequence, retrieve the semantic coherence constraints corresponding to the previous and next numerical semantic type labels from the preset financial semantic coherence rule base. The preset financial semantic coherence rule base includes allowed adjacent relationship types, prohibited adjacent relationship types, and adjacent relationship types that require additional verification between different numerical semantic type labels.
[0097] The pre-defined financial semantic coherence rule base is a 5x5 two-dimensional integer matrix M3. The row and column indices of the matrix correspond to five types of labels: index 0 corresponds to AMOUNT, index 1 to RATE, index 2 to PERCENT, index 3 to TERM, and index 4 to SHARE. The element value M3[a][b] in M3 has the following meanings: a value of 1 indicates that the adjacency relationship between label a and label b is allowed; a value of 0 indicates a prohibited type; and a value of 2 indicates a type requiring additional verification. The specific values of matrix M3 are pre-configured according to the financial business semantic rules. For example, in financial text, an amount followed by an interest rate is a common allowed adjacency relationship, while an interest rate followed by a term is a relationship requiring additional verification, necessitating further verification of the numerical logic. For the j-th adjacency pair in ArrPair, the preceding label Lb(j) is converted to the corresponding row index a, and the following label Lb(j+1) is converted to the corresponding column index b. The value of M3[a][b] is read from M3 as the semantic coherence constraint code CohCode(j).
[0098] Step S230: For each semantic type label adjacent relationship pair in the semantic type label adjacent relationship pair sequence, determine whether the adjacent relationship between the previous numerical semantic type label and the next numerical semantic type label belongs to an allowed adjacent relationship type according to the retrieved semantic coherence constraint conditions. If it belongs to an allowed adjacent relationship type, generate a semantic coherence judgment mark representing semantic coherence. If it belongs to a prohibited adjacent relationship type, generate a semantic coherence judgment mark representing semantic contradiction. If it belongs to an adjacent relationship type that requires additional verification, generate a semantic coherence judgment mark representing the need for additional verification.
[0099] For the j-th adjacent pair, read its semantic coherence constraint code CohCode(j). If CohCode(j) equals 1, the semantic coherence determination flag H(j) is assigned a value of 1, indicating semantic coherence; if CohCode(j) equals 0, H(j) is assigned a value of 0, indicating semantic contradiction; if CohCode(j) equals 2, H(j) is assigned a value of 2, indicating that additional verification is needed. Store H(j) in the temporary array ArrH in the order of j.
[0100] Step S240: For the semantic type label adjacent relationship pair that generates the semantic coherence judgment mark to be further verified, extract the previous formatted numerical fragment corresponding to the previous numerical semantic type label and the next formatted numerical fragment corresponding to the next numerical semantic type label from the verified financial response text sequence. Compare the magnitude of the numerical magnitude of the previous formatted numerical fragment with the magnitude of the next formatted numerical fragment. The magnitude logical relationship comparison is used to determine whether the magnitude size constraint relationship between the numerical value of the previous formatted numerical fragment and the numerical value of the next formatted numerical fragment conforms to the magnitude size constraint relationship defined in the financial business scenario.
[0101] Iterate through each pair of adjacent pairs in ArrH where H(j) equals 2. For each j that satisfies the condition, locate the j-th and (j+1)-th text span intervals in S7. Extract the formatted numerical fragments within the j-th interval and parse them into double-precision floating-point numbers Vj; extract the formatted numerical fragments within the (j+1)-th interval and parse them into double-precision floating-point numbers Vj1. The specific rules for comparing magnitude logical relationships are determined based on the combination of preceding and following labels: If Lb(j) is RATE and Lb(j+1) is PERCENT, the judgment condition is |Vj×100-Vj1|<ε1, where ε1 is a preset tolerance threshold; if Lb(j) is PERCENT and Lb(j+1) is AMOUNT, the judgment condition is that the value of Vj1÷Vj falls within the preset ratio interval [τ1, τ2], where τ1 is the lower bound coefficient and τ2 is the upper bound coefficient; if Lb(j) is AMOUNT and Lb(j+1) is AMOUNT, the judgment condition is whether the magnitude relationship between Vj and Vj1 conforms to the expected direction derived from the contextual semantics. If the label combination does not define magnitude constraint rules, it is directly determined to be satisfied. The magnitude logical relationship comparison result is denoted as CompRes(j), where CompRes(j) equals 1 if the constraint is satisfied, and equals 0 if it is not satisfied.
[0102] Step S250: Use the result of the magnitude logical relationship comparison as an additional verification basis. If the result of the magnitude logical relationship comparison conforms to the magnitude size constraint relationship defined in the financial business scenario, then update the original semantic coherence judgment mark representing the additional verification to a semantic coherence judgment mark representing semantic coherence. If the result of the magnitude logical relationship comparison does not conform to the magnitude size constraint relationship defined in the financial business scenario, then update the original semantic coherence judgment mark representing the additional verification to a semantic coherence judgment mark representing semantic contradiction.
[0103] For each adjacent relation pair where H(j) equals 2, read the corresponding order of magnitude logical relation comparison result CompRes(j). If CompRes(j) equals 1, update the j-th element H(j) in ArrH to 1; if CompRes(j) equals 0, update H(j) to 0. After the update, there are no longer any elements with a value of 2 in ArrH.
[0104] Step S260: Collect the semantic coherence judgment tags corresponding to all semantic type label adjacent relationship pairs in the semantic type label adjacent relationship pair sequence, and combine all semantic coherence judgment tags according to the order of the semantic type label adjacent relationship pair sequence to form a semantic coherence verification result.
[0105] The updated ArrH array is used as the semantic coherence verification result. ArrH has a length of K-1, and each element has a value of 1 or 0. The semantic coherence verification result is used to evaluate whether the combination of numeric types in the verified financial response text sequence conforms to financial semantic logic.
[0106] like Figure 4 As shown, when the validated financial response text sequence contains multiple financial values, semantic coherence verification will also be performed. The sequence of semantic type label adjacency pairs in the diagram illustrates the pairing relationships between the various numerical labels. Between each pair of labels, semantic coherence constraints (indicated by double-headed arrows and checkmark / cross marks) are used to verify that the semantic types of adjacent numerical values meet the constraints of financial business logic. Simultaneously, Figure 4 The process of marking the temporal format consistency and verifying the numerical evolution direction of formatted numerical segments at the beginning of T1 and the end of T2 is demonstrated, ensuring that the numerical representation across time periods remains consistent in format and conforms to a reasonable evolution trend in terms of numerical magnitude.
[0107] Step S310: Obtain all abnormal text span intervals in the review result identifier sequence that are marked as non-compliant in terms of format, and extract the corresponding formatted numerical fragments and original numerical text fragments for each abnormal text span interval.
[0108] Traverse the verification result identifier sequence S6 generated in step S157, and collect all indices i where S6(i) equals 0 to form an abnormal index list ErrList. For each abnormal index e in ErrList, take S4(e) from the formatted numerical fragment sequence S4 as the formatted numerical fragment StrFmt for that abnormal interval; take S1(e) from the numerical text fragment sequence S1 as the original numerical text fragment StrOrig for that abnormal interval.
[0109] Step S320: Perform feature-dimensional difference decomposition on the formatted numerical fragment and the original numerical text fragment. The feature-dimensional difference decomposition decomposes the difference into precision dimension difference components, separator dimension difference components, positive and negative sign dimension difference components, and leading zero dimension difference components.
[0110] For each anomalous index e, parse the actual precision bits Pa of StrFmt and the original precision bits Po of StrOrig. Precision dimension difference component Δprec(e) = Pa - Po. Parse the number of thousands separator commas Ca in StrFmt and the number of thousands separator commas Co in StrOrig. Separator dimension difference component Δsep(e) = Ca - Co. Parse the display mode of plus / minus signs Sa in StrFmt (0 indicates no plus sign, only minus sign; 1 indicates both plus and minus signs are displayed) and the display mode of plus / minus signs So in StrOrig. Plus / minus sign dimension difference component Δsign(e) = Sa - So. Parse the number of leading zeros La in StrFmt and the number of leading zeros Lo in StrOrig. Leading zero dimension difference component Δlead(e) = La - Lo. Combine the four difference components into a difference vector DiffVec(e) = (Δprec(e), Δsep(e), Δsign(e), Δlead(e)).
[0111] Step S330: Trace the source of deviation for each difference component. Trace the difference component in the precision dimension to the retrieval or application stage of the numerical precision digit constraint parameter, trace the difference component in the separator dimension to the retrieval or application stage of the thousands separator usage constraint parameter, trace the difference component in the plus / minus dimension to the retrieval or application stage of the plus / minus sign display constraint parameter, and trace the difference component in the leading zero dimension to the retrieval or application stage of the leading zero padding constraint parameter, and generate a deviation source stage identifier for each difference component.
[0112] The logic for determining the source of deviation is as follows: For the precision dimension difference component, query the constraint object Robj from RuleDict using the label of S3(e) as the key, and read the value V1r of field P1. If V1r does not conform to the financial industry standard, the deviation source is identified as the rule base retrieval stage; if V1r conforms to the standard but an error occurs when calculating Pa in step S135, the deviation source is identified as the formatting and reshaping application stage. For the delimiter dimension difference component, read the value V2r of field P2 and determine it according to the same logic. For the sign dimension difference component, read the value V3r of field P3 and determine it according to the same logic. For the leading zero dimension difference component, read the value V4r of field P4 and determine it according to the same logic. Each difference component generates a deviation source stage identifier string, in the format of component name concatenated with stage identifier.
[0113] Step S340: Based on the deviation source link identifier of each difference component, construct the deviation propagation path from the deviation source link identifier to the abnormal text span interval. The deviation propagation path records the complete link link from the root link where the deviation is generated, through numerical semantic type label recognition and format reshaping processing, to the abnormal text span interval.
[0114] The deviation propagation path is a string sequence. The starting point of the path is the identifier of the deviation source stage. The intermediate nodes of the path are, in order: the numerical semantic type label identification stage for the abnormal interval in step S124, the various sub-steps of the formatting and reshaping process in step S135, and the backfilling stage in step S140. The ending point of the path is the position coordinates (R1(e), R2(e)) of the abnormal text span interval e in S7. The deviation propagation path Path(e) is stored in list form, and the list elements are the name strings of each stage.
[0115] Step S350: Summarize the source links and propagation paths of all abnormal text span intervals to generate a format deviation tracing and attribution record.
[0116] Create a list called TraceList. For each anomaly index e in ErrList, construct a record object containing the following fields: anomaly interval number e, original value StrOrig, formatted value StrFmt, difference vector DiffVec(e), list of deviation source identifiers SrcList(e), and deviation propagation path Path(e). Append the record object to TraceList. TraceList is the record for tracing and attributing formatted deviations, persistently stored in JSON format.
[0117] For example, such as Figure 4 As shown, to support the traceability of the numerical reshaping process, a formatting operation backtracking chain was constructed. The starting node of this backtracking chain is the original character sequence, the intermediate transformation nodes are the rule identifiers of the numerical semantic type label and formatting constraints, and the ending node is the reshaped character sequence. The diagram illustrates the transformation relationship between the three through a chain connection. Simultaneously, the deviation propagation paths derived from each stage in the diagram clearly identify the specific stages that may produce formatting deviations, including precision dimension deviation, separator dimension deviation, plus / minus sign dimension deviation, and leading zero dimension deviation.
[0118] Step S410: Obtain the original character sequence of each numerical text segment in the numerical text segment sequence, and establish a one-to-one correspondence storage relationship between the original character sequence and the corresponding numerical text segment in the numerical text segment sequence; obtain the reshaped character sequence of each formatted numerical segment in the formatted numerical segment sequence, and establish a one-to-one correspondence storage relationship between the reshaped character sequence and the corresponding formatted numerical segment in the formatted numerical segment sequence; obtain the semantic type name of each numerical semantic type label and the rule identifier of the corresponding formatting constraint in the numerical semantic type label sequence, and establish a one-to-one correspondence storage relationship between the rule identifier and the corresponding numerical semantic type label in the numerical semantic type label sequence.
[0119] Three arrays are created to store the correspondence. The `OrigLink` array has a length of K, and `OrigLink(i)` stores key-value pairs where the key is the original character sequence `S1(i)` and the value is the index `i`. The `FormLink` array has a length of K, and `FormLink(i)` stores key-value pairs where the key is the reshaped character sequence `S4(i)` and the value is the index `i`. The `RuleLink` array has a length of K, and `RuleLink(i)` stores key-value pairs where the key is a combined string consisting of the label string `Lb(i)` extracted from `S3(i)` and the unique identifier `Rid(i)` of the constraint object retrieved from `RuleDict` with `Lb(i)` as the key, and the value is the index `i`.
[0120] Step S420: For each text span interval, the original character sequence is used as the starting node for backtracking, the semantic type name of the numerical semantic type label and the rule identifier of the corresponding formatting constraint are used as the intermediate transformation node for backtracking, and the reshaped character sequence is used as the ending node for backtracking, thus constructing a single formatting operation backtracking chain.
[0121] For i from 1 to K, construct a trace chain Trace(i). Trace(i) is an ordered list. The first element of the list is the starting node, containing S1(i); the second element is the intermediate transformation node, containing Lb(i) concatenated with the separator vertical line and then concatenated with Rid(i); the third element is the ending node, containing S4(i). The ordered list of Trace(i) describes the complete transformation path from the original value to the formatted value.
[0122] Step S430: For each text span interval, bind the starting offset value and ending offset value of the single formatting operation backtracking chain to the numerical fragment position binding mapping table, and update the actual position coordinate information of the corresponding financial value in the verified financial response text sequence according to the construction logic of the recombined text unit.
[0123] For i from 1 to K, read the values P1(i) and P2(i) of fields S and E from M1 with i as the key. In S7, obtain the actual start index R1(i) and actual end index R2(i) of the i-th formatted numeric fragment in S7 through the auxiliary positioning array. Combine Trace(i), the original position (P1(i), P2(i)), and the actual position (R1(i), R2(i)) into a structured record object Rec(i).
[0124] Step S440: Arrange and combine all single formatted operation backtracking chains with attached location coordinate information corresponding to all text span intervals according to the order in which the text span intervals appear in the verified financial response text sequence to generate formatted operation backtracking records.
[0125] Create a list called BacktraceList. For each element i from 1 to K, append Rec(i) to BacktraceList. The order of elements in BacktraceList corresponds to the order in which the text span intervals appear in S7. BacktraceList is the backtracking record for formatting operations, used for subsequent auditing and issue tracing.
[0126] For example, step S510: traverse the review result identifier sequence, filter out all abnormal text span intervals marked as non-compliant in format, and record the starting offset value and ending offset value corresponding to each abnormal text span interval.
[0127] Iterate through the S6 array generated in step S157 and collect the indices i where S6(i) equals 0. For each abnormal index e, extract the actual starting index R1(e) and the actual ending index R2(e) from Rec(e) stored in step S430. Construct an abnormal interval position list ErrPosList, where each element is a triplet (e, R1(e), R2(e)).
[0128] Step S520: For each abnormal text span interval, extract the abnormal formatted numerical fragments backfilled within the abnormal text span interval from the initial formatted response text sequence, and extract the original formatted numerical fragments corresponding to the abnormal text span interval from the formatted numerical fragment sequence.
[0129] For each element in ErrPosList, extract the substring of index range [R1(e), R2(e)) in S5 as the abnormal formatted numeric fragment StrBad(e). Extract S4(e) from S4 as the original formatted numeric fragment StrGood(e).
[0130] Step S530: Perform difference feature extraction processing on the abnormally formatted numerical fragment and the original formatted numerical fragment to identify the deviation feature type of the abnormally formatted numerical fragment relative to the original formatted numerical fragment. The deviation feature type includes precision digit deviation, separator deviation, positive and negative sign deviation, and leading zero deviation.
[0131] Compare StrBad(e) and StrGood(e) across each feature dimension. Compare precision bits: extract the length of the decimal part of both; if the lengths are unequal, mark the precision bit deviation type. Compare separators: extract the number and position of commas in the integer parts of both; if there is a difference, mark the separator deviation type. Compare plus / minus signs: extract the first character plus / minus sign display of both; if there is a difference, mark the plus / minus sign deviation type. Compare leading zeros: extract the number of consecutive leading zeros in the integer parts of both; if there is a difference, mark the leading zero deviation type. The deviation feature types are stored as a list of strings in DevType(e).
[0132] Step S540: Based on the deviation feature type, retrieve the corresponding formatting constraints from the preset financial formatting rule library, perform secondary formatting and reshaping processing on the abnormal formatted numerical fragment, and generate a corrected formatted numerical fragment.
[0133] For each deviation type in DevType(e), re-query the constraint object Robj from RuleDict using the label of S3(e) as the key. Taking StrBad(e) as input, re-execute the relevant sub-steps in step S135 only for the constraint parameter items corresponding to the deviation type. For example, if only the precision decimal point deviation exists, only the precision rounding and decimal part processing are re-executed. After processing, the corrected formatted numerical fragment StrFix(e) is obtained.
[0134] Step S550: Replace the abnormal formatted value fragments within the corresponding abnormal text span range in the initial formatted response text sequence with the corrected formatted value fragments, and adjust the position of the affected subsequent text content in the replaced initial formatted response text sequence.
[0135] In S5, substrings within the index range [R1(e), R2(e)) are replaced with StrFix(e). The total length of S5 may change after the replacement; the length change ΔL is calculated as len(StrFix(e)) - (R2(e) - R1(e)). ΔL is added to the starting and ending indices of all subsequent abnormal intervals in ErrPosList for offset adjustment. The auxiliary positioning arrays for all intervals are updated synchronously.
[0136] Step S560: Record the starting offset value, ending offset value, deviation feature type, and rule identifier of the formatting constraint conditions used in the secondary formatting and reshaping process for each abnormal text span interval, and generate an abnormal location correction feedback record.
[0137] For each abnormal interval e, construct a correction record object FixRec(e), containing the following fields: original starting index R1(e), original ending index R2(e), corrected starting index R1new(e), corrected ending index R2new(e), deviation feature type list DevType(e), and list of constraint rule identifiers used. Append FixRec(e) to the correction record list FixList. FixList represents the anomaly location correction feedback records.
[0138] Step S610: Extract the numerical semantic type label corresponding to each text span interval from the verified financial response text sequence, construct a numerical semantic type label sequence, and establish a binding relationship between each numerical semantic type label and its corresponding formatted numerical fragment.
[0139] Extract the label Lb(i) for each text span interval i from S3, and construct the label sequence TagList=[Lb(1), Lb(2), ..., Lb(K)]. For each i, establish a binding relationship Bind(i)=(Lb(i), S4(i)), where Bind(i) is a tuple.
[0140] Step S620: For each text span interval, extract the context semantic unit corresponding to the text span interval from the context skeleton text sequence, perform semantic role labeling on the context semantic unit to obtain the semantic role label of the financial value within the text span interval, the semantic role label includes subject value role, object value role, condition value role and result value role.
[0141] For each i, extract the context semantic unit U(i) from S2 using the same method as in step S122. Perform dependency parsing on U(i) to construct a dependency parsing tree. Locate the node corresponding to the placeholder PH(i) in the dependency parsing tree. Determine the semantic role based on the syntactic function of the node in the dependency parsing tree: if the node is the core word of the subject, assign the semantic role label Role(i) value SUBJ to indicate the subject numerical role; if the node is the core word of the object, assign the semantic role label Role(i) value OBJ to indicate the object numerical role; if the node is the core word of the conditional adverbial, assign the semantic role label Role(i) value COND to indicate the conditional numerical role; if the node is the core word of the result complement, assign the semantic role label Role(i) value RES to indicate the result numerical role. If the syntactic function cannot be determined, assign the default value SUBJ to Role(i).
[0142] Step S630: Retrieve the differentiated format presentation strategy corresponding to the semantic role tag from the preset semantic role formatting strategy library. The preset semantic role formatting strategy library contains the mapping relationship between different semantic role tags and formatted presentation styles. The formatted presentation styles include bold numerical presentation style, italic numerical presentation style, and underlined numerical presentation style.
[0143] The default semantic role formatting strategy library is a dictionary called StyleDict. The keys of StyleDict are semantic role tag strings, and the values are formatting style codes. The mapping relationships are as follows: SUBJ maps to bold style code BOLD; OBJ maps to italic style code ITALIC; COND maps to underline style code UNDER; and RES maps to a combination of bold and italic style code BOLDITALIC. For each i, the style code StyleCode(i) is retrieved from StyleDict using Role(i) as the key.
[0144] Step S640: According to the retrieved differentiated format presentation strategy, add format presentation style marks to the formatted numerical fragments within each text span range to generate formatted numerical fragments with style marks. The formatted numerical fragments with style marks retain all the character content of the original formatted numerical fragments and add presentation style control characters around the characters.
[0145] Generate the corresponding rendering style control character based on the value of StyCode(i). If StyCode(i) is BOLD, add a bold label around the characters in S4(i), formatted as left angle bracket B right angle bracket concatenated with S4(i) concatenated with left angle bracket forward slash B right angle bracket. If StyCode(i) is ITALIC, add an italic label. If StyCode(i) is UNDER, add an underscore label. If StyCode(i) is BOLDITALIC, add both bold and italic labels. The processed string is denoted as StyledStr(i).
[0146] Step S650: Replace the original formatted numerical fragments within each text span interval with the formatted numerical fragments marked with style tags, and recalculate the position offset of the subsequent text content affected by the replacement operation in the verified financial response text sequence.
[0147] In S7, the original formatted numerical segment S4(i) within the i-th text span interval is replaced with StyledStr(i). After the replacement, the length change is calculated, and the index of subsequent intervals is offset and adjusted in the same way as in step S550.
[0148] Step S660: Keep the text content in the verified financial response text sequence that did not participate in the replacement operation as is, and reassemble the formatted numerical fragments with style marks after replacement with the text content that was kept as is in the original order to generate a semantic disambiguation reconstructed text sequence.
[0149] After processing in step S650, S7 is output as a semantic disambiguation and reconstructed text sequence S8. While preserving the original financial semantic content, S8 visually distinguishes the numerical values of different semantic roles through differentiated presentation styles.
[0150] Step S710: Identify the preceding and following text segments with time sequence indicators from the verified financial response text sequence. The time sequence indicators include the beginning time sequence indicator, the end time sequence indicator, the previous period time sequence indicator, and the current period time sequence indicator. Determine the time sequence attribute label of the text span interval based on the time sequence indicators.
[0151] Construct a time-series indicator dictionary, TimeDict. The keys of TimeDict are: Beginning of Period set: Beginning of Period, Beginning of Year, Beginning of Month, Beginning of Quarter; End of Period set: End of Period, End of Year, End of Month, End of Quarter; Previous Period set: Previous Period, Same Period Last Year, Same Period Last Month, Same Period Last Quarter; Current Period set: Current Period, Current Month, Current Quarter. For each text span interval i, extract the text within a range of D2 characters before and after the interval in S7 as time-series detection segments. Match the time-series detection segments with each set in TimeDict. If a match is successful, mark the interval with the corresponding time-series attribute label TimeLabel(i). TimeLabel(i) takes values of PERBEG (beginning of period), PEREND (end of period), PREV (previous period), and CURR (current period). If no time-series indicator is matched, TimeLabel(i) takes an empty value.
[0152] Step S720: Arrange the text span intervals with time sequence attribute labels according to the time sequence attribute labels to construct a time sequence associated text span interval sequence. Each element in the time sequence associated text span interval sequence contains a time sequence attribute label and a corresponding formatted numerical fragment.
[0153] Select non-empty interval indices for TimeLabel(i) to form a time-series interval index list TimeIdxList. The chronological order is defined as PREV > PERBEG > CURR > PEREND. Sort the indices in TimeIdxList according to this order, and denote the sorted list as SortedTimeIdx. The time-series associated text span interval sequence TimeSeq is a list of (TimeLabel(i), S4(i)) tuples arranged in SortedTimeIdx order.
[0154] Step S730: Perform a format morphological evolution logic comparison on the formatted numerical segments of adjacent temporal attributes in the temporal associated text span interval sequence. If the number of decimal places after the previous formatted numerical segment and the number of thousands separators used in the same way and the leading zero padding rules are the same, a temporal format consistency mark representing consistent temporal format is generated. If there is a difference, a temporal format consistency mark representing inconsistent temporal format is generated.
[0155] For the m-th and (m+1)-th tuples in TimeSeq, extract the corresponding formatted numeric segments StrTm and StrTm1 from S4. Parse StrTm for its precision PTm, thousands separator usage STm, and leading zero padding LTm. Parse the corresponding parameters PTm1, STm1, and LTm1 of StrTm1. If PTm equals PTm1, STm equals STm1, and LTm equals LTm1, then the timing format consistency flag TFC(m) is set to 1; otherwise, TFC(m) is set to 0.
[0156] Step S740: Verify the numerical evolution direction of the formatted numerical segments of adjacent time series attributes in the time series associated text span interval sequence, extract the numerical magnitude corresponding to the previous formatted numerical segment and the numerical magnitude corresponding to the next formatted numerical segment, and determine whether the change direction of the numerical magnitude conforms to the preset financial time series evolution direction constraint based on the time advancement direction of the time series attribute label.
[0157] For the m-th and (m+1)-th tuples in TimeSeq, StrTm is parsed into a floating-point number VTm, and StrTm1 is parsed into a floating-point number VTm1. The time-series attribute labels TLm and TLm1 are obtained. Preset constraints on the direction of financial time-series evolution are applied: if TLm is PREV and TLm1 is CURR, for income-related values, VTm1 should be greater than or equal to VTm; if TLm is PERBEG and TLm1 is PEREND, for balance-related values, VTm1 should be less than or equal to VTm. The actual direction of numerical change is compared with the constraint direction. If the constraint is met, the numerical evolution direction verification result TVD(m) is assigned a value of 1; if it is not met, TVD(m) is assigned a value of 0; if no constraint rule is defined for this time-series combination, TVD(m) is assigned a value of 1.
[0158] Step S750: Combine the temporal format consistency marker and the numerical evolution direction verification result into a single set of temporal association evolution verification records, collect all single sets of temporal association evolution verification records corresponding to adjacent temporal attributes in the temporal association text span interval sequence, and generate temporal association evolution verification results.
[0159] For each adjacent pair m, construct a record object TimeRec(m) = (TFC(m), TVD(m)). Collect the TimeRec(m) of all adjacent pairs in TimeSeq into a list TimeCheckList in order. TimeCheckList is the result of time-series correlation evolution verification.
[0160] Step S810: Obtain the target output modal identifier corresponding to the verified financial response text sequence. The target output modal identifier includes a voice broadcast modal identifier, a table presentation modal identifier, and a chart rendering modal identifier.
[0161] The target output modality identifier is passed in by the downstream application system through an interface parameter named `outputMode`. The value set for `outputMode` is {AUDIO, TABLE, CHART}, corresponding to the voice broadcast modality, table presentation modality, and chart rendering modality, respectively. The value of the `outputMode` parameter is read and assigned to the variable `ModeID`.
[0162] Step S820: Extract the formatted numerical fragments and numerical semantic type labels corresponding to each text span interval from the verified financial response text sequence, and establish a modal conversion source data pair of formatted numerical fragments and numerical semantic type labels.
[0163] For each text span interval i, extract the corresponding formatted numeric fragment string S4(i) from S7 and the corresponding numeric semantic type label Lb(i) from S3. Construct the modality transformation source data pair SrcPair(i) = (S4(i), Lb(i)), where SrcPair(i) is a tuple.
[0164] Step S830: Based on the target output modality identifier, retrieve the modality format conversion template corresponding to the target output modality identifier from the preset cross-modality format mapping rule library. The preset cross-modality format mapping rule library contains the correspondence between different output modality identifiers and numerical presentation formats.
[0165] The default cross-modal format mapping rule library is a dictionary called ModalDict. ModalDict contains three key-value pairs: the key AUDIO corresponds to the voice broadcast conversion template TplAudio; the key TABLE corresponds to the table rendering conversion template TplTable; and the key CHART corresponds to the chart rendering conversion template TplChart. TplAudio defines the conversion rules from numerical values to phonetic sequences, including a digit-by-digit phonetic mapping table for the integer part, a digit-by-digit phonetic mapping table for the decimal part, a unit word phonetic mapping table, and separator pause rules. TplTable defines the cell alignment format for numerical values, including alignment methods, column width parameters, and numerical precision display rules. TplChart defines the mapping function from numerical values to visual coordinates, including coordinate axis range parameters and numerical normalization formulas. Searching for the target template Tpl in ModalDict using ModeID as the key yields the result.
[0166] Step S840: For each modal conversion source data pair, apply the retrieved modal format conversion template to convert the formatted numerical fragment into a target modal formatted numerical fragment. The target modal formatted numerical fragment contains the digit-by-digit pronunciation sequence of the numerical value under the voice broadcast modal identifier, contains the cell alignment format of the numerical value under the table presentation modal identifier, and contains the visual mapping coordinates of the numerical value under the chart rendering modal identifier.
[0167] If ModeID equals AUDIO, perform voice broadcast conversion on S4(i) in SrcPair(i). First, identify the currency symbol prefix and unit suffix in S4(i). Second, map the integer part of the numerical body digit by digit to Chinese numeral pronunciation characters, inserting pause marks corresponding to the thousands separator, and map the decimal part digit by digit to Chinese numeral pronunciation characters. Third, concatenate the currency symbol pronunciation, integer pronunciation sequence, decimal point pronunciation, decimal pronunciation sequence, and unit pronunciation in sequence into a digit-by-digit pronunciation sequence string AudStr(i). If ModeID equals TABLE, perform table rendering conversion on S4(i), generating a table format string TabStr(i) containing cell alignment marks and precision control characters. If ModeID equals CHART, perform chart rendering conversion on S4(i), extracting the floating-point values of the numerical values, calculating normalized coordinate values based on the coordinate axis range parameters, and generating a visual mapping coordinate string ChStr(i). The processing result is uniformly denoted as ModalStr(i).
[0168] Step S850: Replace the original formatted numerical fragments in each text span interval of the verified financial response text sequence with the corresponding target modal formatted numerical fragments, and perform contextual fluency adjustment processing on the replaced text sequence.
[0169] In S7, for each text span interval i, the original formatted numerical segment S4(i) is replaced with ModalStr(i). After the replacement, if ModeID equals AUDIO, the entire text sequence is adjusted for speech fluency: adjacent pause marks are merged, the order of units and numerical values is adjusted, and long pause marks are inserted at paragraph boundaries. If ModeID equals TABLE or CHART, the surrounding text of the numerical value remains unchanged, and only the numerical part is replaced with a table or chart format string.
[0170] Step S860: Output the text sequence after context fluency adjustment as a cross-modal format-mapped text sequence.
[0171] The entire text sequence processed in step S850 is assigned to the string variable S9. S9 is the cross-modal format mapped text sequence, which serves as the final output of this step.
[0172] Step S910: Perform paragraph boundary recognition processing on the verified financial response text sequence, identify paragraph separation marks in the verified financial response text sequence, and divide the verified financial response text sequence into multiple response text paragraph units according to the paragraph separation marks.
[0173] Paragraph separators include newline characters, carriage returns, paragraph spacing markers, and commonly used paragraph keywords in financial text. Each character in S7 is traversed, and the position of a newline or carriage return is detected. The text content between two consecutive paragraph separators constitutes a response text paragraph unit. All the segmented paragraph units are stored sequentially in the array ParArr, where ParArr has a length of NP, and NP is the total number of paragraphs.
[0174] Step S920: Extract the formatted numerical fragments corresponding to all text span intervals contained in each response text paragraph unit to form a set of formatted numerical fragments within the paragraph corresponding to the response text paragraph unit.
[0175] For the p-th paragraph unit ParArr(p), iterate through all K text span intervals and determine whether the starting index R1(i) and ending index R2(i) of each interval fall within the index range of ParArr(p) in S7. If they fall within the range, collect the corresponding formatted numeric fragment S4(i) into the numeric fragment list ParNumList(p) of that paragraph.
[0176] Step S930: Perform numerical identity assignment processing on the formatted numerical fragments in the set of formatted numerical fragments within the paragraph corresponding to each response text paragraph unit, calculate the numerical content hash feature of each formatted numerical fragment, and classify the formatted numerical fragments with the same numerical content hash feature into the same numerical identity category.
[0177] For each formatted numeric fragment in ParNumList(p), extract its pure numeric portion and calculate its hash value HashVal using the MD5 hash algorithm. Create a hash map HashMap using HashVal as the key. Formatted numeric fragments with the same HashVal are grouped into the same numeric identity category IDclass. Numeric fragments in the same IDclass represent financial numeric values that are completely identical in content.
[0178] Step S940: Perform cross-paragraph formatting comparison on formatted numeric fragments with the same numeric identity category. If all formatted numeric fragments in the same numeric identity category have the same number of decimal places, the same position of the thousands separator, and the same number of leading zero padding places, then generate a cross-paragraph consistency judgment mark representing cross-paragraph consistency. If there are any differences in formatting, then generate a cross-paragraph consistency judgment mark representing cross-paragraph inconsistency.
[0179] For each IDclass, iterate through all formatted numeric fragments within that class. Parse each fragment for the number of precision digits, the list of thousands separator positions, and the number of leading zeros. If all fragments in the class have the same number of precision digits, identical thousands separator positions, and the same number of leading zeros, then the CrossOK flag for cross-paragraph consistency is set to 1; otherwise, CrossOK is set to 0.
[0180] Step S950: Collect cross-paragraph consistency judgment tags for all numerical identity categories, arrange all cross-paragraph consistency judgment tags according to the recognition order of numerical identity categories, and generate cross-paragraph consistency verification results.
[0181] Arrange all CrossOK values of IDclass in the order of IDclass recognition and store them in the array CrossResult. CrossResult is the cross-paragraph consistency verification result, used to check whether the formatting of the same value remains consistent when it appears in different paragraphs of the text.
[0182] Step S1010: Collect the format compliance status markers of all text span intervals in the review result identifier sequence, statistically analyze the distribution characteristics of the format compliance status markers, and extract the numerical semantic type labels corresponding to the text span intervals with non-compliant formats as semantic type labels to be optimized.
[0183] Iterate through the S6 array generated in step S157 and calculate the format compliance rate for each numerical semantic type label Lb. Let Nt be the number of intervals corresponding to label type t, where NtOK is the number of format compliant intervals. The format compliance rate Rt = NtOK ÷ Nt. Collect label types whose Rt is lower than the preset optimization threshold Rmin into the semantic type label set OptSet to be optimized.
[0184] like Figure 4As shown, this embodiment also includes a rule-adaptive evolution scheme based on historical format optimization samples. The format optimization sample pair module includes a comparison process between the original numerical text fragments and the formatted numerical fragments, and summarizes the constraint parameter types that cause format deviations through the formatting rule deviation pattern mining module. Subsequently, the analysis results are passed to the constraint parameter update suggestion module, which lists the semantic type label to be optimized, the constraint parameter type, and the target constraint parameter value. Finally, these update suggestions are summarized into a format adaptive evolution parameter set, which is used to continuously optimize the constraint condition parameters in the financial formatting rule base.
[0185] Step S1020: For each semantic type label to be optimized, extract the formatted numerical fragment corresponding to the semantic type label to be optimized from the formatted numerical fragment sequence, and extract the original numerical text fragment corresponding to the semantic type label to be optimized from the numerical text fragment sequence to construct a format optimization sample pair.
[0186] For each label type t in OptSet, collect all interval indices where Lb(i) equals t. For each index i, extract the formatted numeric fragment S4(i) from S4 and the original numeric text fragment S1(i) from S1. Combine (S1(i), S4(i)) into a format-optimized sample pair and store it in the sample set SampleSet(t).
[0187] Step S1030: Perform formatting rule deviation pattern mining on the format optimization sample pair, and identify the constraint parameter types that cause format deviation in the formatting constraints corresponding to the semantic type label to be optimized in the preset financial formatting rule library. The constraint parameter types include numerical precision digit constraint parameter types, thousands separator usage constraint parameter types, and positive and negative sign display constraint parameter types.
[0188] For each pair of samples in SampleSet(t), perform the difference decomposition in step S320 to obtain the difference vector. Calculate the proportion of non-zero values for each difference component across all sample pairs. The proportion of non-zero values for the precision digit difference component is denoted as Rprec, for the separator difference component as Rsep, and for the sign difference component as Rsign. If the proportion of non-zero values exceeds a preset deviation judgment threshold, the constraint parameter type is determined to be a constraint parameter type causing format deviation. The determined constraint parameter type is stored in the deviation type list DevTypeList(t).
[0189] Step S1040: Based on the identified constraint parameter types that cause format deviation, extract formatting features that conform to financial business standards from the format optimization sample pair as target constraint parameter values. The formatting features that conform to financial business standards are derived from formatting samples that have been manually reviewed and confirmed or from historically accumulated format compliance samples.
[0190] For each constraint parameter type in DevTypeList(t), select compliant sample pairs from SampleSet(t) as positive samples. Analyze the value distribution of the constraint parameter in the positive samples, and calculate the mode or median of the values as the target constraint parameter value TargetVal. If the number of positive samples is insufficient, extract the standard parameter value corresponding to the tag type from a manually reviewed and confirmed formatted sample library as TargetVal.
[0191] Step S1050: Compare the target constraint parameter value with the corresponding current constraint parameter value in the preset financial formatting rule base. If there is a difference, generate a constraint parameter update suggestion item. The constraint parameter update suggestion item includes the semantic type label to be optimized, the constraint parameter type, and the target constraint parameter value.
[0192] Retrieve the current constraint object from RuleDict using the label type t as the key, and read the current value CurVal of the corresponding field. If TargetVal is not equal to CurVal, generate a constraint parameter update suggestion item SuggItem. SuggItem contains the fields: label to be optimized t, constraint parameter type name, current value CurVal, and suggested value TargetVal. Append the SuggItem to the suggestion list SuggList(t).
[0193] Step S1060: Collect all constraint parameter update suggestions corresponding to the semantic type labels to be optimized, and generate a set of format adaptive evolution parameters.
[0194] All suggestion lists (SuggList(t) of tag type t) are merged into a single total list, TotalSuggList. TotalSuggList is the set of adaptive format evolution parameters. This set is persistently stored in the rule base management module in JSON format for automatic or manual review and application during rule base version updates.
[0195] Furthermore, the financial numerical formatting verification system for large model output provided in this application embodiment includes a processor and a memory. The processor and memory are connected, for example, via a bus. Optionally, the financial numerical formatting verification system for large model output may further include a transceiver, which can be used for data interaction between this financial numerical formatting verification system for large model output and other financial numerical formatting verification systems for large model output, such as sending and / or receiving data. It should be noted that in actual scheduling, the transceiver is not limited to one, and the structure of this financial numerical formatting verification system for large model output does not constitute a limitation on the embodiments of this application.
[0196] The memory stores program code for executing the embodiments of this application, and its execution is controlled by a processor. The processor executes the program code stored in the memory to implement the steps shown in the foregoing method embodiments.
[0197] The above description is only an optional implementation method for some implementation scenarios of this application. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this application, without departing from the technical concept of this application, also fall within the protection scope of the embodiments of this application.
Claims
1. A method for formatting and validating financial numerical data outputs for large models, characterized in that, The method includes: Obtain the original response text sequence generated by the large model for the financial query request, locate and extract the text span occupied by financial values from the original response text sequence to obtain the numerical text fragment sequence and the context skeleton text sequence after extracting the values. Perform a numerical semantic type recognition operation on each numerical text fragment in the numerical text fragment sequence to obtain the numerical semantic type label corresponding to each numerical text fragment, and construct a numerical semantic type label sequence; Based on the numerical semantic type tag sequence, the formatting constraints corresponding to each numerical semantic type tag are retrieved from the preset financial formatting rule base. Based on the formatting constraints, the corresponding numerical text segments in the numerical text segment sequence are formatted and reshaped to generate a formatted numerical segment sequence. Using the contextual skeleton text sequence as the contextual constraint benchmark, the formatted numerical fragments in the formatted numerical fragment sequence are backfilled one by one into the corresponding text span range in the contextual skeleton text sequence to generate an initial formatted response text sequence; The initial formatted response text sequence is subjected to financial numerical compliance review processing to generate a review result identifier sequence. The review result identifier sequence contains a format compliance status flag for each text span interval. Based on the review result identifier sequence, the initial formatted response text sequence is determined to be a verified financial response text sequence.
2. The financial numerical formatting verification method for large model output according to claim 1, characterized in that, The process involves obtaining the original response text sequence generated by the large model for a financial query request, locating and extracting the text span occupied by financial numerical values from the original response text sequence, obtaining a sequence of numerical text fragments and a contextual skeleton text sequence after removing the numerical values, including: The original response text sequence is scanned at the character level to identify character subsequences that conform to the characteristics of financial numerical writing, which include currency symbol introductory characters, thousands separators, decimal point positioning characters, and percent sign ending characters. The identified character subsequences that conform to the characteristics of financial numerical writing are subjected to boundary expansion processing. The text units that are immediately before the character subsequence and have the function of limiting modification are included in the numerical context boundary, and the text units that are immediately after the character subsequence and have the function of dimension labeling are included in the numerical context boundary, forming a complete numerical text span range. For each numerical text span interval, mark the start position offset and the end position offset to generate a span interval position index pair sequence. Each span interval position index pair in the span interval position index pair sequence contains a start offset value and an end offset value. Based on the span interval position index pair sequence, extract the text content corresponding to each numerical text span interval from the original response text sequence one by one, and assemble the extracted text content into a numerical text fragment sequence according to the original order of appearance; While extracting the text content corresponding to each numerical text span interval from the original response text sequence, the remaining text content after removing all numerical text span intervals from the original response text sequence is retained, and the remaining text content is spliced together in the original order to form a contextual skeleton text sequence after removing the numerical values. Each numerical text fragment in the numerical text fragment sequence is bidirectionally bound to the corresponding span interval position index pair in the span interval position index pair sequence to generate a numerical fragment position binding mapping table. Each mapping record in the numerical fragment position binding mapping table contains a numerical text fragment, a start offset value, and an end offset value.
3. The financial numerical formatting verification method for large model output according to claim 1, characterized in that, The step of performing a numerical semantic type recognition operation on each numerical text fragment in the numerical text fragment sequence to obtain a numerical semantic type label corresponding to each numerical text fragment, and constructing a numerical semantic type label sequence, includes: Obtain the starting offset and ending offset values from the numerical fragment position binding mapping table associated with each numerical text fragment in the numerical text fragment sequence; Based on the starting offset value and ending offset value corresponding to each numerical text segment, a contextual semantic unit is extracted from the corresponding offset neighborhood interval of the contextual skeleton text sequence. The contextual semantic unit consists of a preceding text segment located within a preset character span before the starting offset value and a following text segment located within a preset character span after the ending offset value in the contextual skeleton text sequence. The context semantic unit is subjected to semantic feature parsing processing to extract the numerical type indicator words contained in the context semantic unit. The numerical type indicator words are used to distinguish between monetary values, interest rate values, percentage values, term values and share values. The numerical type indicator is matched with a preset financial semantic type mapping table, which contains the correspondence between numerical type indicator and numerical semantic type label. The numerical semantic type label corresponding to each numerical text fragment is determined based on the matching result. A semantic confidence weight is assigned to the numerical semantic type label corresponding to each numerical text segment. The semantic confidence weight is jointly determined by the word frequency position parameter of the numerical type indicator word in the context semantic unit and the syntactic distance parameter between the numerical type indicator word and the numerical text segment. Based on the numerical semantic type label corresponding to each numerical text fragment and the semantic confidence weight, the semantic labels of all numerical text fragments in the numerical text fragment sequence are sorted to generate a numerical semantic type label sequence. The arrangement order of the numerical semantic type label sequence is consistent with the arrangement order of the numerical text fragment sequence.
4. The financial numerical formatting verification method for large model output according to claim 1, characterized in that, The step of retrieving formatting constraints corresponding to each numerical semantic type label from a preset financial formatting rule base based on the numerical semantic type label sequence, and performing formatting reshaping processing on the corresponding numerical text fragments in the numerical text fragment sequence based on the formatting constraints to generate a formatted numerical fragment sequence includes: The numerical semantic type label sequence is traversed one by one, and the numerical semantic type label of the current traversal is extracted as the target semantic type label; The rule retrieval operation is performed in the preset financial formatting rule base according to the target semantic type tag. The preset financial formatting rule base includes formatting constraints of amount, interest rate, percentage, term and share. The rule retrieval operation outputs the target formatting constraints that exactly match the target semantic type tag. The numerical precision digit constraint parameters, thousands separator usage constraint parameters, plus / minus sign display constraint parameters, leading zero padding constraint parameters, and trailing zero retention constraint parameters specified in the target formatting constraint conditions are analyzed. Locate the target numerical text fragment corresponding to the target semantic type label from the numerical text fragment sequence, and extract the original character sequence of the target numerical text fragment; The numerical precision digit constraint parameters, thousands separator usage constraint parameters, plus / minus sign display constraint parameters, leading zero padding constraint parameters, and trailing zero retention constraint parameters are applied to the original character sequence. Decimal point alignment processing, separator insertion position calculation processing, sign bit replacement processing, leading zero character supplementation processing, and trailing zero character pruning processing are performed on the original character sequence to generate a reshaped numerical text fragment that meets all the constraint requirements of the target formatting constraint conditions. After traversing all numerical semantic type tags in the numerical semantic type tag sequence and generating the corresponding reshaped numerical text fragments, all the reshaped numerical text fragments are arranged in the original order of the numerical semantic type tag sequence to generate a formatted numerical fragment sequence.
5. The financial numerical formatting verification method for large model output according to claim 3, characterized in that, The step of using the contextual skeleton text sequence as a contextual constraint benchmark, and filling the formatted numerical fragments in the formatted numerical fragment sequence one by one into the corresponding text span range in the contextual skeleton text sequence to generate an initial formatted response text sequence includes: Obtain the start offset value and end offset value contained in each mapping record in the numerical fragment position binding mapping relationship table, and determine the boundary range of the text substring to be replaced in the context skeleton text sequence based on the start offset value and end offset value. The formatted value fragments in the formatted value fragment sequence that correspond to the current mapping record are identified as the formatted value fragments to be backfilled. Construct a reconstructed text unit, which is formed by sequentially splicing together the first part of the text in the context skeleton text sequence before the starting offset value, the formatted numerical fragment to be filled back, and the second part of the text in the context skeleton text sequence after the ending offset value. The recombined text unit is used to replace the content in the context skeleton text sequence from the starting offset value to the ending offset value, thereby generating an updated context skeleton text sequence. For all mapping records in the numerical fragment position binding mapping relationship table, perform boundary determination, reorganization unit construction and interval content replacement operations in reverse or forward order of the original appearance order. After all mapping records have been processed, a complete text sequence with continuous context is obtained. A global character position index consistency check is performed on the complete text sequence with continuous context. The position index of each character unit in the complete text sequence is traversed and rearranged in a continuously increasing order starting from the starting position to generate an initial formatted response text sequence.
6. The financial numerical formatting verification method for large model output according to claim 1, characterized in that, The process of performing financial numerical compliance review on the initial formatted response text sequence generates a review result identifier sequence. This sequence includes a format compliance status flag for each text span interval. Based on this review result identifier sequence, the initial formatted response text sequence is determined to be a verified financial response text sequence. This includes: Extract the formatted numerical fragments backfilled within each text span interval from the initial formatted response text sequence, and perform a character-by-character consistency comparison with the original formatted numerical fragments corresponding to the formatted numerical fragment sequence to obtain the character-by-character consistency comparison result; Extract the numerical semantic type label corresponding to the formatted numerical fragments filled in each text span interval from the initial formatted response text sequence, and retrieve the formatting constraint conditions corresponding to the numerical semantic type labels from the preset financial formatting rule base as the review benchmark constraint conditions. The formatted numerical fragments backfilled within each text span interval are compared with the numerical precision bit constraint parameters specified in the verification benchmark constraint conditions to obtain the precision bit matching results. The formatted numerical fragments backfilled within each text span interval are compared with the thousands separator usage constraint parameters specified in the review benchmark constraints to obtain the separator usage matching results. The formatted numerical fragments backfilled within each text span interval are compared with the positive and negative sign display constraint parameters specified in the verification benchmark constraint conditions to obtain the sign display matching result. For each text span interval, the character-by-character consistency comparison results, the precision bit matching results, the delimiter matching results, and the symbol display matching results are comprehensively judged. If all comparison results indicate a matching state, a format compliance status mark representing format compliance is generated. If any comparison result indicates a non-match state, a format compliance status mark representing non-compliance is generated. Arrange the format compliance status markers of all text span intervals according to the order in which the text span intervals appear in the initial formatted response text sequence to generate a review result identifier sequence; The review result identifier sequence is traversed. If all format compliance status markers in the review result identifier sequence are in a format compliance state, then the initial formatted response text sequence is determined as the verified financial response text sequence and the review process is terminated.
7. The financial numerical formatting verification method for large model output according to claim 1, characterized in that, The method further includes: Locate all text span intervals from the verified financial response text sequence, obtain the numerical semantic type label corresponding to each text span interval, and construct a semantic type label adjacency pair sequence according to the order in which the text span intervals appear in the verified financial response text sequence. Each semantic type label adjacency pair in the semantic type label adjacency pair sequence contains the previous numerical semantic type label and the next numerical semantic type label. For each semantic type label adjacent relationship pair in the sequence of semantic type label adjacent relationship pairs, the semantic coherence constraints corresponding to the previous numerical semantic type label and the next numerical semantic type label are retrieved from the preset financial semantic coherence rule base. The preset financial semantic coherence rule base includes allowed adjacent relationship types, prohibited adjacent relationship types and adjacent relationship types that require additional verification between different numerical semantic type labels. For each semantic type label adjacent relationship pair in the semantic type label adjacent relationship pair sequence, the adjacent relationship between the previous numerical semantic type label and the next numerical semantic type label is determined according to the invoked semantic coherence constraint conditions. If it belongs to the allowed adjacent relationship type, a semantic coherence judgment mark representing semantic coherence is generated. If it belongs to the prohibited adjacent relationship type, a semantic coherence judgment mark representing semantic contradiction is generated. If it belongs to the adjacent relationship type that requires additional verification, a semantic coherence judgment mark representing additional verification is generated. For the semantic type label adjacent relationship pair that generates a semantic coherence judgment mark to be further verified, the previous formatted numerical fragment corresponding to the previous numerical semantic type label and the next formatted numerical fragment corresponding to the next numerical semantic type label are extracted from the verified financial response text sequence. The magnitude of the numerical magnitude of the previous formatted numerical fragment and the numerical magnitude of the next formatted numerical fragment are compared by magnitude logical relationship. The magnitude logical relationship comparison is used to determine whether the numerical magnitude of the previous formatted numerical fragment and the numerical magnitude of the next formatted numerical fragment conform to the magnitude size constraint relationship defined in the financial business scenario. The results of the comparison of magnitude logical relationships are used as additional verification criteria. If the results of the comparison of magnitude logical relationships conform to the magnitude size constraint relationship defined in the financial business scenario, the original semantic coherence judgment mark representing the additional verification is updated to a semantic coherence judgment mark representing semantic coherence. If the results of the comparison of magnitude logical relationships do not conform to the magnitude size constraint relationship defined in the financial business scenario, the original semantic coherence judgment mark representing the additional verification is updated to a semantic coherence judgment mark representing semantic contradiction. Collect the semantic coherence judgment tags corresponding to all semantic type label adjacent relationship pairs in the semantic type label adjacent relationship pair sequence, and combine all semantic coherence judgment tags according to the order of the semantic type label adjacent relationship pair sequence to form the semantic coherence verification result.
8. The financial numerical formatting verification method for large model output according to claim 4, characterized in that, The method further includes: Obtain all abnormal text span intervals in the review result identifier sequence that are marked as non-compliant in terms of format, and extract the corresponding formatted numerical fragments and original numerical text fragments for each abnormal text span interval; The formatted numerical fragment and the original numerical text fragment are decomposed into feature-dimensional differences, and the feature-dimensional differences are decomposed into precision dimension difference components, separator dimension difference components, positive and negative sign dimension difference components, and leading zero dimension difference components. For each difference component, the source of deviation is traced. The difference component in the precision dimension is traced to the retrieval or application stage of the numerical precision digit constraint parameter, the difference component in the separator dimension is traced to the retrieval or application stage of the thousands separator usage constraint parameter, the difference component in the plus / minus dimension is traced to the retrieval or application stage of the plus / minus sign display constraint parameter, and the difference component in the leading zero dimension is traced to the retrieval or application stage of the leading zero filling constraint parameter, thereby generating a deviation source stage identifier for each difference component. Based on the deviation source link identifier of each difference component, a deviation propagation path is constructed from the deviation source link identifier to the abnormal text span interval. The deviation propagation path records the complete link link from the root link where the deviation is generated, through numerical semantic type label recognition and format reshaping processing, to the abnormal text span interval. The source links and propagation paths of all abnormal text spans are identified and summarized to generate a record of format deviation attribution.
9. The financial numerical formatting verification method for large model output according to claim 5, characterized in that, The method further includes: Obtain the original character sequence of each numerical text segment in the numerical text segment sequence, and establish a one-to-one correspondence storage relationship between the original character sequence and the corresponding numerical text segment in the numerical text segment sequence; Obtain the reshaped character sequence of each formatted numerical fragment in the formatted numerical fragment sequence, and establish a one-to-one correspondence between the reshaped character sequence and the corresponding formatted numerical fragment in the formatted numerical fragment sequence; Obtain the semantic type name and the rule identifier of the corresponding formatting constraint for each numerical semantic type label in the numerical semantic type label sequence, and establish a one-to-one correspondence storage relationship between the rule identifier and the corresponding numerical semantic type label in the numerical semantic type label sequence; For each text span interval, the original character sequence is used as the starting node for backtracking, the semantic type name of the numerical semantic type label and the rule identifier of the corresponding formatting constraint are used as the intermediate transformation node for backtracking, and the reshaped character sequence is used as the ending node for backtracking, thus constructing a single formatting operation backtracking chain. For each text span interval, the starting offset value and ending offset value of the single formatting operation backtracking chain are bound to the numerical fragment position binding mapping relationship table, and the actual position coordinate information of the corresponding financial value in the verified financial response text sequence is updated according to the construction logic of the recombined text unit. All formatted operation backtracking chains with accompanying location coordinate information corresponding to all text span intervals are arranged and combined according to the order in which the text span intervals appear in the verified financial response text sequence to generate formatted operation backtracking records.
10. A financial numerical formatting verification system for large model outputs, characterized in that, The method includes a processor and a computer-readable storage medium storing machine-executable instructions that, when executed by the processor, implement the financial numerical formatting and verification method for large model output as described in any one of claims 1-9.
