Method for rendering display of model output data and electronic device

By preprocessing the data output by the AI ​​language model streaming, predicting and completing or deleting temporary markers, the structural anomaly problem in the streaming rendering process is solved, improving the rendering effect and user experience.

CN122287550APending Publication Date: 2026-06-26UC MOBILE CHINA CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610142012.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-30
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

During the streaming output of AI language models, rendering anomalies and structural abrupt changes caused by the incompleteness of markup language in structured documents affect the user experience.

Method used

By parsing the model output data through a preprocessing module outside or inside the rendering engine, predicting the structure type, and completing or deleting temporary markers, the rendering engine can ensure that it can perceive the complete markers in advance or with a delay, thereby performing correct data rendering.

Benefits of technology

It effectively avoids or reduces structural anomalies and mutations, improving the stability and visual consistency of the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122287550A_ABST
    Figure CN122287550A_ABST
Patent Text Reader

Abstract

This application discloses a method and electronic device for rendering and displaying model output data, including: receiving and parsing current data from a structured document streamed by an artificial intelligence (AI) language model to predict the structure type corresponding to a target tag included in the current data; the structure type includes: a structure type defined for the main content in the structured document; if the markup language corresponding to the predicted structure type consists of multiple tags existing in pairs or groups, and the target tag belongs to a tag pair or group, then based on the other tags in the tag pair or group, temporary tags are added to the current data and provided to the rendering engine, so that the rendering engine can perform data rendering when it perceives the complete tags corresponding to the structure type in advance. Through this application embodiment, structural anomalies or structural mutations can be avoided or reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data display technology, and in particular to methods and electronic devices for rendering and displaying model output data. Background Technology

[0002] With the rapid development of AI (Artificial Intelligence) modeling technology, AI language models are widely used in the field of text content generation. However, due to their technical characteristics, AI language models present some challenges in the front-end rendering process when generating structured documents in formats such as Markdown.

[0003] For example, to provide a better interactive experience, AI language models often adopt a "streaming output" approach, which means that the model generates a word or a fragment and immediately sends it to the front end for rendering and display, rather than waiting for all the content to be generated before displaying it all at once. This approach simulates the effect of a "typewriter," allowing users to see the content generation process word by word, which significantly improves the interactive experience.

[0004] In the aforementioned streaming process, the model typically outputs on a token-by-token basis. However, structured documents often use tags or tag pairs to express specific structured information. For example, in Markdown syntax, if a pair of "**" tags appears at the beginning and end of text content, it means that this text content needs to be rendered as bold during rendering. Additionally, other structured information types such as code blocks and tables are also typically expressed using specific tags or tag pairs. During the streaming output of an AI language model, this structured information expressed through tags or tag pairs may be broken into multiple fragments, arriving at different times. For example, suppose a portion of structured information, if fully expressed, could be "**Conclusion is as follows:**", meaning that the text content "Conclusion is as follows:" needs to be displayed in bold, and the "**" tags do not need to be rendered. However, during streaming output, the front-end might first receive "**Conclusion". At this point, the rendering engine sees an unclosed bold tag, which it might render as plain text "**Conclusion", or it might try to wait for it to close, but display an error. At this point, the user might see garbled text like "**Conclusion" or incorrectly styled text. This is a classic example of structural anomalies—the markup language structure is broken at a certain moment, making it impossible to parse correctly. A few milliseconds later, the remaining part, "as follows:**", is received. Only then can the rendering engine correctly parse the entire text "**Conclusion as follows:**" and display "Conclusion as follows:" in bold, potentially replacing the previously displayed "**Conclusion". Because this replacement involves a sudden change in the overall structure, the page will "flicker" or "jump". For example, the user might just see "**Conclusion" and suddenly it changes to the bolded "Conclusion as follows:", this dynamic structural adjustment affects visual stability.

[0005] The aforementioned issues can disrupt the user's reading experience. If users want to perform actions such as selection, copying, or clicking during content generation, the abrupt layout will make these actions virtually impossible. Furthermore, frequent flickering and rendering errors make the product appear rough and unstable, damaging user trust. Summary of the Invention

[0006] This application provides a method and electronic device for rendering and displaying model output data, which can avoid or reduce the occurrence of structural anomalies or structural mutations.

[0007] This application provides the following solution: A method for rendering and displaying model output data includes: The system receives and parses current data from a structured document streamed from an AI language model to predict the structure type corresponding to the target tags included in the current data; the structure type includes the structure type defined for the main content in the structured document. If the markup language corresponding to the predicted structure type consists of multiple tags existing in pairs or groups, and the target tag belongs to a part of a tag pair or tag group, then based on the other tags in the tag pair or tag group, temporary tags are added to the current data and provided to the rendering engine, so that the rendering engine can render the data in advance when it is aware of the complete tags corresponding to the structure type.

[0008] The process of supplementing the current data with temporary tags based on the tag pair or other tags in the tag group further includes: Write the target tags included in the current data to the tag state stack; After receiving new data from the AI ​​language model's streaming output, if the new data actually generates the tag pair or other tags in the tag group, then the target tag is removed from the tag state stack.

[0009] Before writing the target markers included in the current data to the marker state stack, the process also includes: Determine whether the target marker included in the current data already exists in the marker state stack. If not, determine that there is incomplete marker information in the current data, and trigger the steps of writing the target marker included in the current data to the marker state stack and completing the temporary marker.

