Display method, device and storage medium of text to be displayed

By obtaining the global offset and slicing result of the text to be displayed, the global character range and local offset of the slice are determined, which solves the problem that long text generated by LLM cannot be formatted and enables formatting adjustment during streaming display, thus improving the user interaction experience.

CN122369047APending Publication Date: 2026-07-10GREAT WALL MOTOR CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GREAT WALL MOTOR CO LTD
Filing Date
2026-04-01
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

In in-vehicle smart cockpits, long texts generated by LLM cannot be formatted during display, making it impossible to locate the text to be adjusted in each slice, resulting in only the text content being displayed without formatting adjustments.

Method used

By obtaining the global offset and slicing results of the text to be displayed, the global character range of each slice is determined, and the target slice including the characters to be adjusted and its local offset are determined based on the comparison results. When displaying in streaming mode, the format of the characters to be adjusted in the target slice is adjusted.

Benefits of technology

This technology enables long texts output by large language models to be displayed correctly in specific text formats, thus improving the user interaction experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122369047A_ABST
    Figure CN122369047A_ABST
Patent Text Reader

Abstract

This application relates to a method, apparatus, and storage medium for displaying text to be displayed. The method includes: upon acquiring the text to be displayed, acquiring the global offset of the target text within the text to be displayed that requires formatting adjustment; determining the global character range of each slice in the slicing results of the text to be displayed; determining, based on the comparison result between the global character range and the global offset, a target slice containing the character to be adjusted, and determining the local offset of the character to be adjusted within its respective target slice; and during the streaming display of the target slice of the text to be displayed, adjusting the format of the character to be adjusted corresponding to the local offset within the target slice before displaying it. This application solves the technical problem that formatted text cannot be displayed when displaying long text output by LLM.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of large language models, and more particularly to a method, apparatus, and storage medium for displaying text to be displayed. Background Technology

[0002] With the widespread application of Large Language Model (LLM) technology in in-vehicle smart cockpits, the real-time interactive experience between users and Artificial Intelligence (AI) is becoming increasingly important. In in-vehicle scenarios, the text content generated by LLM often needs to be pushed to the client in real time for rendering and display in a streaming manner. However, due to the limitations of network transmission protocols on the size of single packet data (usually a few KB to tens of KB), when LLM generates long text, the text must be sliced ​​(fragmented) and sent packet by packet.

[0003] For longer text generated by LLM, if there is text to be formatted, it is impossible to locate the text to be formatted in each slice after the slice is sent. As a result, when the long text output by LLM is displayed on the front end, only the text content can be displayed, without the formatting adjustment. Summary of the Invention

[0004] This application provides a method, apparatus, and storage medium for displaying text to solve the technical problem that long text output by LLM cannot be displayed with adjusted formatting.

[0005] Firstly, this application provides a method for displaying text to be displayed, comprising: upon obtaining the text to be displayed, obtaining the global offset of the target text in the text to be displayed that needs to be formatted; determining the global character range of each slice in the slicing result based on the slicing result of the text to be displayed; determining the target slice containing the character to be formatted from the slicing result based on the comparison result of the global character range and the global offset, and determining the local offset of the character to be formatted in the target slice; and displaying the target slice of the text to be displayed in a streaming manner after formatting the character to be formatted corresponding to the local offset in the target slice.

[0006] Secondly, this application provides a display device for text to be displayed, comprising: an acquisition module, configured to acquire, upon acquiring the text to be displayed, a global offset of a target text whose format needs to be adjusted; a first determination module, configured to determine, based on the slicing results of the text to be displayed, the global character range of each slice in the slicing results; a second determination module, configured to, based on the comparison result between the global character range and the global offset, determine, from the slicing results, a target slice including the character to be adjusted, and determine the local offset of the character to be adjusted within the target slice; and a display module, configured to, during the process of displaying the target slice of the text to be displayed in a streaming manner, adjust the format of the character to be adjusted corresponding to the local offset in the target slice and then display it.

[0007] Thirdly, this application provides an electronic device, comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus, wherein the memory stores a computer program, and the processor is configured to implement the display method of the text to be displayed as described above when executing the computer program.

[0008] Fourthly, this application also provides a computer storage medium storing computer-executable instructions for executing the display method of the text to be displayed according to any one of the above claims of this application.

[0009] Compared with the prior art, the technical solution provided in this application has the following advantages: When the text to be displayed is obtained, this application obtains the global offset of the target text that needs to be formatted in the text to be displayed; determines the global character range of each slice in the slice result based on the slice result of the text to be displayed; determines the target slice containing the character to be formatted based on the comparison result of the global character range and the global offset, and determines the local offset of the character to be formatted in the target slice based on the slice result; during the process of the client displaying the target slice of the text to be displayed in a streaming manner, the character to be formatted in the target slice is rendered according to the local offset, so that the global offset of the target text that needs to be formatted in the text to be displayed output by the large language model can be mapped to each target slice result containing the character to be formatted, and the local offset is obtained. The character to be formatted is rendered according to the local offset, thus realizing the effect that the long text output by the large language model can display the format of a specific text normally when it is displayed. Attached Figure Description

