Data processing method and device, medium, electronic equipment and program product

By repairing JSON structure rules for the data fragments output by the target model, generating output results and triggering control instructions, the problem that the large model cannot parse the output content as soon as possible when executing the Agent task, and improving the task completion speed and response speed.

CN119781928APending Publication Date: 2025-04-08BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411856176.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-16
Publication Date
2025-04-08

AI Technical Summary

Technical Problem

When large models execute tasks with Agent capabilities, they often have problems that they cannot correctly parse the streaming output content as soon as possible, resulting in delayed task completion or inability to complete.

Method used

By obtaining the data fragments output by the target model stream, repairing the data fragments according to the preset JSON structure rules, generating the corresponding output results, and triggering the target control instruction.

Benefits of technology

It effectively avoids the problem of JSON structure errors in the model output data fragment and cannot be parsed, improves the response speed to streaming output results, shortens the task completion time, and avoids the user waiting time too long.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119781928A_ABST
    Figure CN119781928A_ABST
Patent Text Reader

Abstract

The invention provides a data processing method and device, a medium, electronic equipment and a program product, and the data processing method comprises the steps: carrying out the restoration processing of a data fragment outputted by a target model in a streaming manner, thereby obtaining an output result corresponding to the data fragment, triggering a subsequent control instruction through the output result, and carrying out the restoration processing of the data fragment. The phenomenon that JSON structure errors exist in data fragments output by a model and cannot be analyzed can be effectively avoided, the problem that JSON data can only be analyzed after the multiple data fragments are output can be avoided, the response speed of a streaming output result can be effectively increased, the task completion speed can be increased, and the efficiency of analyzing the JSON data is improved. Therefore, the task completion time is shortened, and the user waiting time is prevented from being too long.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular, to a data processing method, device, medium, electronic device and program product. Background Art

[0002] Due to the limitation of computing power, the current large model cannot achieve complete output in seconds under the traditional mode. In order to prevent users from waiting too long, the general approach is to output token by token. For example, when the large model is asked to output "Hello!", the large model can output "you" in the first second, "good" in the second second, "!" in the third second, and the end mark in the fourth second. However, when the large model executes tasks with agent capabilities, such as RAG (Retrieval-Augmented Generation), there is often a problem that the output content of the large model cannot be correctly parsed in the first time, which easily leads to delays in task completion or even failure to complete the task. Summary of the invention

[0003] This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.

[0004] In a first aspect, the present disclosure provides a data processing method, the method comprising:

[0005] Obtaining a data segment of a target model streaming output, wherein the data segment includes JSON (JavaScript Object Notation) data;

[0006] Repairing the data fragment according to a preset JSON structure rule to obtain a target code corresponding to the data fragment;

[0007] The target code is parsed to generate an output result corresponding to the data segment, and the output result is used to trigger the target control instruction.

[0008] In a second aspect, the present disclosure provides a data processing device, the device comprising:

[0009] An acquisition module is configured to acquire a data segment streamed output by a target model, wherein the data segment includes JSON data;

[0010] A repair module is configured to repair the data segment according to a preset JSON structure rule to obtain a target code corresponding to the data segment;

[0011] A generation module is configured to parse the target code to generate an output result corresponding to the data segment, and the output result is used to trigger a target control instruction.

[0012] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the method described in the first aspect above.

[0013] In a fourth aspect, the present disclosure provides an electronic device,

[0014] A processing device is used to execute the computer program in the storage device to implement the steps of the method described in the first aspect above.

[0015] In a fifth aspect, the present disclosure provides a computer program product, including a computer program, which implements the steps of the method described in the first aspect when executed by a processor.

[0016] The above technical solution, by repairing the data segment of the target model's streaming output, obtains the output result corresponding to the data segment, and triggers subsequent control instructions through the output result, can effectively avoid the phenomenon that the data segment output by the model has JSON structure errors and cannot be parsed, and can avoid the problem of having to wait until multiple data segments are output before parsing the JSON data. It can effectively improve the response speed to the streaming output results, which is conducive to improving the task completion speed, thereby achieving the effect of shortening the task completion time and avoiding users waiting for too long.

[0017] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale. In the drawings:

[0019] Figure 1 is a scenario schematic diagram of a data processing method shown in an exemplary embodiment of the present disclosure;

[0020] Figure 2 is a flow chart of a data processing method shown in an exemplary embodiment of the present disclosure;

[0021] Figure 3 is based on Figure 2 A flow chart of a data processing method shown in the illustrated embodiment;

[0022] Figure 4 is based on Figure 3 A flow chart of a data processing method shown in the illustrated embodiment;

[0023] Figure 5 is based on Figure 3 A flow chart of another data processing method shown in the illustrated embodiment;

[0024] Figure 6 is a block diagram of a data processing method shown in an exemplary embodiment of the present disclosure;

[0025] Figure 7 It is a block diagram of an electronic device shown in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION

[0026] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0027] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0028] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0029] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0030] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0031] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0032] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.

[0033] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.

[0034] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.

[0035] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.

[0036] At the same time, it is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.