[0010] The target marker includes a start marker in the marker pair, and the other part markers are the end markers in the marker pair; The step of adding temporary markers to the current data includes: A temporary end marker is added to the end of the current data so that the rendering engine can render the main content guided by the start marker in advance in the style expressed by the marker pair.

[0011] This also includes: After receiving new data from the streaming output of the AI ​​language model, if the end marker is not present in the new data, the new data is appended to the end of the output data historically generated by the AI ​​language model in the same session, and the temporary end marker is moved to the end of the new data before being provided to the rendering engine.

[0012] The structure type includes a table structure, the target marker includes a table header marker, and the other part markers include delimiter markers that appear in groups with the table header marker; The step of adding temporary markers to the current data includes: Add the delimiter marker to the current data so that the rendering engine can render the main content guided by the header marker into a table structure in advance.

[0013] A method for rendering and displaying model output data includes: The system receives and parses current data from a structured document streamed from an AI language model to predict the structure type corresponding to the target marker characters included in the current data; the structure type includes the structure type defined for the main content in the structured document. If the markup language corresponding to the predicted structure type consists of multiple consecutive markup characters, and the target markup character is a part of those characters, or there are other markup characters that have not yet been fully output, or there is no main content after the target markup character, then the target markup character is deleted from the current data and provided to the rendering engine so that the rendering engine can perform data rendering while delaying the perception of the target markup character.

[0014] This also includes: After receiving new data from the AI ​​language model's streaming output, if the new data has already completely output other marker characters, then the new data, without deleting any marker characters, is appended to the end of the original output data generated by the AI ​​language model in the same session without deleting the target marker characters, and provided to the rendering engine so that the rendering engine can perform data rendering while perceiving the multiple consecutive marker characters.

[0015] The process of deleting the target marker character from the current data further includes: Write the target marker character into the marker state stack; After receiving new data from the AI ​​language model's streaming output, if other marker characters have already been fully output in the new data, then the target marker character is removed from the marker state stack.

[0016] The structure type corresponding to the target marker character includes an unordered list.

[0017] A method for rendering and displaying model output data, the method being applied to a rendering engine, comprising: Receive model output data generated by the AI ​​language model, the model output data including the output data of the structured documents generated by the AI ​​language model in the same session, and the current data of the streaming output; If the data to be rendered is determined to include a code block structure based on the markers included in the historically generated data, and the current data includes some marker characters of the end marker in the marker group corresponding to the structure of the code block, then the some marker characters are deleted from the current data before rendering.

[0018] This also includes: After receiving new data from the streaming output of the AI ​​language model, if the end marker has been completely output, the complete end marker of the code block class is perceived based on the new data in the state without the deletion of marker-type characters, and the original output data generated by the AI ​​language model in the same session in the state without the deletion of target marker-type characters. Data rendering is then performed based on the complete end marker.

[0019] The process of deleting the partial marker characters from the current data further includes: writing the partial marker characters into the marker state stack; After receiving new data from the AI ​​language model's streaming output, if the end marker has been fully output, the target marker class character is removed from the marker state stack.

[0020] A computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the steps of any of the preceding methods.

[0021] An electronic device, comprising: One or more processors; and A memory associated with the one or more processors, the memory being used to store program instructions that, when read and executed by the one or more processors, perform the steps of any of the preceding methods.

[0022] A computer program product includes a computer program / computer executable instructions that, when executed by a processor in an electronic device, implement the steps of any of the preceding methods.

[0023] According to the specific embodiments provided in this application, the following technical effects are disclosed: In Embodiment 1 of this application, during the streaming output of the AI ​​language model, the current output data can be parsed to predict the structure type corresponding to the target markers included in the current data. If the marker language corresponding to the predicted structure type consists of multiple markers existing in pairs or groups, and the target marker in the current data belongs to a part of a marker pair or group, temporary markers can be added to the current data based on the other markers in the marker pair or group before being provided to the rendering engine. This allows the rendering engine to render the data with prior awareness of the complete markers corresponding to the structure type. In this way, because temporary markers can be added to the current data, the rendering engine can perceive the complete markers corresponding to the structure type in advance. Therefore, the current data can be directly rendered according to the corresponding structure type. Even when the marker information in the data currently output by the AI ​​language model is incomplete, the correct structure can still be rendered, avoiding or reducing structural anomalies or structural mutations.

[0024] Of course, any product implementing this application does not necessarily need to achieve all of the advantages described above at the same time. Attached Figure Description

[0025] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0026] Figure 1 This is a schematic diagram of the system architecture provided in the embodiments of this application; Figure 2 This is a flowchart of the first method provided in the embodiments of this application; Figure 3 This is a schematic diagram of the rendering result provided in an embodiment of this application; Figure 4 This is a flowchart of the second method provided in the embodiments of this application; Figure 5 This is a flowchart of the third method provided in the embodiments of this application; Figure 6 This is a schematic diagram of the electronic device provided in the embodiments of this application. Detailed Implementation

[0027] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.