[0010] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0011] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0012] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.

[0013] Figure 1 A flowchart illustrating a method for displaying text from a large language model, as provided in an embodiment of this application; Figure 2 An overall framework diagram provided for an embodiment of this application; Figure 3 An algorithm schematic diagram provided for an embodiment of this application; Figure 4 A core flowchart of an algorithm provided in an embodiment of this application; Figure 5a and Figure 5b A schematic diagram illustrating the calculation of local offsets between a target slice and a character to be adjusted, provided as an embodiment of this application; Figure 6a and Figure 6b This application provides an overall framework diagram of an application scenario. Figure 7 A schematic diagram of the structure of a display device for displaying text of a large language model, provided in an embodiment of this application; Figure 8 This is a schematic diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0014] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0015] The following disclosure provides numerous different embodiments or examples for implementing various structures of the invention. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of the invention. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.

[0016] To address the technical problem in existing technologies where long text output by an LLM cannot display its format, this application provides a method for displaying text from a large language model, which enables the long text output by the large language model to display the format of a specific text correctly.

[0017] Figure 1 This is a flowchart illustrating a method for displaying text in a large language model, as provided in an embodiment of this application. Figure 1 As shown, the methods for displaying the text to be displayed in the above large language model include: S102, when the text to be displayed is obtained, obtain the global offset of the target text whose format needs to be adjusted in the text to be displayed; S104, Based on the slicing results of the text to be displayed, determine the global character range of each slice in the slicing results; S106. Based on the comparison results of the global character range and the global offset, determine the target slice containing the character to be adjusted from the slice results, and determine the local offset of the character to be adjusted in the target slice. S108, during the process of displaying the target slice of the text to be displayed in a streaming manner, the characters to be adjusted in the target slice corresponding to the local offset are formatted and then displayed.

[0018] This application can be applied to scenarios involving the display of long text. Long text is typically text with a large volume of text. Due to the large volume of text, it is necessary to slice the text before displaying it. During the display of long text, this application can accurately determine whether each slice contains characters that need to be formatted, even after slicing the text to be displayed. Therefore, when displaying the slices, the characters to be formatted are formatted and then displayed.

[0019] Furthermore, the present application can be applied to scenarios where the text to be displayed of a large language model is formatted. For the text to be displayed generated by the large language model for the input text, the amount of text is large, and the global offset of the target text that needs to be formatted is included in the text to be displayed. For example, if the text to be displayed is "Hello, nice to meet you", the global offset can be [4, 6], indicating that the 4th to 6th characters are the target text to be formatted. If the global offset is [4, 6), it means that the 4th to 5th characters are the target text to be formatted. Corresponding to the text to be displayed, "nice" needs to be formatted.

[0020] The formatting adjustment in the present application can be at least one of adjusting color, text size, bold, italic, underline, special marking, etc. For example, coloring specific text to improve visibility and allow users to easily focus on key content.

[0021] The global offset can not only be used to mark the global character position, but in the present application, the global offset can also be used to mark which byte the target text that needs to be formatted is in the global sorting. In the present application, the number of bytes occupied by text and symbols is not the same. For example, in the present application, ASCII characters (English letters, numbers, basic symbols) occupy 1 byte, Chinese characters usually occupy 3 bytes, Emoji emoji occupy 4 bytes, and special symbols may occupy 2 bytes. Specifically, Chinese characters can also occupy 2 bytes, and the number of bytes occupied can be modified according to the actual situation, but when implementing the solution of the present application, the number of bytes occupied is fixed.

[0022] In the case where the global offset is used to mark bytes, for example, if the text to be displayed is "Hello, nice to meet you", the global offset can be [10, 16), indicating that the 10th to 15th bytes are the bytes that need to be formatted. Corresponding to the text to be displayed, "nice" needs to be formatted.

[0023] Since the above text to be displayed has a global offset, and the global offset is used to mark the target text that needs to be formatted in the text to be displayed, so if the text to be displayed is directly displayed, the format can be adjusted. However, in a streaming scenario, the text to be displayed is not output at once, but is output in a stream. Streaming output can significantly reduce the user's perceived latency and improve the interaction experience. Therefore, the text to be displayed will be sliced into multiple shards and transmitted in a sharded manner. When transmitting in shards, the original global offset cannot mark which characters in the sharded result need to be formatted. So, in the present application, after slicing the text to be displayed to obtain the sliced result, the global character range of each slice needs to be determined.