[0037] Before introducing the specific implementation of the present disclosure in detail, the application scenario of the present disclosure is first described as follows. The present disclosure can be applied to the processing of the intermediate code output by the model stream when implementing the Agent / Function Call technology. For example, Figure 1 As shown in the figure, in a certain scenario, the large model needs to output {"text":"hello world"}, and then use the program to parse it, and perform the next search process based on the parsing result, such as Figure 1As shown, in the complete output mode, the user will be waiting for the first 3 seconds, and the data can only be parsed in the 4th second. In this way, when searching based on the parsed results, the user needs to wait at least 3 seconds before receiving the search feedback. In the streaming output mode, if the code output by the model needs to be parsed, since the JSON structure output from the 1st to the 3rd seconds is incomplete, no information can be parsed out. Only when the JSON data with a complete structure is obtained in the 4th second can the output result of the model be parsed, and then the next step of search processing can be performed based on the output result. Moreover, if the data in the 4th second is incorrect, such as the lack of a key identifier in the JSON structure, there will be a problem of being completely unable to parse the output result, which can easily lead to the phenomenon that the search task cannot be completed.

[0038] In order to solve the above technical problems, the present disclosure provides a data processing method, device, medium, electronic device and program product. The data processing method repairs the data segment streamed output by the target model to obtain the output result corresponding to the data segment, and triggers subsequent control instructions through the output result. It can effectively avoid the phenomenon that the data segment output by the model has JSON structure errors and cannot be parsed, and can avoid the problem of having to wait until multiple data segments are output before parsing the JSON data. It can effectively improve the response speed to the streaming output results, which is conducive to improving the task completion speed, thereby achieving the effect of shortening the task completion time and avoiding the user waiting time for too long.

[0039] Figure 2 is a flow chart of a data processing method shown in an exemplary embodiment of the present disclosure. Figure 2 As shown, the data processing method may include:

[0040] Step 201: Obtain data segments streamed from a target model, where the data segments include JSON data.

[0041] The target model may be an NLP (Natural Language Processing) model, a computer vision model, or a multimodal model such as a joint training model or an integrated model.

[0042] Step 202: repair the data segment according to a preset JSON structure rule to obtain a target code corresponding to the data segment.

[0043] For example, the preset JSON structure rules may include: using double quotes to surround string keys and values, numbers, Boolean values, and null as basic data types do not require quotes, data is organized in the form of objects (consisting of key-value pairs, surrounded by curly braces) or arrays (consisting of an ordered set of values, surrounded by square brackets), and elements or key-value pairs in objects and arrays must be separated by commas, etc.

[0044] Step 203: parsing the target code to generate an output result corresponding to the data segment, wherein the output result is used to trigger a target control instruction.

[0045] In one implementation, control instructions corresponding to different output results may be pre-set. After obtaining the current output result, a target control instruction is determined according to the current output result, and the target control instruction is input into the Agent system so that the Agent system executes the control task corresponding to the target control instruction in response to receiving the target control instruction.

[0046] In another implementation, after the output result is generated, the output result is input into a preset interface so that the preset interface performs a subsequent task according to the output result. The task may be a dialogue task, an image processing task, a search task, or an ordering task.

[0047] For example, in the intelligent customer service system of an e-commerce platform, the output end of the large model can be coupled with the interface of the Agent system. When the large model streams out data fragments, the data fragments are repaired to obtain the target code. By parsing the target code, the output content corresponding to the current data fragment is obtained. The Agent system can generate further target control instructions based on the output content. For example, when the output content is "women's clothing", the Agent system can trigger a search instruction based on the "women's clothing" to obtain the corresponding order information, and further complete the corresponding recommendation task or dialogue task based on the order information.

[0048] The above technical solution repairs the data segment of the target model's streaming output to obtain the output result corresponding to the data segment, and triggers subsequent control instructions through the output result, which can avoid the problem of having to wait until multiple data segments are output before correctly parsing the JSON data. It can effectively improve the response speed to the streaming output results, which is conducive to improving the task completion speed, thereby shortening the task completion time and avoiding the user's waiting time for too long. It can also effectively avoid the phenomenon that the data segment output by the model has JSON structure errors and cannot be parsed.

[0049] Figure 3 is based on Figure 2 The embodiment shown is a flow chart of a data processing method, such as Figure 3 As shown, Figure 2 The step 102 of repairing the data segment according to the preset JSON structure rule to obtain the target code corresponding to the data segment may include:

[0050] Step 1021: Use the first character in the data segment as the current character.

[0051] Step 1022, determining the character type of the current character in the data segment.

[0052] Among them, the character type is an object start identifier, an object end identifier, an array start identifier, an array end identifier or a program end identifier; the object start identifier is the first half of the curly brackets "{", the object end identifier is the second half of the curly brackets "}", the array start identifier is the first half of the square brackets "[", the array end identifier is the second half of the square brackets "[", and the program end identifier is used to represent the end of the JSON data in the data segment, for example, it can be EOF.

[0053] Step 1023, determining whether the character type is a program end mark.

[0054] If it is determined that the character type is not the program end mark, step 1024 is executed; if it is determined that the current character is the program end mark, step 1027 is executed.

[0055] Step 1024: determine a current repair segment from the data segments according to the character type of the current character.

[0056] The implementation of this step may include the following scenarios:

[0057] Scenario 1: When it is determined that the character type is the object start identifier, if it is determined that an object end identifier corresponding to the object start identifier exists in the data segment, the data between the object start identifier and the object end identifier in the data segment is used as the current repair segment.

[0058] It should be noted that, when the data segment includes multiple layers of nested objects, the object end identifier “}” corresponding to the object start identifier “{” can be understood as a group of object identifiers at the same nesting depth.

[0059] For example, taking the following code 1 as an example, the object end identifier “}” corresponding to the first object start identifier “{” is an object end identifier at the same depth as the first object start identifier. Therefore, the object end identifier “}” corresponding to the first object start identifier “{” should be the “}” in the last line of the code.