[0028] In this application embodiment, a corresponding solution is provided to avoid or reduce "flickering" or "jumping" caused by structural anomalies or abrupt changes in the rendering results during the streaming output of data from an AI language model. In this solution, such as... Figure 1 As shown, a preprocessing module can be provided on the client side. This module receives the streaming output data from the AI ​​language model, preprocesses the received streaming output data, and then inputs it into the rendering engine for rendering. Specifically, after receiving the current data from the AI ​​language model's streaming output, it can parse it to predict the structure type corresponding to the target tags included in the current data. Based on the predicted structure type, it determines whether the target tags included in the current data are incomplete. If so, preprocessing can be performed on the current data. Specific preprocessing could include supplementing temporary tags in the current data (for cases where pairs or groups are needed for a more complete structure expression), or temporarily deleting tags from the current data (for cases where only the tag itself is output in the current data, and the content following the tag has not yet been generated, or where the specific tag needs to be composed of multiple consecutive characters, but the current data only outputs the first half, etc.), before inputting it into the rendering engine. In this way, for the former, the rendering engine can perceive the complete structure expressed by the tag pair or tag group in advance, so that it can directly render the current data according to the complete structure and avoid structural changes when the actual end tag or other tags are received later; or, for the latter, the rendering engine can render the data in a state of delayed perception of the tags in the current data, so as to avoid the impact of such incomplete tags or tag characters on the rendering structure.

[0029] In addition to the preprocessing module performing the aforementioned preprocessing on the current streaming output data, in some cases, further processing can be performed within the rendering engine to avoid rendering structure anomalies or sudden changes. This will be discussed in detail later.

[0030] It's important to note that since the AI ​​language model outputs data in a streaming manner, the specific tagging information may need to go through multiple data outputs to go from incomplete to complete. Therefore, to avoid errors, in the actual implementation, if temporary tag completion or temporary deletion is performed based on the target tag included in the current data, the target tag can be written to the tag state stack to indicate that the target tag is in an incomplete state and the preprocessing module is performing preprocessing operations on it. Subsequently, after the AI ​​language model outputs new data and the target tag becomes complete, the target tag can be removed from the tag state stack. The tag state stack can be memory space allocated to store target tags.

[0031] The specific implementation schemes provided in the embodiments of this application will be described in detail below.

[0032] Example 1 First, this first embodiment addresses the case where marker completion is performed by a preprocessing module outside the rendering engine, providing a method for rendering and displaying model output data. See [link to previous document]. Figure 2 The method may specifically include: S201: Receive and parse the current data in the structured document streamed by the AI ​​language model to predict the structure type corresponding to the target tags included in the current data. The structure type includes the structure type defined for the main content in the structured document.

[0033] Specifically, AI language models can output data in various scenarios, such as generating and outputting content based on user queries. The "current data" in the structured document streamed by the AI ​​language model refers to the incremental data being output during the streaming process.

[0034] Once the AI ​​language model begins streaming output, the client can start rendering. In this embodiment, preprocessing can be performed before rendering. Specifically, during preprocessing, the current data can first be parsed to predict the structure type corresponding to the target tags included in the current data, in order to further determine whether there is any structured content in an incomplete state.

[0035] The so-called structure type refers to the structure type defined for the main content of a structured document output by an AI language model. The main content is the actual text that needs to be rendered and displayed. During rendering, the main content can be rendered in the corresponding style according to its structure type. Typically, a structured document in one format defines multiple different structure types and uses different tags to express these different structure types. Therefore, if a certain part of the main content needs to be rendered in the style corresponding to a certain structure type, the tags corresponding to that structure type can be used to wrap that part of the main content; that is, the corresponding tags are added to that part of the main content. For example, a Markdown-formatted structured document will include at least the following structure types: headings, paragraphs (separated by blank lines), unordered lists, ordered lists, task lists, quotation blocks, code, tables, links, etc. Headings are usually marked with "#", where "#" represents a first-level heading, "##" represents a second-level heading, "###" represents a third-level heading, and so on. Unordered lists can be marked in the following ways: Project 1 Project 2 Sub-items (indented by 2 or 4 spaces) If you need to render a main body of content as a level 1 heading, you need to add a "#" marker in the structured document, for example: "#This is a dialogue content". When rendering, you can use the "#" marker to render "This is a dialogue content" as a level 1 heading, and the font and size can conform to the definition of a level 1 heading, etc.

[0036] Since different structure types are represented by different tags, the structure type can be predicted by information such as the tags present in the current data. For example, if the current data includes markup-related content such as "**", and tags such as "**" are often used as the starting tags for structures such as "bold display", then the corresponding structure type can be predicted to be "bold display".

[0037] In addition to predicting specific structure types based on target markers included in the current data, predictions can also be made by combining context. For example, predictions can be made based on keywords contained in the content already output by the AI ​​language model, and so on.

[0038] It should be noted that, in this embodiment, since subsequent steps require the completion or deletion of some markers, optionally, the processed markers can be recorded using a marker state stack. These markers can then be deleted from the stack after the complete structure is output. Furthermore, recording the processed markers using a marker state stack has the advantage that paired markers may have the same start and end markers. For example, the start and end markers for bold format might both be "**", etc. In such cases, relying solely on the "**" in the current data might not be sufficient to determine whether it is the start or end marker. Therefore, in specific implementation, after receiving the current data, if it is found that it includes a certain mark and belongs to a certain mark pair, it can be determined whether the mark already exists in the aforementioned mark state stack. If it exists, it proves that the mark in the currently received data may be an end mark. This end mark does not need to be written to the mark state stack, nor does it need to perform subsequent mark completion processing. Only when the mark in the current data does not exist in the mark state stack can it be proven that the target mark in the current data may be a start mark, and a corresponding end mark will be generated later. At this time, the current data belongs to the case of having incomplete mark information.