[0024] The global character range of each slice is its position within the text to be displayed. For example, if the text to be displayed is "Hello, nice to meet you", and the slices are "Hello", "Nice to meet you", and "Meet you", then following the principle that text occupies 3 bytes and symbols occupy 1 byte, the global byte range of each of the three slices is [0,7), [7,16) and [16,25), and the global character range is [0,3), [3,6) and [6,9).

[0025] After determining the global character range of each slice and obtaining the global offset of the target text, we can use both to determine whether each slice contains the character to be adjusted, and the local offset of the character to be adjusted in the target slice that contains the character to be adjusted.

[0026] Once the target slice containing the character to be adjusted is determined, and the local offset of the character to be adjusted is determined, the character to be adjusted in the target slice can be rendered according to the local offset (when the target slice is displayed).

[0027] This application achieves the effect of correctly adjusting the format of specific text within the target text that needs to be formatted when the text to be displayed is obtained; the global character range of each slice in the sliced ​​text is determined based on the sliced ​​text; the target slice containing the characters to be formatted is determined from the sliced ​​text based on the comparison between the global character range and the global offset, and the local offset of the characters to be formatted within the target slice is determined; during the streaming display of the target slices of the text to be displayed, the format of the characters to be formatted corresponding to the local offsets in the target slices is adjusted before display. This allows the global offset of the target text that needs to be formatted in the text to be displayed output by the large language model to be mapped to each target slice containing the characters to be formatted, obtaining the local offset, and rendering the characters to be formatted according to the local offset. This enables the long text output by the large language model to be displayed with the format of specific text that needs to be formatted correctly.

[0028] As an optional example, determining the target slice containing the characters to be adjusted from the slicing results based on the comparison results of the global character range and the global offset includes: comparing the global character range and the global offset of each slice; when the comparison results show that the two have an intersection, the corresponding slice is determined to be the target slice.

[0029] In this application, a solution is provided for determining a target slice including the character to be adjusted and the local offset of the character to be adjusted in the target slice by comparing the global character range and the global offset. In this solution, the core of comparing the global character range and the global offset lies in checking whether there is an intersection between the two. If there is an intersection between the two, the slice that intersects with the global offset is determined as the target slice.

[0030] To determine whether there is an intersection between two intervals, it is judged whether two intervals [a, b) and [c, d) satisfy a < d AND b > c. In this application, there can be multiple intervals for the global offset. When determining whether each slice is a target slice, the global character range of each slice needs to be compared with each global offset.

[0031] In this application, by comparing whether there is an intersection between each slice and each global offset, the target slice including the character to be adjusted can be determined from the slice results of the text to be displayed, and further the local offset of the character to be adjusted can be determined, thus achieving the effect of full-scale search for target slices without omission.

[0032] As an optional example, determining the local offset of the character to be adjusted in the target slice where it is located includes: determining the local offset through the following formula: u = [max(0, c - a), min(chunkLength, d - a)) (1) The global character range of the target slice is [a, b), the global offset is [c, d), u is the local offset of the character to be adjusted in the target slice, and chunkLength is the length of the global character range.

[0033] It should be noted that the global character range and the global offset here can be the order of characters. For example, "你好," has 3 characters in total, so the range is [0, 3), where the first character occupies the position of zero, the second character occupies the position of 1, and the third character occupies the position of 2. Therefore, the left side of the range [0, 3) is a closed interval and the right side is an open interval.

[0034] The above formula can determine the local offset of the character to be adjusted in the target slice. Since it has been determined that the target slice includes the character to be adjusted, and further only the local offset of the character to be adjusted in the target slice needs to be determined. And the global character range of the target slice itself identifies the global position of the target slice. Therefore, through the above formula, the local offset of the character to be adjusted located within the target slice in the global offset within the target slice can be calculated.

[0035] If there are multiple global offsets, a local offset is calculated for each global offset using Formula 1 above. If multiple local offsets can be calculated, it means that there are multiple discontinuous characters in the target slice that need to be formatted.

[0036] This application, through Formula 1 above, calculates the local offset of the character to be adjusted in each target slice containing the character to be adjusted, and binds the local offset to the target slice. Thus, as the target slice is transmitted and rendered, the format of the character to be adjusted can be adjusted according to the local offset, achieving the effect of accurately displaying the text format after slicing the text to be displayed.

[0037] As an optional example, before determining the global character range of each slice in the sliced ​​result based on the sliced ​​result of the text to be displayed, the above method further includes: obtaining the expected slice size of the text to be displayed; and performing a dynamic slicing action on the text to be displayed based on the expected slice size to obtain the sliced ​​result of the text to be displayed.

[0038] In this application, when slicing the text to be displayed, the desired slice size can be obtained. The purpose of the desired slice size is to constrain the size of the slice obtained from the text to be displayed. For example, the desired slice size may be 10 bytes or 128kb.