[0060] Code 1:

[0061]

[0062] Still taking code 1 as an example, if code 1 is a data segment of the lost output, the first character "{" is used as the current character, the character type of "{" is determined as the object start identifier, and it is determined that there is a "}" corresponding to the first character "{" in the data segment, so the data between the outermost "{}" in code 1 (together with the outermost "{}") can be used as the current repair segment.

[0063] Scenario 2: When it is determined that the character type is the object start identifier, if it is determined that the object end identifier corresponding to the object start identifier does not exist in the data segment, the data after the current character in the data segment is used as the current repair segment.

[0064] For example, taking the following code 2 as an example, code 2 is JSON data in a data segment, and there is no object end identifier "}" corresponding to "{" in the data segment, then all the data after the "{" (together with the "{") can be used as the current repair segment.

[0065] Code 2:

[0066]

[0067] Scenario three, when it is determined that the character type is the object end marker, the key value interval data before the current character in the data segment is used as the current repair segment, and the key value interval data includes one or more consecutive key value pairs, and punctuation between adjacent key value pairs.

[0068] For example, taking the following code 3 as an example, code 3 is JSON data in the data segment, and determining that the character type of the current character is an object end marker, for example, the current character is the "}" in the last line of code 3, then taking all the key-value pairs before the "}" in the last line, and the punctuation between the key-value pairs, i.e., the comma, (together with the "}") as the current repair segment.

[0069] Code 3:

[0070]

[0071] Scenario four, when it is determined that the character type is an array start identifier, if it is determined that an array end identifier corresponding to the array start identifier exists in the data segment, the data between the array start identifier and the array end identifier in the data segment is used as the current repair segment.