[0039] S202: If the markup language corresponding to the predicted structure type consists of multiple tags existing in pairs or groups, and the target tag belongs to a part of a tag pair or tag group, then according to the other tags in the tag pair or tag group, the current data is supplemented with temporary tags and provided to the rendering engine, so that the rendering engine can perform data rendering when it is aware of the complete tags corresponding to the structure type in advance.

[0040] After predicting the specific structure type, it can be determined whether the markup language corresponding to that structure type consists of pairs or groups of tags. For example, if the target tag's structure type is determined to be bold, since the markup language for this structure type consists of a start tag "**" and an end tag "**", it can be determined that the markup language for this structure type consists of tag pairs. Or, if the target tag's structure type is determined to be table, since the markup language for table structure type includes header tags, followed by delimiter tags, these header tags and delimiter tags usually appear in groups; that is, if there is a header tag, there will definitely be a delimiter tag. Therefore, if the structure type is determined to be table, it can also be determined that the markup language for this structure type consists of groups of tags, and so on. Then, it can be further determined whether the target tag contained in the current data belongs to a part of the aforementioned tag pairs or tag groups. If so, temporary tags can be added to the current data based on the other tags in the aforementioned tag pairs or tag groups before being provided to the rendering engine.

[0041] In a preferred embodiment, the target marker included in the current data can also be written to the marker state stack. Subsequently, after receiving new data from the AI ​​language model's streaming output, if the new data actually generates the marker pair or other markers in the marker group, the target marker is deleted from the marker state stack.

[0042] In this context, if the target marker is the start marker in a marker pair, then the other markers are the end markers in the same pair. Specifically, when supplementing the current data with temporary markers, a temporary end marker can be added to the end of the current data. This allows the rendering engine to render the main content guided by the start marker in advance according to the style expressed by the marker pair. For example, assuming the target marker in the current data is "**", and the predicted structure type is bold, and the markup language corresponding to bold is composed of the start marker "**" and the end marker "**", it can be determined that the target marker in the current data is likely the start marker for bold. This structure type also includes an end marker. Therefore, a temporary end marker "**" can be added to the current data before it is input into the rendering engine, allowing the rendering engine to render the data with prior awareness of the complete markers corresponding to the specific structure type. Specifically, assuming the current output data is "**Conclusion", the preprocessing module can add "**" to the end of the output data to form "**Conclusion**", and then input it into the rendering engine. In this way, the rendering engine receives the complete marker for "bold display," and therefore can directly bold the word "Conclusion" in the rendering result. Otherwise, without the above processing, the rendered result might be "**Conclusion," meaning the specific marker characters are also displayed, and the word "Conclusion" is not bolded. Only after the AI ​​language model officially outputs the end marker will the previously displayed "**" be deleted, and the text such as "Conclusion" be bolded.

[0043] When adding target markers to the marker state stack for recording, after receiving new data from the AI ​​language model's streaming output, the marker state stack can be checked first. If it includes a start marker, but the new data still lacks an end marker, the new data can be appended to the end of the AI ​​language model's historical output data in the same session, and a temporary end marker can be moved to the end of the new data before being provided to the rendering engine. For example, in the aforementioned example, assuming the new data from the AI ​​language model's streaming output is "as follows," the actual data input to the rendering engine could be "**The conclusion is as follows**" (of course, this may include other historical output data), so that the rendering engine can directly render "as follows" in bold.

[0044] Alternatively, in another scenario, if the predicted structure type is a table structure, and the target marker included in the current data is a table header marker, then the other markers determined in this case can be delimiter markers that appear in groups with the table header markers. Therefore, when supplementing the current data with temporary markers, delimiter markers can be added to the current data so that the rendering engine can render the main content guided by the table header markers as a table structure in advance.

[0045] For example, table headers are usually represented by "|", and the text between two "|"s typically corresponds to the content of the same cell. Separators are expressed by "|------|-------|", etc., and are located on the next line after the table header structure. For example, as... Figure 3 As shown in (A), data segment 31 shows the table header marker and its guided content, and data segment 32 shows the separator. When the AI ​​language model outputs this type of table content, if only the table header-related content is output and the separator is not yet output, the rendering engine cannot directly render the content guided by the table header marker into a table structure, but can only output it as ordinary text. However, in this embodiment, if the AI ​​language model currently outputs content related to the table header marker, it can automatically complete the separator marker in the current data. That is, assuming the AI ​​language model currently outputs content such as... Figure 3 (A) The content shown at data segment 31 can be automatically appended to the next line of data segment 32 by the preprocessing module, and then input into the rendering engine. This allows the rendering engine to obtain complete tags regarding the table structure, enabling it to directly render the content at data segment 31 as a table structure. For example, the rendering result could be as follows: Figure 3 As shown in (B). When the AI ​​language model continues to output new data, if a complete delimiter has already been officially output, the temporary delimiter can be replaced with the actual delimiter. If the header of the next row is output, the delimiter for that row can also be completed. During this process, the rendering engine can gradually draw the complete table. From the beginning, the user sees content displayed in a table format, initially only one or two cells in a row, gradually increasing the number of cells, rows, and columns, thus avoiding a sudden shift from plain text to a table structure.