[0039] The desired slice size in this application can be adjusted based on network quality and the client's rendering capabilities. If the network quality is good and the client's rendering capabilities are strong, the desired slice size can be set larger; conversely, the desired slice size can be set smaller. Furthermore, the desired slice size can dynamically fluctuate based on network quality. By setting and dynamically adjusting the desired slice size, different LLM use cases can be adapted. For example, when using LLM in vehicles, it can be adapted to different displays and processors in different vehicle models.

[0040] In this application, after obtaining the expected slice size, a dynamic slicing action can be performed on the text to be displayed using the expected slice size to obtain the slicing result. The dynamic slicing action means that when performing the slicing action on the text to be displayed, it does not strictly cut each piece of text to be displayed into a slice according to the expected slice size, but rather dynamically adjusts based on the expected slice size, cutting complete characters in the text to be displayed into a slice, avoiding the situation where the sliced ​​text only includes a part of a character.

[0041] This application obtains the desired slice size and then performs dynamic slicing based on that size to obtain the slicing result. This ensures that the characters in each slice are complete, thus improving the accuracy of the rendering after slicing.

[0042] As an optional example, the dynamic slicing action is performed on the text to be displayed according to the expected slice size. The sliced ​​result of the text to be displayed includes: when the expected slice size is a number of bytes, starting from the first character of the remaining data after the previous slicing of the text to be displayed, the initial landing point of the current slice is determined according to the number of bytes; when the initial landing point is located in the middle of any target character, the characters from the first character to the target character are determined as the current slice.

[0043] In this application, since the expected slice size has different types, different slicing methods can be used for different types of expected slice sizes. If the expected slice size is in bytes, there can be a dynamic slicing method with automatic shrinking. Specifically, for the text to be displayed, the position of the initial landing point of the current slice is determined by counting from the first character of the text to be displayed, when slicing according to the expected slice size.

[0044] For example, if the desired slice size is 10 bytes, start from the first byte of the text to be displayed, count forward 9 bytes (10 bytes total) to determine the initial stop point. Then, for the initial stop point, determine if it lies in the middle of a target character. If it does, traverse backward from that initial stop point until the boundary between two characters. The characters from the first byte to that boundary are then defined as the first slice. For the next slice, use the remaining data from the previous slice as a reference and continue slicing in the same way until all slices of the text to be displayed are obtained.

[0045] In this application, for each slicing operation, if the initial landing point of the slice splits a character, it will automatically shrink according to the expected slice size, thereby ensuring that the data contained in each slice is a complete character and ensuring the accuracy of the slicing results.

[0046] As an optional example, when the initial landing point is located in the middle of any target character, determining the characters from the first character to the target character as the current slice includes: traversing backward from the initial landing point of the target character, determining whether the traversed position is the boundary between the target character and the previous character for each byte traversed; when the boundary is reached, the data from the first character to the boundary is sliced ​​as the current slice; when the number of traversals exceeds 3, determining that the boundary between the target character and the previous character has not been identified, and traversing backward again from the initial landing point.

[0047] In this application, since automatic scaling can be performed during the slicing of the text to be displayed in the above process, when automatically scaling, bytes are traversed backward from the initial landing point. Therefore, it is necessary to determine whether the boundary between two characters has been reached when traversing each byte backward. Only if the boundary between two characters has been reached can the slice position of the complete character be determined.

[0048] During the traversal, a constraint can be added: the number of bytes traversed forward cannot exceed 3. Since the maximum number of bytes for a character is 4, and the initial landing point is not the boundary of the character, if the number of bytes traversed forward exceeds 3, it means that at least the boundary of the character has been traversed but not recognized. In this case, it is necessary to traverse again from the initial landing point to determine the boundary between the two characters.

[0049] To determine whether the boundary between two characters has been reached after traversing bytes, the following method can be used: After traversing one byte backward from the current point, for that byte, determine whether it includes the first byte of an ASCII character, a double-byte character, a triple-byte character, or a quad-byte character. For example, the first byte pattern for an ASCII character is 0xxxxxxx, for a double-byte character it is 110xxxxx, for a triple-byte character it is 1110xxxx, and for a quad-byte character it is 11110xxx. Compare the data of the byte traversed backward from the current point with the data of the above first byte patterns to determine whether the traversed byte is the first byte of a certain character. If it is the first byte of a certain character, then the boundary between two characters has been determined.

[0050] This application improves the accuracy of determining the boundary between two characters by adding traversal constraints to avoid unlimited traversal.

[0051] As an optional example, when the initial landing point is in the middle of any target character, determining the characters from the first character to the target character as the current slice includes: when the first character is the target character, determining the target character as the current slice.

[0052] In this application, for the case of traversing bytes backward from the initial landing point, there is an additional situation where, during the backward traversal from the initial landing point, the first character is encountered. In this case, slicing is not possible. The reason for this phenomenon is that the expected slice size is too small, and a complete character cannot be sliced ​​into a single piece. Therefore, in this case, automatic expansion is required. Traversing backward from the current landing point, when a character boundary is reached, slicing is performed from the boundary to obtain a complete character.