[0072] It should be noted that, when the data segment includes multiple layers of nested arrays, the array end identifier “]” corresponding to the array start identifier “[” can be understood as a group of array identifiers “[]” at the same nesting depth.

[0073] For example, take the following code 4 as an example, which is JSON data in the data segment. If the current character is the first "[", the array end marker corresponding to the first "[" is the last "]" in code 4. Since there is an array end marker "]" corresponding to the first "[" in code 4, [1, [2, 3], [4, [5, 6]], 7] can be used as the current repair segment.

[0074] Code 4:

[0075] [1,[2,3],[4,[5,6]],7]

[0076] Scenario five, when it is determined that the character type is the array start identifier, if it is determined that the array end identifier corresponding to the array start identifier does not exist in the data segment, the data after the array start identifier in the data segment is used as the current repair segment.

[0077] For example, taking the following code 5 as an example, code 5 is the JSON data in the data segment. Since the array end marker "]" corresponding to the first "[" does not exist in code 5, 1, [2, 3], [4, [5, 6]], 7 after the first "[" can be used as the current repair segment.

[0078] Code 5:

[0079] [1,[2,3],[4,[5,6]],7

[0080] Scenario six: when it is determined that the character type is the array end marker, the array elements before the array end marker and the punctuation between adjacent array elements in the data segment are used as the current repair segment.

[0081] For example, taking the following code 6 as an example, code 6 is JSON data in the data segment, and the current character is "]". Since there is no "[" corresponding to the array end mark "]" in code 6, the array elements before "]" and the punctuation between the adjacent array elements (together with "]") can be used as the current repair segment.

[0082] Code 6:

[0083]

[0084] Step 1025: perform a correction operation on the current repair segment according to the preset JSON structure rule.

[0085] This step can be implemented as follows Figure 4 As shown, Figure 4 is based on Figure 3 The embodiment shown is a flowchart of a data processing method, and step 1025 may include:

[0086] S11, determining the key field and the value field in the current repair fragment.

[0087] Among them, by identifying the ":" in the key-value pair, the character string before the ":" can be used as the key field, and the data after the ":" can be used as the value field.

[0088] S12, identifying data of a first preset data type in the key field, and identifying data of a second preset data type in the value field.

[0089] The first preset data type may be a string, a reserved word, a number, and a comma, and the second preset data type may be a string. It should be noted that the identification of the character types such as the string, the reserved word, the number, and the comma may be determined by a regular expression, which is relatively mature in the prior art and is not limited in the present disclosure.

[0090] S13, when it is determined that the data of the first preset data type and the data of the second preset data type do not conform to the preset JSON structure rules, correction operations are performed on the data of the first preset data type in the key field and the data of the second preset data type in the value field according to the preset JSON structure rules to obtain the corrected data corresponding to the current repair fragment.

[0091] Among them, the preset JSON structure rules stipulate that the data in the key field needs to be surrounded by double quotes, the string in the value field needs to be surrounded by double quotes, numbers, reserved words and commas as basic data types do not require quotes, data is organized in the form of or array (composed of an ordered set of values, surrounded by square brackets), objects consist of key-value pairs, surrounded by curly braces, arrays consist of an ordered set of values, surrounded by square brackets, and objects and elements or key-value pairs in arrays must be separated by commas.

[0092] In this step, when the data of the first preset data type in the key field and the data of the second preset data type in the value field are modified according to the preset JSON structure rule, the character string, reserved words, numbers and commas in the key field can be enclosed in double quotes, and the character string in the value field can be enclosed in double quotes. In this way, the JSON data in the current repair segment can be effectively modified through the above S11 to S13.

[0093] In addition, it should be noted that the corrected data obtained in this step can be stored in a stack, and when the data in the data segment is corrected, the characters in the stack are completed by popping the data.

[0094] Step 1026: Use the first character after the current repair segment as the updated current character.

[0095] For example, taking code 7 as an example, the current repair segment is determined to be:

[0096] "city":"New York",

[0097] "country":"USA"

[0098] }

[0099] Afterwards, the first character after the current repair segment (i.e., the comma) is used as the updated current character. Since the comma is not an object start identifier, an object end identifier, an array start identifier, an array end identifier, or a program end identifier, it can be skipped directly, and the next character (the leading quotation mark) is used as the current character. Since the leading quotation mark is not an object start identifier, an object end identifier, an array start identifier, an array end identifier, or a program end identifier, it is skipped continuously. Similarly, until the character [ is reached, it is determined to belong to the array start identifier. The next current repair segment is determined again according to the scheme in step 1024. This cycle is repeated until the current character is a program end identifier, and step 1027 is executed.

[0100] Code 7:

[0101]

[0102] Step 1027: Completing the corrected data corresponding to the data segment to obtain the target code corresponding to the data segment.

[0103] This step can be implemented as follows Figure 5 As shown, Figure 5 is based on Figure 3 The embodiment shown is a flowchart of another data processing method, and step 1026 may include:

[0104] S21, when it is determined that the corrected data corresponding to the data segment is JSON data with an incomplete structure, determine the missing structure identifier in the corrected data according to the preset JSON structure rule.

[0105] In this case, whether the corrected data is JSON data with a complete structure can be determined by calling JSON.parse().

[0106] In this step, the second half structure identifier corresponding to each first half structure identifier in the corrected data can be determined; when it is determined that the first half structure identifier in the corrected data has a corresponding second half structure identifier, the target structure data between the first half structure identifier and the second half structure identifier is determined as the verification qualified data; when it is determined that the first half structure identifier in the corrected data does not have a corresponding second half structure identifier, the second half structure identifier is used as the missing structure identifier corresponding to the first half structure identifier in the corrected data.

[0107] Among them, the first half structure identifier can be an object start identifier, an object end identifier, an array start identifier or an array end identifier, and the second half structure identifier is the other half structure identifier that matches the first half structure identifier. For example, when the first half structure identifier is an object start identifier, the second half structure identifier is an object end identifier; when the first half structure identifier is an object end identifier, the second half structure identifier is an object start identifier; when the first half structure identifier is an array end identifier, the second half structure identifier is an array start identifier; when the first half structure identifier is an array end identifier, the second half structure identifier is an array start identifier.

[0108] For example, if the corrected data is [1, [2, 3], [4, [5, 6]], 7, where [2, 3], [4, [5, 6]] have corresponding second half structure identifiers for the first half structure identifiers, and therefore [2, 3], [4, [5, 6]] are all verified data. In some embodiments, verified data identifiers are generated for [2, 3], [4, [5, 6]]. Since the first “[” does not have a corresponding second half structure identifier, the second half structure identifier “]” corresponding to the first “[” is the missing structure identifier.

[0109] S22, completing the missing structure identifier to obtain the target code.

[0110] In one implementation, when it is determined that the corrected data includes the verified data, if the first half structure identifier is a post-structure identifier, the missing structure identifier is added before the verified data to obtain the target code; if the first half structure identifier is a pre-structure identifier, the missing structure identifier is added after the verified data to obtain the target code.

[0111] The latter structure is identified by the second half of the curly bracket “}” or the second half of the square bracket “]”, and the former structure is identified by the first half of the curly bracket “{” or the second half of the square bracket “[”.

[0112] For example, if the corrected data is [1, [2, 3], [4, [5, 6]], 7, since the first half structure identifier is the front structure identifier “[”, [2, 3], [4, [5, 6]] are verified qualified data, therefore, “]” is added after [5, 6]]. When there are other characters after [5, 6]], it is determined whether the character belongs to an element in the first half structure identifier and the second half structure identifier. If it is determined that the character belongs to an element in the first half structure identifier and the second half structure identifier, “]” is added after the character. If it is determined that the character does not belong to an element in the first half structure identifier and the second half structure identifier, “]” is added before the character and after [5, 6]].

[0113] In another implementation, when it is determined that the corrected data does not include the verified data, if the first half structure identifier is a post-structure identifier, the missing structure identifier is added before the corrected data to obtain the target code; if the first half structure identifier is a pre-structure identifier, the missing structure identifier is added after the corrected data to obtain the target code.

[0114] For example, if the corrected data is:

[0115]

[0116] Since the first half structure identifier is the front structure identifier "{", the missing structure identifier "}" is added after the corrected data, that is, "}" is added to the last line of the code.

[0117] If the repaired code is:

[0118]

[0119] Since the first half structure identifier is the front structure identifier "}", the missing structure identifier "{" is added before the corrected data, that is, "{" is added to the first line of the code.

[0120] The above technical solution, by repairing the data segment of the target model's streaming output, obtains the output result corresponding to the data segment, and triggers subsequent control instructions through the output result, which can avoid the problem of having to wait until multiple data segments are output before correctly parsing the JSON data. It can effectively improve the response speed to the streaming output results, which is conducive to improving the task completion speed, thereby achieving the effect of shortening the task completion time and avoiding the user's waiting time for too long; and it can effectively avoid the phenomenon that the data segment output by the model has JSON structure errors and cannot be parsed.