[0046] In summary, in Embodiment 1 of this application, during the streaming output of the AI ​​language model, the current output data can be parsed to predict the structure type corresponding to the target markers included in the current data. If the marker language corresponding to the predicted structure type consists of multiple markers existing in pairs or groups, and the target marker in the current data belongs to a part of a marker pair or group, temporary markers can be added to the current data based on the other markers in the marker pair or group before being provided to the rendering engine. This allows the rendering engine to render the data in advance by sensing the complete markers corresponding to the structure type. In this way, because temporary markers can be added to the current data, the rendering engine can sense the complete markers corresponding to the structure type in advance. Therefore, the current data can be directly rendered according to the corresponding structure type. Even when the marker information in the data currently output by the AI ​​language model is incomplete, the correct structure can still be rendered, avoiding or reducing structural anomalies or structural mutations.

[0047] Example 2 In the aforementioned Example 1, the focus was primarily on tag pairs or tag groups, where temporary tag completion could be performed in advance. However, in practical applications, another situation exists where the tag language for some structural types consists of multiple consecutive tag characters. For example, the tag language for unordered lists might consist of "-" and "space". That is, to display an unordered list, it needs to be expressed as "- (space) unordered list content". However, if the AI ​​language model's current output data ends with "-" or "- (space)" without any subsequent text content, direct rendering by the rendering engine may result in structural anomalies or abrupt changes. For example, data before "-" might suddenly appear larger in font size. Alternatively, some structural types might have tag languages ​​composed of a single tag character. However, if the model's current output data lacks main content after that tag character, direct rendering may also result in structural anomalies or abrupt changes. Therefore, to address this situation, the preprocessing module in this embodiment can temporarily delete such marker characters from the current data before inputting them into the rendering engine for rendering, thus delaying the rendering engine's perception of this structure. Subsequently, after obtaining complete markers and including text content in the new data output by the AI ​​language model, the complete marker characters and the subsequent main content are then normally input into the rendering engine, allowing the rendering engine to render according to the corresponding structure.

[0048] To address the above situation, Embodiment 2 of this application provides a method for rendering and displaying model output data, see [link to embodiment]. Figure 4 The method may specifically include: S401: Receive and parse the current data in the structured document streamed by the AI ​​language model to predict the structure type corresponding to the target tag characters included in the current data; the structure type includes: the structure type defined for the main content in the structured document; S402: If the markup language corresponding to the predicted structure type consists of multiple consecutive markup characters, the target markup character is a part of them, there are other markup characters that have not been completely output, or there is no main content after the target markup character, then the target markup character is deleted from the current data and provided to the rendering engine so that the rendering engine can perform data rendering in a state of delayed perception of the target markup character.

[0049] Upon receiving new data streamed from the AI ​​language model, if other marker characters have already been fully output in the new data, the new data, without any marker character deletion, can be appended to the end of the original output data generated by the AI ​​language model in the same session and provided to the rendering engine. This allows the rendering engine to render the data while aware of the target marker character. In other words, if other marker characters have already been fully output in the new data, it can be processed in the conventional way, without triggering the preprocessing procedure described in this embodiment. The so-called original output data refers to the output data generated by the AI ​​language model during streaming data output in the same session, without the aforementioned target marker character deletion. In other words, although the target marker characters were deleted before being input into the rendering engine in step S402, if the AI ​​language model generates new data and other marker characters have been completely output in the new data, firstly, the marker characters will not be deleted again for this new data. Furthermore, the previously generated original output data will also be appended to the end of the previously generated original output data in the same session without the aforementioned deletion of the target marker characters, and then input into the rendering engine. This allows the rendering engine to fully perceive the multiple consecutive marker characters and render the corresponding main content according to the structural type corresponding to these multiple consecutive marker characters.

[0050] For example, suppose the current data received in step S401 is "See the following content-". At this point, the marker character "-" is incomplete. If directly input to the rendering engine, the rendering engine will cause the font of "See the following content" to be enlarged due to the presence of "-", which is a structural error. Therefore, in this embodiment, the "-" can be deleted first, and then the current data can be appended to the end of the historical output data generated in the same session before being provided to the rendering engine. In this case, the rendering engine is unaware of the presence of "-", and therefore the rendering process will not be affected by it; it can simply render based on the other received data.

[0051] Subsequently, assuming the AI ​​language model's next incremental output already contains complete output of other marker characters—for example, the new incremental data might be "(space) list content"—the "(space)" in the new incremental data (representing the "space" character) can form a complete marker string with the "-" in the previously received data. Therefore, the "(space)" in the new incremental data will not be deleted, and the new incremental data will be appended to the end of the original output data generated in the same session. For example, if the previous original output data was "See the following content-", then the actual data input into the rendering engine will be "...See the following content-(space) list content". At this point, the rendering engine will recognize the complete marker string and can render the subsequent "list content" and so on according to the structure type corresponding to this complete marker string.

[0052] In addition, when deleting the target marker character from the current data, the target marker character can also be written to the marker state stack. Subsequently, after receiving new data from the AI ​​language model's streaming output, if other marker characters have been completely output in the new data, the target marker character can be deleted from the marker state stack.

[0053] In the above embodiment two, for cases where the markup language corresponding to a structure type consists of multiple consecutive markup characters, if the target markup character in the current data is only a part of that character set, and there are other markup characters that have not yet been completely output, or if there is no main content following the target markup character, then this target markup character can be temporarily deleted before rendering and displaying. This method can avoid or reduce the occurrence of structural anomalies or abrupt changes caused by incomplete markup.