[0053] This application ensures the accuracy of the slicing process by automatically expanding the capacity for cases with extremely small expected slice sizes.

[0054] As an optional example, performing dynamic slicing on the text to be displayed based on the expected slice size to obtain the sliced ​​result of the text to be displayed includes: when the expected slice size is the data size, determining the corresponding range of bytes according to the data size value; slicing the text to be displayed according to the range of bytes to obtain the sliced ​​result.

[0055] In this application, besides the case where the expected slice size is in bytes, the expected slice size may also be in the form of data size, i.e., in bytes (b), kilobytes (kb), etc. In this case, the range of bytes can be determined based on the data size of the expected slice. For example, 128 bytes corresponds to 8-12 bytes, and 1 kb corresponds to 60-100 bytes (these figures are for illustrative purposes only and do not constitute a limitation). Therefore, when slicing the text to be displayed, the aforementioned range of bytes can be used. For example, slicing the text to be displayed into slices of 8-12 bytes is acceptable.

[0056] In this slicing scenario, for a byte range of 8-12 bytes, the text to be displayed can be sliced ​​starting from the largest (smallest, or random) byte range. During slicing, if the initial landing point does not fall on a character boundary, the slicer can iterate towards the smallest (or largest) byte range, selecting other byte ranges for slicing, further determining whether a complete character can be sliced. Therefore, each slice of the text to be displayed includes 8-12 bytes, and all characters within it are complete. The only difference is the size of the slices, which vary, falling into different cases of 8, 9, 10, 11, and 12 bytes. For a byte range of 60-100 bytes, the same slicing method can be used to divide the text to be displayed into multiple slices, each slice being between 60 and 100 bytes in size.

[0057] This application allows for the creation of slices of different sizes from the text to be displayed by setting the desired slice size to the number of bytes. It does not necessarily require all slices to be the same size, which can improve the efficiency of slicing the text to be displayed. Furthermore, different scenarios may require different slice sizes, and processing slices of different sizes is more efficient.

[0058] The following section explains the process of slicing and rendering the text to be displayed based on the user's input text in the large LLM model of vehicle human-computer interaction, along with the corresponding attached diagrams.

[0059] Figure 2This is the overall framework diagram of the present application. The LLM of the in-vehicle intelligent cockpit streams the text to be displayed. The text to be displayed determines the global offset of the global adjustment range of the text whose format needs to be adjusted in the input layer. After dynamic slicing in the core algorithm layer, the global offset of the global adjustment range is mapped to the local offset of the local adjustment range through the offset mapping algorithm in the output layer. When displaying on the in-vehicle display screen, local adjustment display is performed on the local text of the target slice.

[0060] Figure 3 This is the algorithm principle diagram in the present application. In UTF-8 encoding, one character is represented by 1 - 4 bytes, and the first byte of the character identifies the byte length of the character through a specific bit pattern.

[0061] For ASCII characters, usually 1 byte, such as 'A', '1', '!', the first byte bit pattern is 0xxxxxxx. Double-byte characters are 2 bytes, such as 'é', 'ñ', and the first byte bit pattern is 110xxxxx. Triple-byte characters are 3 bytes, such as '中', '世', '界', and the first byte bit pattern is 1110xxxx. Quad-byte characters are 4 bytes, such as emoticons, etc., and the first byte bit pattern is 11110xxx. When slicing the text to be displayed, through the dynamic boundary adjustment strategy, priority is given to reducing the capacity. When the expected slice end position falls in the middle of a certain character, move back to the start position of that character to ensure that the byte size limit is not exceeded. The alternative strategy is to increase the capacity. If moving back will result in an empty slice (moving back to the start position), then extend backward, including at least one complete character, even if it slightly exceeds the expected slice size limit. The constraint algorithm moves back at most 3 bytes forward (UTF-8 characters are at most 4 bytes, minus the current position there are 3 bytes) to ensure finding the complete character boundary.

[0062] Figure 4 This is the core flowchart of the algorithm. It is illustrated in combination with an example of slicing the text to be displayed. For example, if the text to be displayed is "Hello世界", and the byte positions are 0 1 2 3 4 5 6 7 8 9 10 respectively, and the byte size occupied by the text is 1 1 1 1 [3 bytes][3 bytes]. For example, if the expected slice size is 10 bytes, if sliced by 10 bytes, the initial landing point is between the 2nd and 3rd bytes of "界". At this time, if sliced, the bytes of the "界" character will be cut into two parts. At this time, dynamic capacity reduction is performed. Traverse the bytes forward and find that position 8 is the first byte (1110xxxx) of "界", so traverse to between "世" and "界" and perform slicing. The slicing results are slice 1: "Hello世" (8 bytes, slightly less than 10 bytes), and slice 2: "界" (3 bytes).