[0121] Figure 6 is a block diagram of a data processing method shown in an exemplary embodiment of the present disclosure, such as Figure 6 As shown, the data processing device may include:

[0122] An acquisition module 601 is configured to acquire a data segment stream-outputted by a target model, wherein the data segment includes JSON data;

[0123] A repair module 602 is configured to repair the data segment according to a preset JSON structure rule to obtain a target code corresponding to the data segment;

[0124] The generating module 603 is configured to parse the target code to generate an output result corresponding to the data segment, and the output result is used to trigger the target control instruction.

[0125] The above technical solution, by repairing the data segment streamed output by the target model, obtains the output result corresponding to the data segment, and triggers subsequent control instructions through the output result, which can avoid the problem of having to wait until multiple data segments are output before correctly parsing the JSON data, thereby effectively improving the response speed to the streaming output results, which is conducive to improving the task completion speed, thereby achieving the effect of shortening the task completion time and avoiding the user waiting time for too long; and can effectively avoid the phenomenon that the data segment output by the model has JSON structure errors and cannot be parsed.

[0126] Optionally, the repair module 602 is configured to:

[0127] Taking the first character in the data segment as the current character;

[0128] Determine a character type of a current character in the data segment, where the character type is an object start identifier, an object end identifier, an array start identifier, an array end identifier, or a program end identifier;

[0129] Determine whether the character type is a program end identifier; the program end identifier is used to indicate the end of the JSON data in the data segment;

[0130] When it is determined that the character type is not the program end identifier, the data segment is repaired according to the character type and a preset JSON structure rule.

[0131] Optionally, the repair module 602 is configured to:

[0132] Determining a current repair segment from the data segments according to the character type of the current character;

[0133] The data segment is repaired according to the current repair segment and in accordance with preset JSON structure rules.

[0134] Optionally, the repair module 602 is configured to:

[0135] Performing a correction operation on the current repair segment according to the preset JSON structure rule;

[0136] The first character after the current repair segment is used as the updated current character, and the steps of determining the character type of the current character in the data segment to determining whether the character type is a program end marker are re-executed, until it is determined that the current character is a program end marker, and the corrected data corresponding to the data segment is completed to obtain the target code corresponding to the data segment.

[0137] Optionally, the repair module 602 is configured to:

[0138] When it is determined that the character type is the object start identifier, if it is determined that an object end identifier corresponding to the object start identifier exists in the data segment, the data between the object start identifier and the object end identifier in the data segment is used as the current repair segment.

[0139] Optionally, the repair module 602 is configured to:

[0140] In the case where it is determined that the character type is the object start identifier, if it is determined that the object end identifier corresponding to the object start identifier does not exist in the data segment, the data after the current character in the data segment is used as the current repair segment.

[0141] Optionally, the repair module 602 is configured to:

[0142] When it is determined that the character type is the object end marker, the key value interval data before the current character in the data segment is used as the current repair segment, and the key value interval data includes one or more continuous key value pairs and punctuation between adjacent key value pairs.

[0143] Optionally, the repair module 602 is configured to:

[0144] When it is determined that the character type is an array start identifier, if it is determined that an array end identifier corresponding to the array start identifier exists in the data segment, the data between the array start identifier and the array end identifier in the data segment is used as the current repair segment.

[0145] Optionally, the repair module 602 is configured to:

[0146] In the case where it is determined that the character type is the array start identifier, if it is determined that an array end identifier corresponding to the array start identifier does not exist in the data segment, the data after the array start identifier in the data segment is used as the current repair segment.

[0147] Optionally, the repair module 602 is configured to:

[0148] When it is determined that the character type is the array end marker, the array elements before the array end marker and the punctuation between adjacent array elements in the data segment are used as the current repair segment.

[0149] Optionally, the repair module 602 is configured to:

[0150] Determine the key field and the value field in the current repair fragment;

[0151] identifying data of a first preset data type in the key field, and identifying data of a second preset data type in the value field;

[0152] When it is determined that the data of the first preset data type and the data of the second preset data type do not conform to the preset JSON structure rules, correction operations are performed on the data of the first preset data type in the key field and the data of the second preset data type in the value field according to the preset JSON structure rules to obtain corrected data corresponding to the current repair fragment.

[0153] Optionally, the repair module 602 is configured to:

[0154] In the case where it is determined that the corrected data corresponding to the data segment is JSON data with an incomplete structure, determining a missing structure identifier in the corrected data according to the preset JSON structure rule;

[0155] The missing structure identifier is completed to obtain the target code.

[0156] Optionally, the repair module 602 is configured to:

[0157] Determine a second half structure identifier corresponding to each first half structure identifier in the corrected data;

[0158] In a case where it is determined that the first half structure identifier in the corrected data has a corresponding second half structure identifier, determining the target structure data between the first half structure identifier and the second half structure identifier as verification qualified data;

[0159] When it is determined that the first half structure identifier in the corrected data does not have a corresponding second half structure identifier, the second half structure identifier is used as a missing structure identifier corresponding to the first half structure identifier in the corrected data.

[0160] Optionally, the repair module 602 is configured to:

[0161] In the case where it is determined that the corrected data includes the verification-qualified data, if the first half structure identifier is a post-structure identifier, adding the missing structure identifier before the verification-qualified data to obtain the target code;

[0162] If the first half structure identifier is the front structure identifier, the missing structure identifier is added after the verification qualified data to obtain the target code.

[0163] Optionally, the repair module 602 is configured to:

[0164] In the case where it is determined that the corrected data does not include the verified data, if the first half structure identifier is a post-structure identifier, adding the missing structure identifier before the corrected data to obtain the target code;

[0165] If the first half structure identifier is the front structure identifier, the missing structure identifier is added after the corrected data to obtain the target code.

[0166] The above technical solution, by repairing the data segment streamed output by the target model, obtains the output result corresponding to the data segment, and triggers subsequent control instructions through the output result, which can avoid the problem of having to wait until multiple data segments are output before correctly parsing the JSON data, thereby effectively improving the response speed to the streaming output results, which is conducive to improving the task completion speed, thereby achieving the effect of shortening the task completion time and avoiding the user waiting time for too long; and can effectively avoid the phenomenon that the data segment output by the model has JSON structure errors and cannot be parsed.

[0167] In another embodiment of the present disclosure, a computer readable medium is provided on which a computer program is stored. When the computer program is executed by a processing device, the above Figures 1 to 5 The steps of any one of the methods described in .

[0168] In another embodiment of the present disclosure, an electronic device is provided, including:

[0169] a storage device having a computer program stored thereon;

[0170] A processing device, configured to execute the computer program in the storage device to achieve the above Figures 1 to 5 The steps of any one of the methods described in .

[0171] In another embodiment of the present disclosure, a computer program product is provided, including a computer program, which implements the above when executed by a processor. Figures 1 to 5 The steps of any of the methods described above.

[0172] Reference below Figure 7 , which shows a schematic diagram of the structure of an electronic device (such as a terminal device or a server) 700 suitable for implementing the embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0173] like Figure 7 As shown, the electronic device 700 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0174] Typically, the following devices may be connected to the I / O interface 705: an input device 706 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 707 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 708 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 709. The communication device 709 may allow the electronic device 700 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7The electronic device 700 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0175] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 709, or installed from a storage device 708, or installed from a ROM 702. When the computer program is executed by the processing device 701, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0176] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0177] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0178] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0179] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: obtains a data segment streamed output by the target model, wherein the data segment includes JSON data; repairs the data segment according to preset JSON structure rules to obtain a target code corresponding to the data segment; and parses the target code to generate an output result corresponding to the data segment, wherein the output result is used to trigger a target control instruction.

[0180] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0181] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0182] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of the module does not limit the module itself in some cases. For example, the acquisition module may also be described as "acquiring a data segment streamed output by the target model, wherein the data segment includes JSON data".

[0183] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0184] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0185] According to one or more embodiments of the present disclosure, Example 1 provides a data processing method, the method comprising:

[0186] Obtain a data segment of a target model streaming output, wherein the data segment includes JSON data;

[0187] Repairing the data fragment according to a preset JSON structure rule to obtain a target code corresponding to the data fragment;

[0188] The target code is parsed to generate an output result corresponding to the data segment, and the output result is used to trigger the target control instruction.

[0189] According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1, wherein the repairing process of the data segment according to the preset JSON structure rule to obtain the target code corresponding to the data segment includes:

[0190] Taking the first character in the data segment as the current character;

[0191] Determine a character type of a current character in the data segment, where the character type is an object start identifier, an object end identifier, an array start identifier, an array end identifier, or a program end identifier;

[0192] Determine whether the character type is a program end identifier;

[0193] When it is determined that the character type is not the program end identifier, the data segment is repaired according to the character type and a preset JSON structure rule.

[0194] According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 2, wherein the repairing process of the data segment according to the character type and the preset JSON structure rule includes:

[0195] Determining a current repair segment from the data segments according to the character type of the current character;

[0196] The data segment is repaired according to the current repair segment and in accordance with preset JSON structure rules.

[0197] According to one or more embodiments of the present disclosure, Example 4 provides the method of Example 3, wherein the step of repairing the data segment according to the current repair segment in accordance with a preset JSON structure rule includes:

[0198] Performing a correction operation on the current repair segment according to the preset JSON structure rule;

[0199] The first character after the current repair segment is used as the updated current character, and the steps of determining the character type of the current character in the data segment to determining whether the character type is a program end marker are re-executed, until it is determined that the current character is a program end marker, and the corrected data corresponding to the data segment is completed to obtain the target code corresponding to the data segment.

[0200] According to one or more embodiments of the present disclosure, Example 5 provides the method of Example 3, wherein determining the current repair segment from the data segment according to the character type includes:

[0201] When it is determined that the character type is the object start identifier, if it is determined that an object end identifier corresponding to the object start identifier exists in the data segment, the data between the object start identifier and the object end identifier in the data segment is used as the current repair segment.

[0202] According to one or more embodiments of the present disclosure, Example 6 provides the method of Example 3, wherein determining the current repair segment from the data segment according to the character type includes:

[0203] In the case where it is determined that the character type is the object start identifier, if it is determined that the object end identifier corresponding to the object start identifier does not exist in the data segment, the data after the current character in the data segment is used as the current repair segment.

[0204] According to one or more embodiments of the present disclosure, Example 7 provides the method of Example 3, wherein determining the current repair segment from the data segment according to the character type includes:

[0205] When it is determined that the character type is the object end marker, the key value interval data before the current character in the data segment is used as the current repair segment, and the key value interval data includes one or more continuous key value pairs and punctuation between adjacent key value pairs.

[0206] According to one or more embodiments of the present disclosure, Example 8 provides the method of Example 3, wherein determining the current repair segment from the data segment according to the character type includes:

[0207] When it is determined that the character type is an array start identifier, if it is determined that an array end identifier corresponding to the array start identifier exists in the data segment, the data between the array start identifier and the array end identifier in the data segment is used as the current repair segment.

[0208] According to one or more embodiments of the present disclosure, Example 9 provides the method of Example 3, wherein determining the current repair segment from the data segment according to the character type includes:

[0209] In the case where it is determined that the character type is the array start identifier, if it is determined that an array end identifier corresponding to the array start identifier does not exist in the data segment, the data after the array start identifier in the data segment is used as the current repair segment.

[0210] According to one or more embodiments of the present disclosure, Example 10 provides the method of Example 3, wherein determining the current repair segment from the data segment according to the character type includes:

[0211] When it is determined that the character type is the array end marker, the array elements before the array end marker and the punctuation between adjacent array elements in the data segment are used as the current repair segment.

[0212] According to one or more embodiments of the present disclosure, Example 11 provides the method of Example 4, wherein the step of performing a correction operation on the current repair segment according to the preset JSON structure rule includes:

[0213] Determine the key field and the value field in the current repair fragment;

[0214] identifying data of a first preset data type in the key field, and identifying data of a second preset data type in the value field;

[0215] When it is determined that the data of the first preset data type and the data of the second preset data type do not conform to the preset JSON structure rules, correction operations are performed on the data of the first preset data type in the key field and the data of the second preset data type in the value field according to the preset JSON structure rules to obtain corrected data corresponding to the current repair fragment.

[0216] According to one or more embodiments of the present disclosure, Example 12 provides the method of Example 4, wherein the step of performing a completion operation on the corrected data corresponding to the data segment to obtain a target code corresponding to the data segment includes:

[0217] In the case where it is determined that the corrected data corresponding to the data segment is JSON data with an incomplete structure, determining a missing structure identifier in the corrected data according to the preset JSON structure rule;

[0218] The missing structure identifier is completed to obtain the target code.

[0219] According to one or more embodiments of the present disclosure, Example 13 provides the method of Example 12, wherein determining the missing structure identifier in the corrected data according to the preset JSON structure rule includes:

[0220] Determine a second half structure identifier corresponding to each first half structure identifier in the corrected data;

[0221] In a case where it is determined that the first half structure identifier in the corrected data has a corresponding second half structure identifier, determining the target structure data between the first half structure identifier and the second half structure identifier as verification qualified data;

[0222] When it is determined that the first half structure identifier in the corrected data does not have a corresponding second half structure identifier, the second half structure identifier is used as a missing structure identifier corresponding to the first half structure identifier in the corrected data.

[0223] According to one or more embodiments of the present disclosure, Example 14 provides the method of Example 13, wherein the step of completing the missing structure identifier to obtain the target code includes:

[0224] In the case where it is determined that the corrected data includes the verification-qualified data, if the first half structure identifier is a post-structure identifier, adding the missing structure identifier before the verification-qualified data to obtain the target code;

[0225] If the first half structure identifier is the front structure identifier, the missing structure identifier is added after the verification qualified data to obtain the target code.

[0226] According to one or more embodiments of the present disclosure, Example 15 provides the method of Example 13, wherein the step of completing the missing structure identifier to obtain the target code includes:

[0227] In the case where it is determined that the corrected data does not include the verified data, if the first half structure identifier is a post-structure identifier, adding the missing structure identifier before the corrected data to obtain the target code;

[0228] If the first half structure identifier is the front structure identifier, the missing structure identifier is added after the corrected data to obtain the target code.

[0229] According to one or more embodiments of the present disclosure, Example 16 provides a data processing device, the device comprising:

[0230] An acquisition module is configured to acquire a data segment streamed output by a target model, wherein the data segment includes JSON data;

[0231] A repair module is configured to repair the data segment according to a preset JSON structure rule to obtain a target code corresponding to the data segment;

[0232] A generation module is configured to parse the target code to generate an output result corresponding to the data segment, and the output result is used to trigger a target control instruction.

[0233] According to one or more embodiments of the present disclosure, Example 17 provides a computer-readable medium having a computer program stored thereon, which implements the steps of any of the methods described in Examples 1-15 when executed by a processing device.

[0234] According to one or more embodiments of the present disclosure, Example 18 provides an electronic device, including:

[0235] a storage device having a computer program stored thereon;

[0236] A processing device is used to execute the computer program in the storage device to implement the steps of the method described in any one of Examples 1-15.

[0237] According to one or more embodiments of the present disclosure, Example 19 provides a computer program product, including a computer program, which implements the steps of any one of the methods of Examples 1 to 15 when executed by a processor.

[0238] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0239] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0240] Although the subject matter has been described in language specific to structural features and / or method logic actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims. Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.

Claims

1. A data processing method, characterized in that: The method comprises: Obtain a data segment of a target model streaming output, wherein the data segment includes JSON data; Repairing the data fragment according to a preset JSON structure rule to obtain a target code corresponding to the data fragment; The target code is parsed to generate an output result corresponding to the data segment, and the output result is used to trigger the target control instruction.

2. The data processing method according to claim 1, characterized in that: The repairing process of the data fragment according to the preset JSON structure rule to obtain the target code corresponding to the data fragment includes: Taking the first character in the data segment as the current character; Determine a character type of a current character in the data segment, where the character type is an object start identifier, an object end identifier, an array start identifier, an array end identifier, or a program end identifier; Determine whether the character type is a program end identifier; When it is determined that the character type is not the program end identifier, the data segment is repaired according to the character type and a preset JSON structure rule.