[0054] Example 3 In the cases described in Embodiments 1 and 2 above, the preprocessing module outside the rendering engine performs temporary markup completion or markup deletion, etc., before inputting the data into the rendering engine for rendering. In specific applications, there are also code block structures. The markup language corresponding to this structure has a start mark and an end mark, located before the beginning and after the end of the code block, respectively. However, unlike structures like bold text, for this type of code block structure, the rendering engine only needs the start mark to correctly render the code block structure, without relying on the end mark. Therefore, in this case, the preprocessing module does not need to pre-complete the end mark. However, a potential problem remains: the end mark of a code block structure is usually composed of multiple consecutive characters, such as three consecutive ".", i.e., "...". In this case, if the current data streamed by the AI ​​module only contains one or two ".", meaning the end mark is incomplete, direct rendering might directly render the ".". In this situation, the rendering engine can temporarily remove the incompletely output end marker from the current data before rendering. Then, the marker can be removed from the marker state stack after all end markers have been fully output.

[0055] Specifically, this third embodiment provides a method for rendering and displaying model output data, see [link to documentation]. Figure 5 The method is applied to a rendering engine and includes: S501: Receive model output data generated by the AI ​​language model, wherein the model output data includes output data from structured documents historically generated by the AI ​​language model in the same session, and current data from streaming output; S502: If the data to be rendered is determined to include a code block class structure based on the markers included in the historically generated data, and the current data includes some marker class characters of the end marker in the marker group corresponding to the structure of the code block class, then the some marker class characters are deleted from the current data before rendering.

[0056] In this embodiment, after receiving new data from the AI ​​language model's streaming output, if the end marker has been fully output, the deletion of marker characters is no longer required. The rendering engine can then render the data based on the original output data from the structured document generated in the same session and the new data in the state where marker characters have not been deleted. This allows the rendering engine to render data while being aware of the structure of the code block class. In other words, if other marker characters have been fully output in the new data, it can be processed in the usual way, without triggering the marker deletion process described in this application. The so-called original output data, as mentioned above, refers to the output data generated by the AI ​​language model during streaming data output in the same session, in the state where the aforementioned target marker characters have not been deleted. For example, suppose the last output data was "(code content) / / ..". Since the end marker of a code block is usually "…", but the above output data only includes two ".", the ".." can be deleted first before rendering to avoid rendering ".." as part of the main text. Subsequently, if the next output data is "." (other content), since the "." at the beginning of the new data and the ".." at the end of the previous output data form a complete code block end marker string, the "." in the new data is not deleted. This new data is appended to the end of the original output data from the previous output before the removal of the target marker character, ensuring that the rendering engine's input data contains the complete code block end marker string. Therefore, the rendering engine can render based on this code block end marker string. At this point, the rendering engine will correctly recognize "..." as a code block end marker string and will not render "..." as ordinary text content.

[0057] Additionally, when deleting certain marker characters from the current data, these marker characters can be written to the marker state stack. Subsequently, after receiving new data streamed from the AI ​​language model, if the end marker has been completely output, the target marker character can be deleted from the marker state stack.

[0058] By temporarily deleting some marker characters within the rendering engine through this third embodiment, abnormalities or mutations in the code block structure can be avoided during the rendering process.

[0059] For the parts of Embodiments 2 and 3 that are not described in detail, please refer to Embodiment 1 and other parts of this specification. They will not be repeated here.