[0063] The above example is for the case of dynamic capacity reduction. For the case of dynamic capacity expansion, if the text to be displayed is "world", which is 6 bytes in total and has a size of [3 bytes][3 bytes]. For example, if the expected slice size is 2 bytes, when slicing, the initial landing point is between the 2nd and 3rd bytes of "世". At this time, if traversing bytes forward, it will traverse before the first byte of "世", and slicing is not possible at this time. Therefore, it is necessary to traverse backward again until between "世" and "界", and then the slicing is completed. Slice 1: "世" (3 bytes, slightly larger than 2 bytes), Slice 2: "界".

[0064] Adopt the scheme of dynamic capacity expansion and dynamic capacity reduction to complete the slicing of the text to be displayed. After obtaining the slicing result of the text to be displayed, since the text to be displayed includes the text whose format needs to be adjusted, for the slicing result, it is necessary to determine the target slice including the character to be adjusted and the local offset of the character to be adjusted in the target slice.

[0065] Figure 5a and Figure 5b is a schematic diagram of calculating the target slice and the local offset of the character to be adjusted in this application. Figure 5a is the first part of the process. Figure 5b is the second part of the process. After the text to be displayed is sliced, each slice has its own local coordinate system (counting starts from 0). Format information such as keyword format adjustment is usually represented by a global offset (relative to the starting position of the text to be displayed), and it needs to be converted to the local offset of each slice. Traverse each slice, calculate the global character range [chunkGlobalStart, chunkGlobalEnd) of this slice in the original text, and check whether there is an intersection between the given global adjustment range and the global offset [globalStart, globalEnd) of the character whose format needs to be adjusted in the original text. If there is an intersection, calculate the local offset of the intersection in the slice: localStart = max(0, globalStart - chunkGlobalStart) localEnd = min(chunkLength, globalEnd - chunkGlobalStart) A necessary and sufficient condition for two intervals [a, b) and [c, d) to have an intersection is: a < d AND b > c.

[0066] For example, taking the text to be displayed as "Hello world, welcome to the in-vehicle intelligent cockpit system" as an example, the character length is 20 characters, and the global offset of the global adjustment range is [4, 10) (indicating that "o world, welcome" needs formatting adjustment). The expected slice size is 7 bytes. Then the slice result is: Slice 0: "Hello" (5 bytes) - Global character range: [0, 5) - Check intersection: 4 < 5 AND 10 > 0 → Intersection exists - Local offset: [max(0, 4-0), min(5, 10-0) )= [4, 5) - Character that needs adjustment: "o" Slice 1: "World" (6 bytes) - Global character range: [5, 7) - Check intersection: 4 < 7 AND 10 > 5 → There is intersection - Local offset: [max(0, 4-5), min(2, 10-5) ) = [0, 2) - Characters that need adjustment: "world" Slice 2: ", Welcome" (7 bytes) - Global character range: [7, 10) - Check intersection: 4 < 10 AND 10 > 7 → There is an intersection - Local offset: [max(0, 4-7), min(3, 10-7) ) = [0, 3) - Characters that need adjustment: ",Welcome" Slices 3-7 are: Usage, Vehicle, Intelligence, Cockpit, and System. These have no overlap with the global offset of the global adjustment range and will not be adjusted. If there are multiple global offsets in the global adjustment range, then for each slice, it must be compared with each global offset.

[0067] Calculations show that the slicing algorithm in this application has a time complexity of O(n), where n is the number of text bytes. Each byte is accessed at most once. The offset mapping algorithm has a time complexity of O(m × k), where m is the number of slices and k is the number of global adjustment ranges. The space complexity is O(m), requiring the storage of m slices and their corresponding offset information.

[0068] Since the text length in vehicle scenarios is usually between a few KB and tens of KB, and the number of slices is usually no more than 100, the execution efficiency of the algorithm fully meets the real-time requirements (usually completed within 1ms).

[0069] Figure 6a and Figure 6b This is an overall framework diagram of one application scenario of this application. Figure 6a This is the first part of the process. Figure 6b This is the latter part of the process. This application can be applied to voice interaction response display: users interact with AI assistants via voice, and the responses generated by LLM need to be displayed in real time on the in-vehicle screen, with key information (such as location, time, name, etc.) highlighted.

[0070] For example, navigation instructions generated by AI assistants contain multiple key information points (starting point, destination, route, etc.), which need to be formatted to help drivers quickly identify them. Similarly, vehicle status reports generated by AI assistants (such as tire pressure, fuel level, maintenance reminders, etc.) require specially formatted alerts for anomalies. Furthermore, AI assistants may combine text, images, and actions to generate responses, with the text portion needing to maintain the integrity of the formatted information.