3. The data processing method according to claim 2, characterized in that: The repairing process of the data fragment according to the character type and the preset JSON structure rule includes: Determining a current repair segment from the data segments according to the character type of the current character; The data segment is repaired according to the current repair segment and in accordance with preset JSON structure rules.

4. The data processing method according to claim 3, characterized in that: The repairing the data segment according to the current repair segment according to a preset JSON structure rule includes: Performing a correction operation on the current repair segment according to the preset JSON structure rule; The first character after the current repair segment is used as the updated current character, and the steps of determining the character type of the current character in the data segment to determining whether the character type is a program end marker are re-executed, until it is determined that the current character is a program end marker, and the corrected data corresponding to the data segment is completed to obtain the target code corresponding to the data segment.

5. The data processing method according to claim 3, characterized in that: The step of determining a current repair segment from the data segment according to the character type comprises: When it is determined that the character type is the object start identifier, if it is determined that an object end identifier corresponding to the object start identifier exists in the data segment, the data between the object start identifier and the object end identifier in the data segment is used as the current repair segment.

6. The data processing method according to claim 3, characterized in that: The step of determining a current repair segment from the data segment according to the character type comprises: In the case where it is determined that the character type is the object start identifier, if it is determined that the object end identifier corresponding to the object start identifier does not exist in the data segment, the data after the current character in the data segment is used as the current repair segment.

7. The data processing method according to claim 3, characterized in that: The step of determining a current repair segment from the data segment according to the character type comprises: When it is determined that the character type is the object end marker, the key value interval data before the current character in the data segment is used as the current repair segment, and the key value interval data includes one or more continuous key value pairs and punctuation between adjacent key value pairs.

8. The data processing method according to claim 3, characterized in that: The step of determining a current repair segment from the data segment according to the character type comprises: When it is determined that the character type is an array start identifier, if it is determined that an array end identifier corresponding to the array start identifier exists in the data segment, the data between the array start identifier and the array end identifier in the data segment is used as the current repair segment.

9. The data processing method according to claim 3, characterized in that: The step of determining a current repair segment from the data segment according to the character type comprises: In the case where it is determined that the character type is the array start identifier, if it is determined that an array end identifier corresponding to the array start identifier does not exist in the data segment, the data after the array start identifier in the data segment is used as the current repair segment.

10. The data processing method according to claim 3, characterized in that: The step of determining a current repair segment from the data segment according to the character type comprises: When it is determined that the character type is the array end marker, the array elements before the array end marker and the punctuation between adjacent array elements in the data segment are used as the current repair segment.

11. The data processing method according to claim 4, characterized in that: The correcting operation on the current repair segment according to the preset JSON structure rule includes: Determine the key field and the value field in the current repair fragment; identifying data of a first preset data type in the key field, and identifying data of a second preset data type in the value field; When it is determined that the data of the first preset data type and the data of the second preset data type do not conform to the preset JSON structure rules, correction operations are performed on the data of the first preset data type in the key field and the data of the second preset data type in the value field according to the preset JSON structure rules to obtain corrected data corresponding to the current repair fragment.

12. The data processing method according to claim 4, characterized in that: The performing a completion operation on the corrected data corresponding to the data segment to obtain a target code corresponding to the data segment includes: In the case where it is determined that the corrected data corresponding to the data segment is JSON data with an incomplete structure, determining a missing structure identifier in the corrected data according to the preset JSON structure rule; The missing structure identifier is completed to obtain the target code.

13. The data processing method according to claim 12, characterized in that: The determining the missing structure identifier in the corrected data according to the preset JSON structure rule includes: Determine a second half structure identifier corresponding to each first half structure identifier in the corrected data; In a case where it is determined that the first half structure identifier in the corrected data has a corresponding second half structure identifier, determining the target structure data between the first half structure identifier and the second half structure identifier as verification qualified data; When it is determined that the first half structure identifier in the corrected data does not have a corresponding second half structure identifier, the second half structure identifier is used as a missing structure identifier corresponding to the first half structure identifier in the corrected data.

14. The data processing method according to claim 13, characterized in that: The method of completing the missing structure identifier to obtain the target code includes: In the case where it is determined that the corrected data includes the verification-qualified data, if the first half structure identifier is a post-structure identifier, adding the missing structure identifier before the verification-qualified data to obtain the target code; If the first half structure identifier is the front structure identifier, the missing structure identifier is added after the verification qualified data to obtain the target code.

15. The data processing method according to claim 13, characterized in that: The method of completing the missing structure identifier to obtain the target code includes: In the case where it is determined that the corrected data does not include the verified data, if the first half structure identifier is a post-structure identifier, adding the missing structure identifier before the corrected data to obtain the target code; If the first half structure identifier is the front structure identifier, the missing structure identifier is added after the corrected data to obtain the target code.

16. A data processing device, characterized in that: The device comprises: An acquisition module is configured to acquire a data segment streamed output by a target model, wherein the data segment includes JSON data; A repair module is configured to repair the data segment according to a preset JSON structure rule to obtain a target code corresponding to the data segment; A generation module is configured to parse the target code to generate an output result corresponding to the data segment, and the output result is used to trigger a target control instruction.

17. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processing device, the steps of the method according to any one of claims 1 to 15 are implemented.

18. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 15.

19. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 15 are implemented.

Citation Information

Cited By

  • Method and system for realizing progressive user interface rendering through real-time completion

    CN121255321A