[0060] It should be noted that the embodiments of this application may involve the use of user data. In practical applications, user-specific personal data may be used in the scheme described herein within the scope permitted by applicable laws and regulations, provided that it complies with the applicable laws and regulations of the country (e.g., with the user's explicit consent, with the user being properly notified, etc.).

[0061] Corresponding to Embodiment 1 of this application, this application also provides an apparatus for rendering and displaying model output data, which may include: The structure type prediction unit is used to receive and parse the current data in the structured document streamed by the artificial intelligence (AI) language model, so as to predict the structure type corresponding to the target tags included in the current data; the structure type includes: the structure type defined for the main content in the structured document; The tag completion unit is used to complete temporary tags for the current data based on the other tags in the tag pair or tag group if the tag language corresponding to the predicted structure type consists of multiple tags existing in pairs or groups, and the target tag belongs to a part of the tag pair or tag group. The temporary tags are then provided to the rendering engine so that the rendering engine can render the data in advance when it is aware of the complete tags corresponding to the structure type.

[0062] The device may further include: The state stack writing unit is used to write the target tag included in the current data to the tag state stack when supplementing the temporary tag for the current data according to the tag pair or other tags in the tag group; The state stack deletion unit is used to delete the target tag from the tag state stack after receiving new data from the streaming output of the AI ​​language model, if the new data actually generates the tag pair or other tags in the tag group.

[0063] Additionally, the device may also include: The judgment unit is used to determine whether the target tag included in the current data already exists in the tag state stack before writing the target tag included in the current data to the tag state stack. If not, it determines that there is incomplete tag information in the current data and triggers the execution of the steps of writing the target tag included in the current data to the tag state stack and completing the temporary tag.

[0064] Wherein, the target marker includes the start marker of the marker pair, and the other part markers are the end markers of the marker pair; at this time, the specific marker completion unit can be used for: A temporary end marker is added to the end of the current data so that the rendering engine can render the main content guided by the start marker in advance in the style expressed by the marker pair.

[0065] Additionally, the device may also include: The marker-moving unit is configured to, upon receiving new data from the streaming output of the AI ​​language model, append the new data to the end of the historical output data generated by the AI ​​language model in the same session if the end marker is not present in the new data, and then move the temporary end marker to the end of the new data before providing it to the rendering engine.

[0066] Additionally, the structure type includes a table structure, the target marker includes a table header marker, and the other part markers include delimiter markers that appear in groups with the table header marker; The marker completion unit can specifically be used for: Add the delimiter marker to the current data so that the rendering engine can render the main content guided by the header marker into a table structure in advance.

[0067] Corresponding to Embodiment 2, this application also provides an apparatus for rendering and displaying model output data, which may include: The structure type prediction unit is used to receive and parse the current data in the structured document streamed by the artificial intelligence (AI) language model, so as to predict the structure type corresponding to the target tag class characters included in the current data; the structure type includes: the structure type defined for the main content in the structured document; The marker deletion unit is used to delete the target marker character from the current data and provide it to the rendering engine if the marker language corresponding to the predicted structure type consists of multiple consecutive marker characters, the target marker character is a part of the characters, there are other marker characters that have not been completely output, or there is no main content after the target marker character, so that the rendering engine can perform data rendering in a state of delayed perception of the target marker character.

[0068] Additionally, the device may also include: The data appending unit is used to append, without deleting any target character, the new data after receiving new data from the streaming output of the AI ​​language model. If other target character characters have already been completely output in the new data, the new data is appended to the end of the original output data generated by the AI ​​language model in the same session without deleting the target target character. The appended data is then provided to the rendering engine so that the rendering engine can perform data rendering while perceiving the multiple consecutive target characters.

[0069] Furthermore, the device may also include: The state stack writing unit is used to write the target tag character to the tag state stack when the target tag character is deleted from the current data; The state stack deletion unit is used to delete the target tag character from the tag state stack if other tag characters have been completely output in the new data after receiving new data from the streaming output of the AI ​​language model.

[0070] The structure type corresponding to the target marker character includes an unordered list.

[0071] Corresponding to Embodiment 3, this application also provides an apparatus for rendering and displaying model output data, wherein the method is applied to a rendering engine and includes: The data receiving unit is used to receive model output data generated by the AI ​​language model. The model output data includes output data from structured documents generated by the AI ​​language model in the same session, as well as the current data of the streaming output. The marker deletion unit is configured to delete the marker characters from the current data before rendering if the current data is determined to be a code block structure based on the markers included in the historically generated data, and the current data includes a portion of the marker characters from the marker group corresponding to the code block structure, before rendering.

[0072] Specifically, after receiving new data from the streaming output of the AI ​​language model, if the end marker has been completely output, the complete end marker of the code block class is perceived based on the new data in the state without the deletion of marker-type characters, and the original output data generated by the AI ​​language model in the same session in the state without the deletion of target marker-type characters. Data rendering is then performed based on the complete end marker.

[0073] Additionally, the device may also include: The state stack writing unit is used to write the partial marker characters into the marker state stack when the partial marker characters are deleted from the current data; The state stack deletion unit is used to delete the target tag class character from the tag state stack after receiving new data from the streaming output of the AI ​​language model, if the end tag has been completely output.

[0074] In addition, embodiments of this application also provide a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the method described in any of the foregoing method embodiments.

[0075] And an electronic device, comprising: One or more processors; and A memory associated with the one or more processors, the memory being used to store program instructions that, when read and executed by the one or more processors, perform the steps of the method described in any of the foregoing method embodiments.

[0076] A computer program product includes a computer program / computer executable instructions that, when executed by a processor in an electronic device, implement the steps of the method described in the foregoing method embodiments.

[0077] in, Figure 6 An exemplary architecture of an electronic device is shown, which may include a processor 610, a video display adapter 611, a disk drive 612, an input / output interface 613, a network interface 614, and a memory 620. The processor 610, video display adapter 611, disk drive 612, input / output interface 613, network interface 614, and memory 620 can communicate with each other via a communication bus 630.

[0078] The processor 610 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to achieve the technical solution provided in this application.

[0079] The memory 620 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 620 can store the operating system 621 for controlling the operation of the electronic device 600, and the basic input / output system (BIOS) for controlling the low-level operations of the electronic device 600. Additionally, it can store a web browser 623, a data storage management system 624, and a rendering and display processing system 625, etc. The aforementioned rendering and display processing system 625 can be the application program that specifically implements the aforementioned steps in this embodiment. In summary, when implementing the technical solution provided in this application through software or firmware, the relevant program code is stored in the memory 620 and is called and executed by the processor 610.

[0080] Input / output interface 613 is used to connect input / output modules to realize information input and output. Input / output modules can be configured as components in the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Input devices may include keyboards, mice, touch screens, microphones, various sensors, etc., and output devices may include displays, speakers, vibrators, indicator lights, etc.

[0081] Network interface 614 is used to connect a communication module (not shown in the figure) to enable communication between this device and other devices. The communication module can communicate via wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0082] Bus 630 includes a pathway for transmitting information between various components of the device, such as processor 610, video display adapter 611, disk drive 612, input / output interface 613, network interface 614, and memory 620.

[0083] It should be noted that although the above-described device only shows the processor 610, video display adapter 611, disk drive 612, input / output interface 613, network interface 614, memory 620, bus 630, etc., in specific implementations, the device may also include other components necessary for normal operation. Furthermore, those skilled in the art will understand that the above-described device may only include the components necessary for implementing the solution of this application, and does not necessarily include all the components shown in the figures.