[0071] Figure 7 This is a schematic diagram of the structure of a display device for displaying text of a large language model, provided as an embodiment of this application. Figure 7 As shown, the display device for the text to be displayed in the above-mentioned large language model includes: The acquisition module 702 is used to acquire the global offset of the target text that needs to be formatted in the text to be displayed when the text to be displayed is acquired; The first determining module 704 is used to determine the global character range of each slice in the slicing result based on the slicing result of the text to be displayed; The second determining module 706 is used to determine, based on the comparison result of the global character range and the global offset, the target slice including the character to be adjusted, and the local offset of the character to be adjusted in the target slice. Display module 708 is used to adjust the format of the characters to be adjusted corresponding to the local offset in the target slice of the text to be displayed in a streaming manner.

[0072] This application can be applied to scenarios involving the display of long text. Long text is typically text with a large volume of text. Due to the large volume of text, it is necessary to slice the text before displaying it. During the display of long text, this application can accurately determine whether each slice contains characters that need to be formatted, even after slicing the text to be displayed. Therefore, when displaying the slices, the characters to be formatted are formatted and then displayed.

[0073] Furthermore, the present application can be applied to the scenario of formatting the text to be displayed of a large language model. For the text to be displayed generated by the large language model for the input text, the amount of text is large, and the global offset of the target text that needs to be formatted is included in the text to be displayed. For example, if the text to be displayed is "Hello, nice to meet you", the global offset can be [4, 6], indicating that the 4th to 6th characters are the target text to be formatted. If the global offset is [4, 6), it means that the 4th to 5th characters are the target text to be formatted. Corresponding to the text to be displayed, "nice" needs to be formatted.

[0074] The formatting in the present application can be at least one of adjusting color, text size, bold, italic, underline, special marking, etc. For example, coloring specific text to improve visibility so that users can easily focus on key content.

[0075] The global offset can not only be used to mark the global character position, but in the present application, the global offset can also be used to mark which byte the target text that needs to be formatted is in the global sorting. In the present application, the number of bytes occupied by characters and symbols is not the same. For example, in the present application, ASCII characters (English letters, numbers, basic symbols) occupy 1 byte, Chinese characters usually occupy 3 bytes, Emoji emoticons occupy 4 bytes, and special symbols may occupy 2 bytes. Specifically, Chinese characters can also occupy 2 bytes, and the number of bytes occupied can be modified according to the actual situation, but when implementing the solution of the present application, the number of bytes occupied is fixed.

[0076] In the case where the global offset is used to mark bytes, for example, if the text to be displayed is "Hello, nice to meet you", the global offset can be [10, 16), indicating that the 10th to 15th bytes are the bytes that need to be formatted, and corresponding to the text to be displayed, "nice" needs to be formatted.

[0077] Since the above text to be displayed has a global offset, and the global offset is used to mark the target text that needs to be formatted in the text to be displayed, so if the text to be displayed is directly displayed, formatting can be performed. However, in a streaming scenario, the text to be displayed is not output at once, but is output in a stream, and streaming output can significantly reduce the user-perceived latency and improve the interaction experience. Therefore, the text to be displayed will be sliced into multiple shards and transmitted in a sharded manner. When transmitting in shards, the original global offset cannot mark which characters in the sharding result need to be formatted. So, in the present application, after slicing the text to be displayed to obtain the slicing result, it is necessary to determine the global character range of each slice.

[0078] The global character range of each slice is its position within the text to be displayed. For example, if the text to be displayed is "Hello, nice to meet you", and the slices are "Hello", "Nice to meet you", and "Meet you", then following the principle that text occupies 3 bytes and symbols occupy 1 byte, the global byte range of each of the three slices is [0,7), [7,16) and [16,25), and the global character range is [0,3), [3,6) and [6,9).

[0079] After determining the global character range of each slice and obtaining the global offset of the target text, we can use both to determine whether each slice contains the character to be adjusted, and the local offset of the character to be adjusted in the target slice that contains the character to be adjusted.

[0080] Once the target slice containing the character to be adjusted is determined, and the local offset of the character to be adjusted is determined, the character to be adjusted in the target slice can be rendered according to the local offset (when the target slice is displayed).

[0081] This application achieves the effect of correctly adjusting the format of specific text within the target text that needs to be formatted when the text to be displayed is obtained; the global character range of each slice in the sliced ​​text is determined based on the sliced ​​text; the target slice containing the characters to be formatted is determined from the sliced ​​text based on the comparison between the global character range and the global offset, and the local offset of the characters to be formatted within the target slice is determined; during the streaming display of the target slices of the text to be displayed, the format of the characters to be formatted corresponding to the local offsets in the target slices is adjusted before display. This allows the global offset of the target text that needs to be formatted in the text to be displayed output by the large language model to be mapped to each target slice containing the characters to be formatted, obtaining the local offset, and rendering the characters to be formatted according to the local offset. This enables the long text output by the large language model to be displayed with the format of specific text that needs to be formatted correctly.