[0084] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of this application.

[0085] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for system or system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and relevant parts can be referred to the descriptions in the method embodiments. The systems and system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0086] The method and electronic device for rendering and displaying model output data provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and its core ideas. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for rendering and displaying model output data, characterized in that, include: The system receives and parses the current data in a structured document from the streaming output of an artificial intelligence (AI) language model in order to predict the structure type corresponding to the target tags included in the current data. The structure type includes: the structure type defined for the main content in the structured document; If the markup language corresponding to the predicted structure type consists of multiple tags existing in pairs or groups, and the target tag belongs to a part of a tag pair or tag group, then based on the other tags in the tag pair or tag group, temporary tags are added to the current data and provided to the rendering engine, so that the rendering engine can render the data in advance when it is aware of the complete tags corresponding to the structure type.

2. The method according to claim 1, characterized in that, When supplementing the current data with temporary tags based on the tag pair or other tags in the tag group, the method further includes: Write the target tags included in the current data to the tag state stack; After receiving new data from the AI ​​language model's streaming output, if the new data actually generates the tag pair or other tags in the tag group, then the target tag is removed from the tag state stack.

3. The method according to claim 2, characterized in that, Before writing the target markers included in the current data to the marker state stack, the process also includes: Determine whether the target marker included in the current data already exists in the marker state stack. If not, determine that there is incomplete marker information in the current data, and trigger the steps of writing the target marker included in the current data to the marker state stack and completing the temporary marker.

4. The method according to claim 1, characterized in that, The target marker includes a start marker in the marker pair, and the other part markers are the end markers in the marker pair; The step of adding temporary markers to the current data includes: A temporary end marker is added to the end of the current data so that the rendering engine can render the main content guided by the start marker in advance in the style expressed by the marker pair.

5. The method according to claim 4, characterized in that, Also includes: After receiving new data from the streaming output of the AI ​​language model, if the end marker is not present in the new data, the new data is appended to the end of the output data historically generated by the AI ​​language model in the same session, and the temporary end marker is moved to the end of the new data before being provided to the rendering engine.

6. The method according to claim 1, characterized in that, The structure type includes a table structure, the target marker includes a table header marker, and the other part markers include delimiter markers that appear in groups with the table header marker; The step of adding temporary markers to the current data includes: Add the delimiter marker to the current data so that the rendering engine can render the main content guided by the header marker into a table structure in advance.

7. A method for rendering and displaying model output data, characterized in that, include: The system receives and parses the current data in a structured document from the streaming output of an artificial intelligence (AI) language model in order to predict the structure type corresponding to the target marker characters included in the current data. The structure type includes: the structure type defined for the main content in the structured document; If the markup language corresponding to the predicted structure type consists of multiple consecutive markup characters, and the target markup character is a part of those characters, or there are other markup characters that have not yet been fully output, or there is no main content after the target markup character, then the target markup character is deleted from the current data and provided to the rendering engine so that the rendering engine can perform data rendering while delaying the perception of the target markup character.

8. The method according to claim 7, characterized in that, Also includes: After receiving new data from the AI ​​language model's streaming output, if the new data has already completely output other marker characters, then the new data, without deleting any marker characters, is appended to the end of the original output data generated by the AI ​​language model in the same session without deleting the target marker characters, and provided to the rendering engine so that the rendering engine can perform data rendering while perceiving the multiple consecutive marker characters.

9. The method according to claim 7, characterized in that, When deleting the target marker character from the current data, the method further includes: Write the target marker character into the marker state stack; After receiving new data from the AI ​​language model's streaming output, if other marker characters have already been fully output in the new data, then the target marker character is removed from the marker state stack.

10. The method according to claim 7, characterized in that, The structure type corresponding to the target marker class character includes an unordered list.

11. A method for rendering and displaying model output data, characterized in that, The method is applied to a rendering engine and includes: Receive model output data generated by the AI ​​language model, the model output data including the output data of the structured documents generated by the AI ​​language model in the same session, and the current data of the streaming output; If the data to be rendered is determined to include a code block structure based on the markers included in the historically generated data, and the current data includes some marker characters of the end marker in the marker group corresponding to the structure of the code block, then the some marker characters are deleted from the current data before rendering.

12. The method according to claim 11, characterized in that, Also includes: After receiving new data from the streaming output of the AI ​​language model, if the end marker has been completely output, the complete end marker of the code block class is perceived based on the new data in the state without the deletion of marker-type characters, and the original output data generated by the AI ​​language model in the same session in the state without the deletion of target marker-type characters. Data rendering is then performed based on the complete end marker.

13. The method according to claim 11, characterized in that, When deleting the portion of the marker characters from the current data, the method further includes: writing the portion of the marker characters into the marker state stack; After receiving new data from the AI ​​language model's streaming output, if the end marker has been fully output, the target marker class character is removed from the marker state stack.

14. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program performs the steps of the method described in any one of claims 1 to 13.

15. An electronic device, characterized in that, include: One or more processors; as well as A memory associated with the one or more processors, the memory being used to store program instructions that, when read and executed by the one or more processors, perform the steps of the method according to any one of claims 1 to 13.

16. A computer program product comprising a computer program / computer-executable instructions, characterized in that, When the computer program / computer-executable instructions are executed by a processor in an electronic device, they implement the steps of the method according to any one of claims 1 to 13.