[0082] For other examples of this embodiment, please refer to the examples above, which will not be repeated here.

[0083] like Figure 8 As shown in the figure, this application provides an electronic device, including a processor 111, a communication interface 112, a memory 113, and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114. Memory 113 is used to store computer programs; In one embodiment of this application, the processor 111, when executing the program stored in the memory 113, implements the method for displaying the text to be displayed of the large language model provided in any of the foregoing method embodiments.

[0084] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements a method for displaying text of a large language model as provided in any of the foregoing method embodiments.

[0085] The device 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.

[0086] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable 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 the various embodiments or some parts of the embodiments.

[0087] It should be understood that the terminology used herein is for the purpose of describing particular exemplary embodiments only and is not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms “a,” “an,” and “described” as used herein may also include the plural forms. The terms “comprising,” “including,” “containing,” and “having” are inclusive and therefore indicate the presence of the stated features, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not construed as requiring them to be performed in a particular order described or illustrated unless the order of performance is explicitly indicated. It should also be understood that additional or alternative steps may be used.

[0088] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for displaying text to be displayed, characterized in that, include: When the text to be displayed is obtained, the global offset of the target text whose format needs to be adjusted is obtained from the text to be displayed; Based on the slicing results of the text to be displayed, determine the global character range of each slice in the slicing results; Based on the comparison result between the global character range and the global offset, the target slice including the character to be adjusted is determined from the slicing result, and the local offset of the character to be adjusted in the target slice is determined. During the process of displaying the target slice of the text to be displayed in a streaming manner, the characters to be adjusted in the target slice corresponding to the local offset are formatted and then displayed.

2. The method according to claim 1, characterized in that, Based on the comparison result between the global character range and the global offset, the target slices including the characters to be adjusted are determined from the slicing results as follows: Compare the global character range of each slice with the global offset; If the comparison results show that the two slices intersect, then the corresponding slice is determined to be the target slice.

3. The method according to claim 1, characterized in that, Determining the local offset of the character to be adjusted within its target slice includes: The local offset is determined using the following formula: u=[max(0,ca),min(chunkLength,da))(1) The global character range of the target slice is [a, b), the global offset is [c, d), u is the local offset of the character to be adjusted in the target slice, and chunkLength is the length of the global character range.

4. The method according to any one of claims 1 to 3, characterized in that, Before determining the global character range of each slice in the sliced ​​result based on the sliced ​​result of the text to be displayed, the method further includes: Obtain the desired slice size of the text to be displayed; Based on the desired slice size, a dynamic slicing action is performed on the text to be displayed to obtain the sliced ​​result of the text to be displayed.

5. The method according to claim 4, characterized in that, Based on the desired slice size, a dynamic slicing action is performed on the text to be displayed to obtain the sliced ​​result of the text to be displayed, including: When the expected slice size is a number of bytes, the initial landing point of the current slice is determined starting from the first character of the remaining data after the previous slice of the text to be displayed, according to the number of bytes. When the initial landing point is located in the middle of any target character, the characters from the first character to the target character are determined as the current slice.

6. The method according to claim 5, characterized in that, When the initial landing point is located in the middle of any target character, the characters from the first character to the target character are determined as the current slice, including: Starting from the initial landing point of the target character, traverse backwards, and after each traversal of 1 byte, determine whether the traversed position is the boundary between the target character and the previous character; When traversing to the boundary, the data from the first character to the boundary is sliced ​​into the current slice; When the number of iterations exceeds 3, it is determined that the boundary between the target character and the previous character has not been identified, and the iteration starts again from the initial landing point.

7. The method according to claim 5, characterized in that, When the initial landing point is located in the middle of any target character, the characters from the first character to the target character are determined as the current slice, including: When the first character is the target character, the target character is determined as the current slice.

8. The method according to claim 4, characterized in that, Based on the desired slice size, a dynamic slicing action is performed on the text to be displayed to obtain the sliced ​​result of the text to be displayed, including: When the expected slice size is equal to the data size, the corresponding range of bytes is determined according to the value of the data size; The text to be displayed is sliced ​​according to the range of the number of bytes to obtain the slicing result.

9. A display device for displaying text, characterized in that, include: The acquisition module is used to acquire the global offset of the target text that needs to be formatted in the text to be displayed when the text to be displayed is acquired; The first determining module is used to determine the global character range of each slice in the slicing result based on the slicing result of the text to be displayed; The second determining module is used to determine, based on the comparison result between the global character range and the global offset, a target slice including the character to be adjusted from the slicing result, and to determine the local offset of the character to be adjusted in the target slice. The display module is used to adjust the format of the characters to be adjusted corresponding to the local offset in the target slice of the text to be displayed in a streaming manner.

10. A computer-readable storage medium, characterized in that, The storage medium stores computer-executable instructions for executing the method for displaying text of a large language model as described in any one of claims 1 to 8 of this application.