A character display method, system and related device
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-14
- Publication Date
- 2026-08-11
AI Technical Summary
[0003]但是语言模型具有超大的参数量和计算量,生成目标文本所需的时间较长,且文本长度越长耗费时间越长
[0066] In a seventh aspect, embodiments of this application provide a computer program product that, when run on an electronic device, causes the electronic device to execute the text display method in any possible implementation of the third aspect described above.
Smart Images

Figure CN119629162B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of machine learning, and more particularly to a text display method, system, and related apparatus. Background Technology
[0002] With the continuous development of machine learning technologies, natural language processing algorithms are becoming increasingly mature. Electronic devices can generate target text based on user-input speech or preliminary text using language models. After obtaining the complete target text, the electronic device can display it on a screen.
[0003] However, language models have a huge number of parameters and require a lot of computation, making it time-consuming to generate the target text, and the longer the text, the longer it takes. If the target text is output in the above way, the user's waiting time will be too long, resulting in a poor user experience. Summary of the Invention
[0004] This application provides a text display method, system, and related apparatus, which reduces user waiting time and avoids stuttering during text display, thus achieving smooth text output.
[0005] In a first aspect, this application provides a text display system, comprising: an electronic device and a cloud server; wherein, the electronic device is configured to send a first message to the cloud server; the cloud server is configured to generate a first target text corresponding to the first message through a language model; the cloud server is further configured to send a first display speed and the first text segment to the electronic device after generating a first text segment in the first target text; the first display speed is used to indicate the number of characters in the first target text displayed per unit time; the electronic device is further configured to display the first text segment at the first display speed; the cloud server is further configured to generate a second text segment in the first target text before the electronic device finishes displaying the first text segment at the first display speed, the second text segment being located after the first text segment in the first target text; the cloud server is further configured to send the second text segment to the electronic device after generating the second text segment of the first target text; the electronic device is further configured to receive the second text segment before or after the first text segment finishes displaying at the first display speed; the electronic device is further configured to display the second text segment at the first display speed after the first text segment finishes displaying at the first display speed.
[0006] This not only allows the generated text to be displayed during the process of generating the target text, reducing the user's waiting time, but also avoids lag during the display process, ensuring smooth text display.
[0007] In one possible implementation, the first text segment includes at least one language symbol token, and the second text segment includes one token; the cloud server is further configured to obtain a first generation speed during the generation of the first target text, the first generation speed being used to indicate the number of tokens generated per unit time; the cloud server is further configured to determine a first display speed based on the first generation speed and a first constraint relationship; the first constraint relationship is that the first display speed is less than or equal to the product of the first generation speed and a first scale, the first scale being the ratio of the number of characters corresponding to the language model to the number of tokens.
[0008] In this way, the number of tokens sent in the first transmission is greater than or equal to the number of tokens sent in each subsequent transmission. The longer time required to display all the text sent in the first transmission ensures smooth text display.
[0009] In one possible implementation, the cloud server is further configured to: acquire a first generation speed during the generation of the first target text, the first generation speed indicating the number of tokens generated per unit time; determine a first display speed based on the first generation speed and a first constraint relationship; the first constraint relationship being that the first display speed equals the product of the first generation speed and a first constant, the first constant being less than a first ratio, the first ratio being the ratio of the number of characters corresponding to the language model to the number of tokens; set a word count range, the word count range indicating the range of word counts for a single text segment of the first target text; determine a first text segment based on the word count range during the generation of the first target text; determine that the first text segment is risk-free before sending it; determine a second text segment based on the word count range during the generation of the first target text, the second text segment having a word count within the word count range; and determine that the second text segment is risk-free before sending it.
[0010] In this way, by setting the word count range for a text segment and the text display speed, smooth display between two adjacent text segments can be ensured.
[0011] In one possible implementation, the cloud server is further configured to determine a third text segment based on a word count range during the generation of the first target text, wherein the third text segment follows the second text segment in the first target text; the cloud server is further configured to determine that the third text segment is risky; the cloud server is further configured to send the third text segment and first risk information to the electronic device, wherein the first risk information indicates that the first target text is risky; and the electronic device is further configured to withdraw all content already displayed in the first target text after receiving the first risk information.
[0012] In this way, if the target text is detected to be risky, the electronic device can retract the content that has been displayed.
[0013] In one possible implementation, the cloud server is further configured to send a second risk information to the electronic device when sending the first text segment, the second risk information indicating that the first target text is currently safe; the cloud server is further configured to send a second risk information to the electronic device when sending the second text segment.
[0014] In this way, even if the target text is risk-free, the cloud server can still send risk information to the electronic device. This risk information is used to notify the electronic device that the current text segment is risk-free.
[0015] In one possible implementation, the electronic device is also used to establish a long-lived connection with the cloud server before sending the first message to the cloud server.
[0016] In this way, data such as the first message and the first target text can be transmitted via long-lived links.
[0017] In one possible implementation, the electronic device is also used to receive the user's first input before establishing a long connection with the cloud server; the electronic device is also used to determine a first message based on the first input.
[0018] The first input type can include: voice input, text input, and event input. The first message type can include: voice message, text message, or event message.
[0019] Determining the first message based on the first input specifically includes: determining the type of the first message based on the type of the first input; and determining the content of the first message based on the content of the first input. The content of the first message can be the same as the content of the first input.
[0020] In one possible implementation, the electronic device is further configured to disconnect the long-lived link with the cloud server when a first disconnection condition is detected; the first disconnection condition includes any one or more of the following: a network error, receiving a first operation from the user, the first operation being used to trigger the electronic device to stop using the language model service.
[0021] In this way, electronic devices can disconnect the long-lived link with the cloud server if the first disconnection condition is met.
[0022] In one possible implementation, the cloud server is also configured to disconnect the long link with the electronic device when a second disconnection condition is detected; the second disconnection condition includes any one or more of the following: network error, completion of sending the first target text, completion of sending the first target text and no message received from the electronic device within a first time period after completion of sending.
[0023] In this way, the cloud server can disconnect the long-lived link with the electronic device if it detects that the second disconnection condition has been met.
[0024] In one possible implementation, the electronic device is further configured to receive a second user input after displaying the first target text at a first display speed; the electronic device is further configured to determine a second message based on the second input; the electronic device is further configured to send the second message to a cloud server; the cloud server is further configured to generate the second target text corresponding to the second message through a language model; the cloud server is further configured to send a second display speed and a fourth text segment to the electronic device after generating a fourth text segment in the second target text; the second display speed is used to indicate the number of characters displayed in the second target text per unit time; the electronic device is further configured to display the fourth text segment at the second display speed; the cloud server is further configured to generate a fifth text segment in the second target text before the electronic device finishes displaying the fourth text segment at the second display speed, the fifth text segment being after the fourth text segment in the second target text; the cloud server is further configured to send the fifth text segment to the electronic device after generating the fifth text segment in the second target text; the electronic device is further configured to receive the fifth text segment before or while displaying the fourth text segment at the second display speed; the electronic device is further configured to display the fifth text segment at the second display speed after displaying the fourth text segment at the second display speed.
[0025] In this way, the second message and the second target text can also be transmitted through this long link.
[0026] In one possible implementation, the electronic device is further configured to send a second message to the cloud server, specifically including: the electronic device is further configured to send a second message to the cloud server when the time interval between the moment the first target text is displayed and the moment the second input is received is less than a second duration.
[0027] Long-lived connections can be reused with a time threshold. Within the preset time threshold, a second message can reuse the long-lived connection used to transmit the first message. This way, if a long-lived connection is not used for an extended period, it can be automatically disconnected, reducing energy consumption.
[0028] Secondly, this application provides a text display method applied to a cloud server. The method includes: receiving a first message sent by an electronic device; generating a first target text corresponding to the first message through a language model; after generating a first text segment in the first target text, sending a first display speed and the first text segment to the electronic device; the first display speed is used to indicate the number of characters displayed per unit time; generating a second text segment in the first target text, the second text segment being located after the first text segment in the first target text; and sending the second text segment to the electronic device before the electronic device finishes displaying the first text segment at the first display speed.
[0029] This not only allows the generated text to be displayed during the process of generating the target text, reducing the user's waiting time, but also avoids lag during the display process, ensuring smooth text display.
[0030] In one possible implementation, the first text segment includes one or more language symbol tokens, and the second text segment includes one token; the method further includes: during the generation of the first target text, obtaining a first generation speed, which is used to indicate the number of tokens generated per unit time; determining a first display speed based on the first generation speed and a first constraint relationship; the first constraint relationship is that the first display speed is less than or equal to the product of the first generation speed and a first scale, where the first scale is the ratio of the number of characters corresponding to the language model to the number of tokens.
[0031] In this way, the number of tokens sent in the first transmission is greater than or equal to the number of tokens sent in each subsequent transmission. The longer time required to display all the text sent in the first transmission ensures smooth text display.
[0032] In one possible implementation, the method further includes: during the generation of the first target text, obtaining a first generation speed, which indicates the number of tokens generated per unit time; determining a first display speed based on the first generation speed and a first constraint relationship; the first constraint relationship is that the first display speed is equal to the product of the first generation speed and a first constant, the first constant being less than a first ratio, the first ratio being the ratio of the number of characters corresponding to the language model to the number of tokens; setting a word count range, which indicates the word count range of a single text segment of the first target text; during the generation of the first target text, determining a first text segment based on the word count range; before sending the first text segment, determining that the first text segment is risk-free; during the generation of the first target text, determining a second text segment based on the word count range, the word count of the second text segment belonging to the word count range; before sending the second text segment, determining that the second text segment is risk-free.
[0033] In this way, by setting the word count range for a text segment and the text display speed, smooth display between two adjacent text segments can be ensured.
[0034] In one possible implementation, the method further includes: during the generation of the first target text, determining a third text segment based on a word count range, wherein the third text segment is located after the second text segment in the first target text; determining that the third text segment is risky; and sending the third text segment and first risk information to an electronic device, wherein the first risk information is used to indicate that the first target text is risky.
[0035] In this way, if the target text is detected to be risky, the electronic device can retract the content that has been displayed.
[0036] In one possible implementation, the method further includes: sending a second risk information to the electronic device when sending the first text segment, the second risk information indicating that the first target text is currently free of risk; and sending the second risk information to the electronic device when sending the second text segment.
[0037] In this way, even if the target text is risk-free, the cloud server can still send risk information to the electronic device. This risk information is used to notify the electronic device that the current text segment is risk-free.
[0038] In one possible implementation, the method further includes establishing a long-lived connection with the electronic device before receiving the first message sent by the electronic device.
[0039] In this way, data such as the first message and the first target text can be transmitted via long-lived links.
[0040] In one possible implementation, the method further includes: disconnecting the long link with the electronic device when a second disconnection condition is detected; the second disconnection condition includes any one or more of the following: network error, completion of sending the first target text, completion of sending the first target text and no message received from the electronic device within a first time period after completion of sending.
[0041] In this way, the cloud server can disconnect the long-lived link with the electronic device if it detects that the second disconnection condition has been met.
[0042] In one possible implementation, the method further includes: receiving a second message sent by an electronic device after sending the first target text; generating a second target text corresponding to the second message through a language model; sending a second display speed and the fourth text segment to the electronic device after generating a fourth text segment in the second target text; generating a fifth text segment in the second target text before the electronic device finishes displaying the fourth text segment at the second display speed, wherein the fifth text segment is located after the fourth text segment in the second target text; and sending the fifth text segment to the electronic device after generating the fifth text segment in the second target text.
[0043] In this way, the second message and the second target text can also be transmitted through this long link.
[0044] Thirdly, this application provides a text display method applied to an electronic device. The method includes: sending a first message to a cloud server; receiving a first display speed and a first text segment in a first target text sent by the cloud server; the first display speed is used to indicate the number of characters in the first target text displayed per unit time; the first target text is text generated by the cloud server based on the first message through a language model; displaying the first text segment at the first display speed; receiving a second text segment in the first target text before the electronic device finishes displaying the first text segment at the first display speed, the second text segment being located after the first text segment in the first target text; and displaying the second text segment at the first display speed after the first text segment has been displayed at the first display speed.
[0045] This not only allows the generated text to be displayed during the process of generating the target text, reducing the user's waiting time, but also avoids lag during the display process, ensuring smooth text display.
[0046] In one possible implementation, the first text segment includes one or more language symbol tokens, and the second text segment includes one token.
[0047] In this way, the number of tokens sent in the first transmission is greater than or equal to the number of tokens sent in each subsequent transmission. The longer time required to display all the text sent in the first transmission ensures smooth text display.
[0048] In one possible implementation, the method further includes: receiving a third text segment and first risk information sent by a cloud server, the first risk information indicating that the first target text is risky; and after receiving the first risk information, withdrawing all content already displayed in the first target text.
[0049] In this way, if the target text is detected to be risky, the electronic device can retract the content that has been displayed.
[0050] In one possible implementation, receiving a first display speed and a first text segment from a first target text sent by a cloud server specifically includes: receiving the first display speed, the first text segment from the first target text, and second risk information sent by the cloud server, wherein the second risk information is used to indicate that the first target text is currently free of risk; receiving a second text segment from the first target text specifically includes: receiving the second text segment from the first target text and the second risk information.
[0051] In this way, electronic devices can determine whether the current text segment is risky based on risk information sent by the cloud server.
[0052] In one possible implementation, the method also includes establishing a long-lived connection with the cloud server before sending the first message to the cloud server.
[0053] In this way, data such as the first message and the first target text can be transmitted via long-lived links.
[0054] In one possible implementation, the method further includes: receiving the user's first input before establishing a long connection with the cloud server; and determining a first message based on the first input in response to the first input.
[0055] The first input type can include: voice input, text input, and event input. The first message type can include: voice message, text message, or event message.
[0056] Determining the first message based on the first input specifically includes: determining the type of the first message based on the type of the first input; and determining the content of the first message based on the content of the first input. The content of the first message can be the same as the content of the first input.
[0057] In one possible implementation, the method further includes: disconnecting the long-lived link with the cloud server when a first disconnection condition is detected; the first disconnection condition includes any one or more of the following: a network error, receiving a first operation from the user, the first operation being used to trigger the electronic device to stop using the language model service.
[0058] In this way, electronic devices can disconnect the long-lived link with the cloud server if the first disconnection condition is met.
[0059] In one possible implementation, the method further includes: after displaying the first target text at a first display speed, receiving a second input from the user; in response to the second input, determining a second message based on the second input; sending the second message to a cloud server; receiving a second display speed and a fourth text segment from the second target text sent by the cloud server; the second display speed is used to indicate the number of characters displayed in the second target text per unit time; the second target text is text generated by the cloud server based on the second message through a language model; displaying the fourth text segment at the second display speed; before the electronic device finishes displaying the fourth text segment at the second display speed, receiving a fifth text segment from the second target text, the fifth text segment being after the fourth text segment in the second target text; and displaying the fifth text segment at the second display speed after displaying the fourth text segment at the second display speed.
[0060] In this way, the second message and the second target text can also be transmitted through this long link.
[0061] In one possible implementation, sending a second message to the cloud server specifically includes: sending a second message to the cloud server when the time interval between the moment the first target text is displayed and the moment the second input is received is less than a second duration.
[0062] Long-lived connections can be reused with a time threshold. Within the preset time threshold, a second message can reuse the long-lived connection used to transmit the first message. This way, if a long-lived connection is not used for an extended period, it can be automatically disconnected, reducing energy consumption.
[0063] Fourthly, this application provides a server comprising: one or more processors and one or more memories. The one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program code, including computer instructions, which, when executed by the one or more processors, cause the server to perform the text display method in any of the possible implementations of the second aspect described above.
[0064] Fifthly, this application provides an electronic device comprising: one or more processors and one or more memories. The one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program code, including computer instructions, which, when executed by the one or more processors, cause the electronic device to perform the text display method of any possible implementation of the third aspect described above.
[0065] Sixthly, embodiments of this application provide a computer storage medium including computer instructions, which, when executed on a server, cause the server to perform the text display method in any possible implementation of the second aspect described above.
[0066] In a seventh aspect, embodiments of this application provide a computer program product that, when run on an electronic device, causes the electronic device to execute the text display method in any possible implementation of the third aspect described above.
[0067] The beneficial effects of aspects four through seven can be referred to the beneficial effects described in aspects one through three above. Attached Figure Description
[0068] Figure 1A A schematic diagram of a language token in text A provided in this application embodiment;
[0069] Figure 1B This application provides a schematic diagram of the system architecture of a text display system 10 according to an embodiment of the present application.
[0070] Figure 1C A schematic diagram of the hardware structure of an electronic device 100 provided in an embodiment of this application;
[0071] Figure 1D A schematic diagram of the hardware structure of a cloud server 200 provided in an embodiment of this application;
[0072] Figure 2A A schematic diagram illustrating the time relationship between the generation time, transmission time, and display time of token1 provided in an embodiment of this application;
[0073] Figure 2B A schematic diagram illustrating the time relationship between the generation time, transmission time, and display time of token2, provided for an embodiment of this application;
[0074] Figure 3 A flowchart illustrating a text display method provided in an embodiment of this application;
[0075] Figure 4A A schematic diagram illustrating the time relationship between the generation time, transmission time, and display time of text segment 1 provided in an embodiment of this application;
[0076] Figure 4B A schematic diagram illustrating the time relationship between the generation time, transmission time, and display time of text segment 2 provided in an embodiment of this application;
[0077] Figure 5 A flowchart illustrating another text display method provided in an embodiment of this application;
[0078] Figures 6A-6F A schematic diagram of an interface for a set of text display methods provided in an embodiment of this application;
[0079] Figure 7A This is a schematic diagram of the functional modules of a text display system 10 provided in an embodiment of this application;
[0080] Figure 7B This is a schematic diagram illustrating two types of links between the electronic device 100 and the various modules of the cloud server 200 provided in this embodiment of the application.
[0081] Figure 8 A schematic diagram of the software architecture of an electronic device 100 provided in an embodiment of this application;
[0082] Figure 9 This is a flowchart illustrating a text display method provided in an embodiment of this application. Detailed Implementation
[0083] The technical solutions in the embodiments of this application will be clearly and thoroughly described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; the word "and / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0084] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0085] The term "user interface (UI)" used in the following embodiments of this application refers to the medium interface through which an application or operating system interacts and exchanges information with a user. It realizes the conversion between the internal form of information and the form that the user can accept. The user interface is source code written in a specific computer language such as Java or Extensible Markup Language (XML). The interface source code is parsed and rendered on the electronic device, ultimately presenting content that the user can recognize. A common form of user interface is the graphical user interface (GUI), which refers to a user interface related to computer operation displayed graphically. It can be visible interface elements such as text, icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, and widgets displayed on the screen of an electronic device.
[0086] The following describes some technical terms used in the embodiments of this application.
[0087] Natural Language Understanding (NLU): NLU is a discipline that integrates linguistics, logic, psychology, and computer science. Through the analysis of syntax, semantics, and pragmatics, NLU can obtain semantic representations of natural language.
[0088] Large Language Model (LLM): An LLM is a neural network model trained on a large amount of text data. It possesses powerful natural language processing and code generation capabilities, and has wide applications in natural language processing, machine translation, dialogue systems, and code generation. An LLM can generate text by learning from large amounts of text data (such as web pages, books, and papers). LLMs typically consist of millions of parameters and have high representational and generative capabilities. By inputting a problem or task description, an LLM can generate corresponding code or text.
[0089] Language tokens: Tokens are the basic units of natural language. A token can be a word, phrase, or a character, etc. After receiving input, LLM can generate target text using tokens as the basic units.
[0090] For example, Figure 1A This illustration shows a token in text A provided in an embodiment of this application.
[0091] like Figure 1A As shown, text A can be the text "In our daily lives, we always face various challenges." Based on grammar and semantics, text A can include the following tokens: "in," "we," "of," "daily," "life," "in," "," "we," "always," "will," "face," "various," "different," "of," "challenges," and ".", and the order of these tokens matches their order in text A. Since LLM generates text using tokens as the basic unit, LLM can sequentially generate all tokens in text A according to their order in text A, until all tokens in text A are generated.
[0092] Understandable Figure 1A The illustrated embodiment is merely an example. In the embodiments of this application, different texts may include more, fewer, or different tokens than those in the above embodiments, and this application does not impose any limitations on them.
[0093] Long-lived links: Also known as persistent links, long-lived links are links that are not immediately disconnected after data transmission is complete. Conversely, links that are immediately disconnected after data transmission are complete are short-lived links. In this application embodiment, long-lived links may include network sockets (WebSockets), etc.
[0094] The following describes the system architecture of a text display system 10 provided in an embodiment of this application.
[0095] like Figure 1B As shown, the text display system 10 may include an electronic device 100 and a cloud server 200.
[0096] Electronic device 100 can receive and respond to user input (e.g., voice input, text input, etc.) and determine message 1 (e.g., voice message, text message, or event message, etc.). After receiving message 1, electronic device 100 can establish a long connection with cloud server 200 and send message 1 to cloud server 200 through this long connection. Electronic device 100 can receive the display time of a single character sent by cloud server 200, and can also receive target text sent by cloud server 200 in multiple installments, and display the target text based on the display time of a single character (i.e., displaying one character at each time interval corresponding to the display time of a single character).
[0097] Cloud server 200 can store one or more language models, such as LLM. After receiving message 1, cloud server 200 can call the LLM to generate target text corresponding to message 1 and send the target text to electronic device 100 through the long-lived connection. It should be noted that cloud server 200 can continuously send the tokens generated in the target text to electronic device 100 during the target text generation process until all tokens of the target text have been sent, thus reducing user waiting time. Furthermore, during the target text generation process, cloud server 200 can also detect the generation time of individual tokens (or retrieve the generation time of individual tokens corresponding to pre-stored LLM), determine the display time of individual characters based on the generation time of individual tokens, and send the display time of individual characters to electronic device 100. This ensures that electronic device 100 can display the target text smoothly.
[0098] Understandable Figure 1B The text display system 10 shown is just an example. In this application embodiment, the text display system 10 may also include more electronic devices or one or more servers. This application does not limit this.
[0099] Figure 1CA schematic diagram of the hardware structure of the electronic device 100 is shown.
[0100] Electronic device 100 may be a mobile phone, tablet computer, desktop computer, laptop computer, handheld computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, as well as cellular phone, personal digital assistant (PDA), augmented reality (AR) device, virtual reality (VR) device, artificial intelligence (AI) device, wearable device, in-vehicle device, smart home device and / or smart city device. The embodiments of this application do not impose any special restrictions on the specific type of electronic device.
[0101] Electronic device 100 may include a processor 110, internal memory 121, charging management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, sensor module 180, and display screen 194, etc. Optionally, electronic device 100 may also include any one or more of the following: external memory interface 120, buttons 190, motor 191, indicator 192, etc.
[0102] The sensor module 180 may include one or more sensors, such as a touch sensor 180K. In some embodiments, the sensor module 180 may also include any one or more of the following: a pressure sensor, a gyroscope sensor, a barometric pressure sensor, a magnetic sensor, an accelerometer, a distance sensor, a proximity sensor, a fingerprint sensor, a temperature sensor, an ambient light sensor, a bone conduction sensor, etc.
[0103] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0104] Processor 110 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). These different processing units may be independent devices or integrated into one or more processors.
[0105] The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.
[0106] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0107] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0108] The charging management module 140 receives charging input from a charger. The charger can be a wireless charger or a wired charger. In some wireless charging embodiments, the charging management module 140 can receive wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also supply power to the electronic device via the power management module 141.
[0109] The power management module 141 connects the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, internal memory 121, display screen 194, and wireless communication module 160, etc. The power management module 141 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be located in the same device.
[0110] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.
[0111] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with tuning switches.
[0112] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be housed in the same device.
[0113] The modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs sound signals through an audio device (not limited to speaker 170A, receiver 170B, etc.) or displays images or videos through the display screen 194. In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 110 and may be housed in the same device as the mobile communication module 150 or other functional modules.
[0114] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, demodulates and filters the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, frequency modulate and amplify them, and then convert them into electromagnetic waves for radiation via antenna 2.
[0115] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, enabling electronic device 100 to communicate with networks and other devices via wireless communication technology. The wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. The GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).
[0116] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0117] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), or it can be manufactured using organic light-emitting diodes (OLEDs), active-matrix organic light-emitting diodes (AMOLEDs), flexible light-emitting diodes (FLEDs), minimized LEDs, microLEDs, micro-OLEDs, quantum dot light-emitting diodes (QLEDs), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.
[0118] Internal memory 121 may include one or more random access memory (RAM) and one or more non-volatile memory (NVM). The RAM can be directly read and written by the processor 110 and can be used to store executable programs (e.g., machine instructions) of the operating system or other running programs, as well as user and application data. The NVM can also store executable programs and user and application data, and can be pre-loaded into the RAM for direct read and write operations by the processor 110.
[0119] The external memory interface 120 can be used to connect to external non-volatile memory, thereby expanding the storage capacity of the electronic device 100. The external non-volatile memory communicates with the processor 110 through the external memory interface 120 to perform data storage functions. For example, music, video, and other files can be stored in the external non-volatile memory.
[0120] The audio module 170 may include one or more of the following: a speaker, a receiver, a microphone, and a headphone jack. The electronic device 100 can implement audio functions, such as music playback and recording, through the audio module 170 and an application processor.
[0121] The audio module 170 is used to convert digital audio information into analog audio signals for output, and also to convert analog audio input into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110.
[0122] A loudspeaker, also known as a "speaker," is used to convert audio electrical signals into sound signals. Electronic device 100 can listen to music or make hands-free calls through loudspeaker 170A.
[0123] A receiver, also known as a "handpiece," is used to convert audio electrical signals into sound signals. When an electronic device answers a phone call or voice message, the receiver can be brought close to the listener's ear to hear the voice.
[0124] A microphone, also known as a "voice transducer," is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user speaks by bringing their mouth close to the microphone, inputting the sound signal into the microphone. Electronic device 100 may be equipped with at least one microphone. In some embodiments, electronic device 100 may be equipped with two microphones, which, in addition to collecting sound signals, can also perform noise reduction. In other embodiments, electronic device 100 may be equipped with three, four, or more microphones, enabling sound signal collection, noise reduction, sound source identification, and directional recording, among other functions.
[0125] Touch sensor 180K, also known as a "touch device," can be located on display screen 194. The touch sensor 180K and display screen 194 together form a touchscreen, also known as a "touchscreen." Touch sensor 180K detects touch operations applied to or near it. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 194. In other embodiments, touch sensor 180K may also be located on the surface of electronic device 100, in a different position than display screen 194.
[0126] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. Electronic device 100 can receive button input and generate key signal inputs related to user settings and function control of electronic device 100.
[0127] Motor 191 can generate vibration alerts. Motor 191 can be used for incoming call vibration alerts or for touch vibration feedback. For example, different vibration feedback effects can correspond to touch operations performed on different applications (such as taking photos, playing audio, etc.). Motor 191 can also correspond to different vibration feedback effects for touch operations performed on different areas of the display screen 194. Different application scenarios (such as time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also be customized.
[0128] Indicator 192 can be an indicator light, used to indicate charging status, power changes, or to indicate messages, missed calls, notifications, etc.
[0129] Figure 1D This illustration shows a schematic diagram of the hardware structure of a cloud server 200 provided in an embodiment of this application.
[0130] like Figure 1D As shown, the cloud server 200 may include one or more network device processors 201, memory 202, communication interface 203, transmitter 205, receiver 206, coupler 207, and antenna 208. These components can be connected via bus 204 or other means. Figure 1C Taking a bus connection as an example:
[0131] The communication interface 203 can be used by the cloud server 200 to communicate with other communication devices, such as electronic devices used by consumers of the project. Specifically, the communication interface 203 can be a 3G communication interface, a Long Term Evolution (LTE) (4G) communication interface, a 5G communication interface, a WLAN communication interface, a WAN communication interface, etc. Not limited to wireless communication interfaces, the cloud server 200 can also be configured with a wired communication interface 203 to support wired communication.
[0132] In some embodiments of this application, transmitter 205 and receiver 206 can be considered as a wireless modem. Transmitter 205 can be used to transmit signals output by network device processor 201. Receiver 206 can be used to receive signals. In cloud server 200, the number of transmitters 205 and receivers 206 can be one or more. Antenna 208 can be used to convert electromagnetic energy in a transmission line into electromagnetic waves in free space, or to convert electromagnetic waves in free space into electromagnetic energy in a transmission line. Coupler 207 can be used to split mobile communication signals into multiple paths and distribute them to multiple receivers 206. Understandably, the antenna 208 of the network device can be implemented as a large-scale antenna array.
[0133] The memory 202 is coupled to the network device processor 201 and is used to store various software programs and / or multiple sets of instructions. Specifically, the memory 202 may include high-speed random access memory and may also include non-volatile memory, such as one or more disk storage devices, flash memory devices, or other non-volatile solid-state storage devices.
[0134] The memory 202 can store an operating system (hereinafter referred to as the system), such as uCOS, VxWorks, RTLinux and other embedded operating systems. The memory 202 can also store a network communication program, which can be used to communicate with other communication devices.
[0135] In this embodiment, the network device processor 201 can be used to read and execute computer-readable instructions. Specifically, the network device processor 201 can be used to call a program stored in the memory 202, such as the implementation program of the text display method provided in one or more embodiments of this application, and execute the instructions contained in the program.
[0136] It needs to be explained that, Figure 1D The cloud server 200 shown is merely one implementation of the embodiment of this application. In actual applications, the cloud server 200 may include more or fewer components, which is not limited here.
[0137] This application provides a text display method. An electronic device 100 can receive and respond to user input, determining the type and content of message 1. Message 1 can be a voice message, text message, or event message, etc. The electronic device 100 establishes a long connection with a cloud server 200 and sends message 1 to the cloud server 200 through this long connection. After receiving message 1, the cloud server 200 can generate the target text corresponding to message 1 using a language model. During the generation of the target text, the cloud server 200 can send the generated language symbols (tokens) in the target text to the electronic device 100 sequentially according to the generation order. Furthermore, the cloud server 200 can determine the display time of a single character based on the generation time of a single token and send the display time of a single character to the electronic device 100. The electronic device 100 can display the target text based on the display time of a single character (i.e., displaying one character at each time interval corresponding to the display time of a single character).
[0138] This reduces user waiting time, ensures smooth text output, avoids output lag, and provides users with a better user experience.
[0139] The following describes the relationship between the generation time and display time of adjacent tokens in a target text, as provided in an embodiment of this application.
[0140] Figure 2A This illustration shows the generation, transmission, and display time of token1 in target text according to an embodiment of this application.
[0141] like Figure 2A As shown, a one-dimensional coordinate axis can represent time. Time's up At any given time, cloud server 200 can generate token1. Time's up At any given time, cloud server 200 can send token1 to electronic device 100. At that moment, electronic device 100 can begin to display the text in token1 at a constant speed. At any given time, electronic device 100 can display all the text in token1. This is due to the display duration of a single character. It is fixed; if the number of characters in token1 is... ,but and The following relationship exists between them:
[0142] Formula (1)
[0143] Figure 2B This illustration shows the generation, transmission, and display time of token2 in target text according to an embodiment of this application.
[0144] like Figure 2B As shown, a one-dimensional coordinate axis can represent time. Since token2 and token1 are two adjacent tokens in the target text, and token1 was generated before token2, then in At that moment, cloud server 200 can begin generating token2. Time's up At any given time, cloud server 200 can generate token2. Time's up At any given time, cloud server 200 can send token2 to electronic device 100. The time is when electronic device 100 receives token2. Once the moment arrives, the electronic device 100 can display all the text in token2 at a constant speed.
[0145] During the process of cloud server 200 generating multiple tokens for the target text, it can be assumed that the token generation speed is uniform, that is, the time taken by cloud server 200 to generate a single token is... .therefore, and The following relationship exists between them:
[0146] Formula (2)
[0147] To avoid lag during the display of target text by electronic device 100, electronic device 100 needs to immediately start displaying token2 after displaying token1. The reception time of token2... No later than the moment token1 is displayed That is:
[0148] Formula (3)
[0149] Under stable network conditions, the data size of a single token is not significantly different, and the time consumed in transmitting a single token is relatively small. They can be considered the same, at this time, and , and The following relationship can be satisfied
[0150] Formula (4)
[0151] Formula (5)
[0152] Combining the above formulas (1)-(5), we can obtain:
[0153] Formula (6)
[0154] In the above formula (6), This represents the time it takes for the cloud server 200 to generate a single character. Therefore, under stable network conditions, when the time it takes for the electronic device 100 to display a single character is greater than or equal to the average time it takes for the cloud server 200 to generate a single character (i.e., the speed at which the electronic device 100 displays text is less than the speed at which the cloud server 200 generates text), the electronic device 100 can avoid stuttering during the display process, ensuring smooth text display.
[0155] If we define scale as the ratio of the number of characters to the number of tokens in the same text, then we have
[0156] Formula (7)
[0157] In the above formula (7), The number of characters in a text. The `scale` parameter represents the number of tokens within the same text, while `total` represents the ratio of the number of characters to the number of tokens within the same text. Based on the above... Figure 1A As shown in the example, a token can include one or more texts, that is, the value of scale can be greater than or equal to 1.
[0158] The time it takes for a cloud server to generate a token The average time it takes to generate a text The following relationships can exist between them:
[0159] Formula (8)
[0160] Combining formula (8), the above formula (6) can be equivalent to the following formula (9):
[0161] Formula (9)
[0162] In the above formula (9), the left side of the inequality is This can represent the time it takes for an electronic device to display a single character; the right side of the inequality... This can represent the time taken by the cloud server 200 to generate a single character. According to formula (9), when the time taken by the electronic device 100 to display a single character is greater than or equal to the ratio of the time taken by the cloud server 200 to generate a single token to the scale, the electronic device 100 can avoid stuttering during the display process and ensure smooth text display.
[0163] It is understood that in this application embodiment, there may be a certain time interval between the generation time and the sending time of the token. In this case, as long as the time interval is fixed, the electronic device 100 can still avoid stuttering during the display process and ensure smooth text display under the condition of satisfying the above formula (9).
[0164] The following describes the specific process of a text display method provided in an embodiment of this application.
[0165] like Figure 3 As shown, the specific process of a text display method provided in this application embodiment may include the following steps:
[0166] S301, electronic device 100 receives and responds to user input, confirms message 1, which may be a voice message, a text message, or an event message.
[0167] In this embodiment of the application, the user's input can be text input, such as entering the text "Please write an article of 100 words". The user's input can also be voice input, such as the voice command "Recite a poem".
[0168] In other embodiments, user input can also be event input, used to set events and event triggering conditions. Event triggering conditions can be a predetermined time or a predetermined state (e.g., awake state, exercise state, music listening state), etc. This application does not limit the event triggering conditions. Electronic device 100 can receive and respond to user input, storing the correspondence between events and event triggering conditions. For example, Table 1 shows a correspondence between events and event triggering conditions provided by an embodiment of this application.
[0169] Table 1
[0170]
[0171] As shown in Table 1, the electronic device 100 can store events and event triggering conditions based on user input. For example, the triggering condition for the event "output an article related to spring" is the time "14:00"; the triggering condition for the event "output a 100-word music appreciation article" is listening to music, etc.
[0172] It is understood that the embodiments shown in Table 1 are merely examples. In the embodiments of this application, the electronic device 100 may also store more or fewer events and triggering conditions than those shown in Table 1, or may be different from those shown in Table 1. This application does not limit the scope of the invention.
[0173] Electronic device 100 can determine message 1 based on user input. Message 1 can be of the following types: voice message, text message, and event message. When the user input is text input, message 1 is a text message. When the user input is voice input, message 1 is a voice message. When the user input is used to set the triggering condition for an event, message 1 is an event message.
[0174] If the user's input is text or voice input, the electronic device 100 can determine message 1 based on the user's input upon receiving the input. In this case, the content of message 1 can include the content of the user's input (text or voice). For example, if the user's input is "Write an article related to animals," then message 1 can include "Write an article related to animals."
[0175] If the user's input is an event input, the electronic device 100 can receive and respond to the user's input, set the event and the event's triggering conditions, and determine message 1 when the triggering conditions of the event are detected. The content of message 1 can include the content of the event. For example, if the event is "output an article related to spring", then message 1 can include "output an article related to spring".
[0176] S302, Electronic device 100 establishes a long-term connection with cloud server 200.
[0177] After confirming message 1, the electronic device 100 can establish a persistent connection with the cloud server 200. In some embodiments, the persistent connection can be a WebSocket. Details of the persistent connection between the electronic device 100 and the cloud server 200 can be found below. Figure 7B The relevant descriptions in the illustrated embodiments will not be detailed here.
[0178] In some other embodiments, if a long link has already been established between the electronic device 100 and the cloud server 200, step S302 may not be performed. In this case, the electronic device 100 can communicate with the cloud server 200 through the established long link.
[0179] S303, Electronic device 100 sends message 1 to cloud server 200 via a long connection.
[0180] S304, Cloud Server 200 generates target text based on message 1 using a language model. The target text includes multiple tokens.
[0181] A cloud server 200 can store one or more language models, such as LLM.
[0182] In some embodiments, after receiving message 1, the cloud server 200 can use message 1 as input to the LLM and generate the target text corresponding to message 1 through the LLM.
[0183] During the generation of multiple tokens for the target text, the cloud server 200 can store these multiple tokens in the order of generation.
[0184] For example, Table 2 shows a generated token stored in a cloud server 200 according to an embodiment of this application.
[0185] Table 2
[0186]
[0187] As shown in Table 2, the cloud server 200 can store multiple generated tokens and their corresponding generation order. For example, token1, token2, and token3, where token1 is generated in order 1, token2 in order 2, token3 in order 3, and so on.
[0188] It is understood that the embodiments shown in Table 2 are merely examples. In the embodiments of this application, the cloud server 200 may store more, fewer, or different tokens than those shown in Table 2 above, and this application does not impose any limitations on this.
[0189] As another example, Table 3 shows another generated token stored in a cloud server 200 provided in an embodiment of this application.
[0190] Table 3
[0191]
[0192] As shown in Table 3, the cloud server 200 can store multiple generated tokens along with their corresponding generation order and sending identifiers. For example, token1, token2, and token3, where token1 was generated in order 1, token2 in order 2, and token3 in order 3, etc. The sending identifier indicates whether the token was sent by the cloud server 200. Table 3 shows that the sending identifiers for token1, token2, and token3 are all "not sent," indicating that all three tokens were sent by the cloud server 200.
[0193] It is understood that the embodiments shown in Table 3 are merely examples. In the embodiments of this application, the cloud server 200 may store more, fewer, or different tokens or sending identifiers than those shown in Table 3 above. This application does not impose any limitations on these embodiments.
[0194] In other embodiments, during the process of generating multiple tokens for the target text, the cloud server 200 may also store the generated text in the target text and the order in which the text was generated, according to the generation order. The specific storage format can be referred to the embodiments shown in Table 2 or Table 3 above, and will not be repeated here.
[0195] S305, the time it takes for the cloud server to obtain a language model and generate a token. .
[0196] In some embodiments, the cloud server 200 may store the time taken by the LLM to generate a token. It should be noted that after the language model is trained, the speed at which the language model generates tokens is deterministic; that is, after LLM training is complete, the time taken by the LLM to generate a token can be measured. and will It is stored on cloud server 200.
[0197] In other embodiments, the cloud server 200 may also detect during the LLM generation of the target text. Specifically, the cloud server 200 can detect the number of tokens generated by the LLM within a fixed time interval (e.g., 100 milliseconds) and determine the [unclear - possibly related to token generation] based on this fixed time interval and the number of generated tokens. The fixed time interval can be a preset time interval.
[0198] It should be noted that because the LLM needs to parse message 1 before generating the target text, this parsing process takes time. Therefore, the time from receiving message 1 to generating the first token of the target text is relatively long (e.g., 250 milliseconds), which can be called the first token latency. After generating the first token, the LLM can continuously generate subsequent tokens at a uniform rate. Therefore, when calculating the time it takes for the LLM to generate a single token... At that time, the cloud server 200 can select fixed time intervals within a period after the LLM generates the first token, detect the number of tokens generated within those fixed time intervals, and determine the time taken for the LLM to generate one token. This avoids errors caused by the latency of the first token.
[0199] S306, cloud server 200 based Determine the display time of a single character. .
[0200] The cloud server 200 can store a scale (e.g., 1.25, 1.20, etc.), which indicates the ratio of the number of characters to the number of tokens in the same text. This preset scale value can be set by the administrator of the cloud server 200, or it can be determined by the cloud server 200 based on the ratio of the number of characters to the number of tokens in a large number of texts stored internally. This application does not limit the value of the scale or the method of determining it. In some embodiments, different language models can correspond to different scale values. The cloud server 200 can store the correspondence between language models and scale values, and determine the corresponding scale value based on the currently used language model.
[0201] Cloud server 200 can be based on The scale is obtained through the above formula (9). . This can be used to indicate the number of characters displayed per unit time by the electronic device 100 during the display of target text. This prevents lag and ensures smooth display during the display of target text.
[0202] S307, in determining Subsequently, cloud server 200 sends a message to electronic device 100 via a long connection. And the already generated token.
[0203] Determine the display time of a single character. Afterwards, the cloud server 200 can send one or more generated tokens to the electronic device 100. It is understood that, if the number of tokens sent initially is greater than or equal to one, and the number of tokens sent subsequently is also one, the time taken to display all the tokens sent initially is greater than or equal to the time required to generate the next token. This ensures that the next token is received before the electronic device 100 displays all the tokens sent initially.
[0204] In some embodiments, when sending the generated token to the electronic device 100, the cloud server 200 may also send the generation order of the token. For example, when sending token1 and token2 as shown in Table 2 above, the generation order 1 of token1 and the generation order 2 of token2 are sent to the electronic device 100 together.
[0205] In other embodiments, the cloud server 200 may also send one or more tokens to the electronic device 100 sequentially according to the order in which the tokens were generated. For example, if it is determined that... If the cloud server 200 has generated multiple tokens as shown in Table 2 above, then the cloud server 200 can first send token1 to the electronic device 100, then send token2, and then send token3.
[0206] In some embodiments, after the cloud server 200 sends a token to the electronic device 100, the cloud server 200 can delete the sent token from a stored pool of generated tokens. For example, if it is determined that... At that time, if the generated tokens stored in cloud server 200 are multiple tokens as shown in Table 2 above, then cloud server 200 will... After token1, token2 and token3 are sent to electronic device 100, the tokens stored in cloud server 200 can be referred to the embodiments shown in Table 4 below.
[0207] Table 4
[0208]
[0209] As shown in Table 4, cloud server 200 can store newly generated tokens and their corresponding generation order. For example, token4, whose generation order is 4. Here, token4 is determined by cloud server 200. The newly generated tokens. Furthermore, Table 4 does not include the already sent tokens 1, 2, and 3.
[0210] It is understood that the embodiments shown in Table 4 are merely illustrative examples illustrating that the cloud server 200 can delete sent tokens from the stored multiple tokens. In this application embodiment, the tokens stored by the cloud server 200 during the token sending process may include more, fewer, or different tokens than those in Table 4, and this application does not impose any limitations on this.
[0211] In other embodiments, if the cloud server 200 stores a sending identifier corresponding to a generated token, then after sending the token, the cloud server 200 can change the sending identifier of the token from "not sent" to "sent". For example, if it is determined that... At that time, if the generated tokens stored in cloud server 200 are multiple tokens as shown in Table 3 above, then cloud server 200 will... After token1, token2 and token3 are sent to electronic device 100, the tokens stored in cloud server 200 can be referred to the embodiments shown in Table 5 below.
[0212] Table 5
[0213]
[0214] As shown in Table 5, the cloud server 200 can store multiple generated tokens along with their corresponding generation order and sending identifier. For example, token1, token2, token3, and token4, where token4 is the token determined by the cloud server 200. The newly generated tokens follow a sequence where token1 is generated in order 1, token2 in order 2, token3 in order 3, token4 in order 4, and so on. The sending identifier indicates whether the token has been sent by cloud server 200. As shown in Table 5, the sending identifiers for token1, token2, and token3 are all "sent," indicating that these three tokens have been sent by cloud server 200. The sending identifier for token4 is "not sent," indicating that token4 has not yet been sent by cloud server 200.
[0215] It is understood that the embodiments shown in Table 5 are merely examples. In the embodiments of this application, the cloud server 200 may store more, fewer, or different tokens or sending identifiers than those shown in Table 5 above. This application does not impose any limitations on these embodiments.
[0216] S308, Electronic Device 100 Based on Display the received token.
[0217] After receiving the and one or more tokens sent by the cloud server 200, the electronic device 100 may display the one or more tokens based on . Specifically, the electronic device 100 may display all the received tokens at a speed of displaying one more character at each interval based on the order of receiving the tokens (or based on the generation order of the received tokens).
[0218] Exemplarily, if all the received tokens are "we" in sequence, then the electronic device 100 may first display the character "我" and, after , display "们" at the display position after the character "我".
[0219] The specific manner in which the electronic device 100 displays the target text based on may also refer to the relevant descriptions in the following Figures 6A-6F shown embodiments.
[0220] S309. When detecting a newly generated token, the cloud server 200 sends the token to the electronic device 100 through a long connection.
[0221] In some embodiments, after sending , if the cloud server 200 detects a newly generated token, the cloud server 200 may send the token to the electronic device 100. That is, the newly generated token can be sent to the electronic device 100 after it is generated.
[0222] It should be noted that steps S309 to S310 are steps that can be repeatedly executed. When the cloud server 200 detects a newly generated token, steps S309 and S310 can be executed again.
[0223] S310. After the electronic device 100 displays all the previously received tokens, it displays the newly received token based on .
[0224] S311. When detecting that the disconnection condition is met, disconnect the long connection.
[0225] Disconnection conditions may include any one or more of the following: network error, cloud server 200 detecting that the target text has been sent, cloud server 200 detecting that the target text has been sent and not receiving a message from electronic device 100 within a preset time threshold after the sending is completed, electronic device 100 detecting that the user has ended the use of the language model service (e.g., exiting application 11, releasing the engine, etc.). Here, application 11 refers to an application that can provide language model services to the user through cloud server 200. In some embodiments, the disconnection conditions and the method of disconnecting the long connection may also refer to the following... Figure 7B The relevant descriptions in the illustrated embodiments.
[0226] The text display method provided in this application can reduce user waiting time and avoid stuttering during text display, ensuring smooth text display.
[0227] In some embodiments, the long-lived connection between electronic device 100 and cloud server 200 can be reused by other messages (e.g., message 2) generated by electronic device 100. Long-lived connection reuse means that the long-lived connection between electronic device 100 and cloud server 200 maintains a connection state across multiple requests and responses, so that the long-lived connection can be reused in subsequent requests without having to establish a new long-lived connection each time. This method can reduce the overhead of connection establishment and closure, and improve the efficiency of network communication. In this embodiment, long-lived connection timeout failure to reuse means that after the target text of message 1 is sent, electronic device 100 does not initiate a request to use the long-lived connection within a preset time threshold. The request to use the long-lived connection can be message 2, etc., determined by electronic device 100 based on another input from the user. It should be noted that in the case of long-lived connection reuse, the type of message 2 can be the same as or different from the type of message 1; this application does not limit this.
[0228] In some embodiments, the time threshold for the long link varies depending on the type of message 1. For example, when message 1 is a voice message, the time threshold for the long link can be 3 seconds, meaning that if the long link is not reused within 3 seconds after the target text of message 1 is sent, the long link is disconnected. As another example, when message 1 is a text message or an event message, the time threshold for the long link can be 60 seconds, meaning that if the long link is not reused within 60 seconds after the target text of message 1 is sent, the long link is disconnected. It is understood that the embodiments described here are merely illustrative examples illustrating that different types of message 1 have different time thresholds for the long link. In this application embodiment, the time threshold can also be a different value than the above embodiments, and this application does not limit it here.
[0229] In this embodiment of the application, the electronic device 100 can also be based on the display time of a single character. The display speed of the target text is determined, which indicates how many characters per second the electronic device 100 displays during the display of the target text. For example, if... If the time is 20 milliseconds, then the display speed of the target text is... After determining the display speed of the target text, the electronic device 100 can display the target text sent by the cloud server 200 based on the display speed. It is understood that, in some embodiments, the cloud server 200 can also determine the display time of a single character. Then, the display time based on a single character. The display speed of the target text is determined and sent to the electronic device 100. No specific requirements are set for this application.
[0230] In some application scenarios, the cloud server 200 also needs to perform risk control detection (hereinafter referred to as risk control detection) on the generated target text. Risk control detection may involve dividing the target text into multiple text segments and performing risk control detection on each text segment in turn. Each text segment may include one or more tokens. Since risk control detection needs to ensure the semantic integrity of the text segments, and different sentences have different lengths, the number of characters (or the number of tokens) in a text segment cannot be a fixed value. During the process of dividing the text segments, the number of characters in a text segment cannot be a fixed value, but it can correspond to a certain range, that is, the number of characters in a text segment can have a minimum value. and maximum value Maximum floating character count of a text segment It can be the maximum number of characters in the text segment. and minimum value The difference, that is:
[0231] Formula (10)
[0232] The following describes a method for determining the character count range of a text segment, provided by an embodiment of this application.
[0233] Figure 4A This illustration shows the generation, transmission, and display time of text segment 1 in a target text according to an embodiment of this application.
[0234] like Figure 4A As shown, a one-dimensional coordinate axis can represent time. Time's up At any given time, cloud server 200 can generate text segment 1. Time's up At any given time, cloud server 200 can perform risk control detection on text segment 1. Time's up At any time, cloud server 200 can send text segment 1 to electronic device 100. At that moment, electronic device 100 can begin displaying all the text in text segment 1 at a constant speed. At any given time, electronic device 100 can display all the text in text 1. This is due to the display time of a single character. It is fixed; if the number of characters in text segment 1 is... ,but and The following relationship exists between them:
[0235] Formula (11)
[0236] Figure 4B This illustration shows the generation, transmission, and display time of text segment 2 in a target text according to an embodiment of this application.
[0237] like Figure 4B As shown, a one-dimensional coordinate axis can represent time. Since text segment 2 and text segment 1 are two adjacent text segments in the target text, and text segment 1 was generated earlier than text segment 2, then in At that moment, cloud server 200 can begin generating text segment 2. Time's up At any given time, cloud server 200 can generate text segment 2. Time's up At any given time, cloud server 200 can perform risk control detection on text segment 2. Time's up At any time, cloud server 200 can send text segment 2 to electronic device 100. The time could be the moment when electronic device 100 receives text segment 2. Once the appointed time arrives, electronic device 100 can display all the text in text segment 2 at a constant speed. If the number of characters in text segment 2 is... ,but and The following relationship exists between them:
[0238] Formula (12)
[0239] In the above formula (12), The average time taken to generate a single token for cloud server 200, where scale is the ratio of the number of characters to the number of tokens in the same text.
[0240] Since the data volume between text segments is not significantly different, and risk control detection is based on the semantics of the text segments, the time spent on risk control detection for each text segment can be considered to be the same, i.e.:
[0241] Formula (13)
[0242] Under stable network conditions, the transmission time of text segments can also be considered approximately the same, that is:
[0243] Formula (14)
[0244] To avoid lag during the display of target text by electronic device 100, electronic device 100 needs to immediately start displaying text segment 2 after displaying text segment 1. The reception time of text segment 2... No later than the time when text segment 1 is finished being displayed That is:
[0245] Formula (15)
[0246] Combining formulas (11) to (15) above, we can obtain:
[0247] Formula (16)
[0248] If the number of words in text segment 1 is taken as The word count of text segment 2 is taken as Then formula (16) can be replaced by the following formula (17):
[0249] Formula (17)
[0250] From the above formula (9), it can be seen that, If the equal sign in formula (9) holds true, then the display time of a single character is the same as the generation time of a single character. In this case, the above formula (17) cannot hold true. Therefore, consider the case where the greater than sign in formula (9) holds true. If there exists a constant prop, and , The value of can be referenced in the following formula (18):
[0251] Formula (18)
[0252] Combining formula (18), the above formula (17) can be replaced by the following formula (19):
[0253] Formula (19)
[0254] As can be seen from the above embodiments, when the word count fluctuation is greatest between two adjacent text segments, if and If formula (19) is satisfied, then the electronic device 100 can avoid stuttering between text segments when displaying the target text. If the word count fluctuation between two adjacent text segments is less than the maximum word count fluctuation... ,exist and If formula (19) is satisfied, formula (16) above can obviously be satisfied, and electronic device 100 can also avoid stuttering between text segments when displaying target text.
[0255] Table 6 shows the interval distribution of sentence length provided in the embodiments of this application.
[0256] Table 6
[0257]
[0258] As shown in Table 6, after exhaustive statistical analysis of 1.2 million Chinese characters, sentences can be divided into multiple intervals based on the number of Chinese characters. Each interval corresponds to a different total number of sentences and a different percentage of the total. For example, interval 1 corresponds to the character range [1, 5], with a total of 25,620 sentences within this interval, accounting for 22.79% of the total sentences, and a cumulative value of 22.79%. Interval 2 corresponds to the character range [6, 10], with a total of 45,600 sentences within this interval, accounting for 40.56% of the total sentences, and a cumulative value of 63.35%. Interval 3 corresponds to the character range [11, 15], with a total of 25,275 sentences within this interval, accounting for 22.48% of the total sentences, and a cumulative value of 85.83%. Interval 4 corresponds to a word count range of [16, 20] words, with a total of 10020 sentences within this range, representing 8.91% of the total sentences, and a cumulative value of 94.74%. Interval 5 corresponds to a word count range of [21, 30] words, with a total of 5007 sentences within this range, representing 4.45% of the total sentences, and a cumulative value of 99.19%. Interval 6 corresponds to a word count range of [31, 40] words, with a total of 725 sentences within this range, representing 0.65% of the total sentences, and a cumulative value of 99.84%. Interval 7 corresponds to a word count range of [41, 50] words, with a total of 150 sentences within this range, representing 0.13% of the total sentences, and a cumulative value of 99.97%. The word count range corresponding to interval 8 is [51, 63]. The total number of sentences within this interval is 34, accounting for 0.03% of the total number of sentences, with a cumulative value of 100%. According to Table 6 above, most sentences have 6-10 words.
[0259] When selecting the word count for a text segment, you can refer to Table 6 for guidance. Since the text in a segment needs to ensure semantic integrity, and the length of most sentences falls within intervals 2 and 3 shown in Table 6, the maximum floating word count for a text segment is... Values can be taken from intervals 2 and 3 as shown in Table 6 above.
[0260] For example, You can take 10. We can take 1.2857. At this time, according to the above formula (19), the word count range corresponding to the text segment can be [35, 45].
[0261] It is understood that the embodiments described here are merely examples, and in the embodiments of this application, Other values can also be taken, and the word count range corresponding to the text segment can also be other ranges, as long as the above formula (19) is satisfied. This application does not limit the specific value of the word count range of the text segment.
[0262] The following describes the specific process of another text display method provided in the embodiments of this application.
[0263] S501, electronic device 100 receives and responds to user input, confirms message 1, which may be a voice message, a text message, or an event message.
[0264] S502, Electronic device 100 establishes a long-term connection with cloud server 200.
[0265] S503, Electronic device 100 sends message 1 to cloud server 200 via a long connection.
[0266] S504, cloud server 200 generates target text based on message 1 using a language model. The target text includes multiple tokens.
[0267] S505, cloud server 200, time spent obtaining language model and generating a token. .
[0268] The specific details of steps S501 to S505 can be found above. Figure 3 The relevant descriptions of steps S301 to S305 shown are not repeated here.
[0269] S506, cloud server 200 based Determine the display time of a single character. .
[0270] Cloud server 200 can be based on The display time of a single character is determined using the formula (18) above. .
[0271] in, It can be a real number greater than 0 and less than scale. It can be a preset constant. In other embodiments, if the value of scale is related to the language model used, then prop can also be the value of scale determined in real time.
[0272] S507, cloud server 200 retrieves the character count range of a text segment [ ].
[0273] In some embodiments, the word count range of a text segment [ The range can be a preset range, such as [35,45] or [20,26], etc. and The relationships shown in formulas (10) and (19) above must be satisfied. Wherein, The value is the same as the value in step S506.
[0274] In other embodiments, the word count range of the text segment [ Alternatively, the values of scale and prop can be determined by formulas (10) and (19) above, based on the values of scale and prop after the language model (e.g., LLM) is determined. This application does not limit this.
[0275] S508, when the number of characters in the generated token is detected to be greater than... At that time, the cloud server 200 is based on semantics and word count range [ Identify a text segment.
[0276] The text segment may include one or more generated tokens, and the number of characters in the text segment must fall within the specified range. ]Inside.
[0277] Cloud server 200 can determine the word count within a certain range based on syntax and semantics. The text segment.
[0278] For example, if the word count range [ Given a set of tokens [35, 45], the generated text composed of multiple tokens is: "I have a cute kitten. It's happy and carefree every day. It waits for me to come home from get off work every day. I like to play with the kitten, and the kitten likes to play with me too." When determining the text segment based on these tokens, we can first take the first 35 characters, i.e., "I have a cute kitten. It's happy and carefree every day. It waits for me to come home from get off work every day, I...". Semantic analysis shows that the meaning of these 35 characters is incomplete. Therefore, we continue taking values until the meaning of the text is complete, or until the number of characters in the text reaches 45. Therefore, the text segment determined based on these tokens is: "I have a cute kitten. It's happy and carefree every day. It waits for me to come home from get off work every day. I like to play with the kitten,...".
[0279] It is understood that the embodiments described herein are merely illustrative of how to base decisions on semantics and word count ranges. In this embodiment of the application, the multiple tokens generated by the cloud server 200 may also be different tokens from those in the above embodiment, and the number of characters ranges from […]. [It can also take different values, which are not limited in this application.]
[0280] In some embodiments, after determining a text segment, the cloud server 200 may store the text segment and delete all tokens (or text) included in the text segment from the generated token table. For example, if the cloud server 200 determines token1 and token2 in Table 2 above as a text segment, the text segment stored by the cloud server 200 may be the content shown in Table 7.
[0281] Table 7
[0282]
[0283] As shown in Table 7, the cloud server 200 can store a defined text segment, such as text segment 1. The content of text segment 1 may include token1 and token2. Optionally, the cloud server 200 can also store a sending identifier for the text segment to determine whether the text segment has been sent. The sending identifier for text segment 1 shown in Table 7 is "not sent," indicating that text segment 1 has not yet been sent.
[0284] In the above scenario, the multiple tokens generated and stored by the cloud server 200 can be as shown in Table 8 below.
[0285] Table 8
[0286]
[0287] As shown in Table 8, the multiple tokens generated by cloud server 200 may include token3, which is generated in the order of 3.
[0288] It is understood that the embodiments shown in Tables 7 and 8 are merely examples. In the embodiments of this application, the text segments stored in the cloud server 200 may include more, fewer, or different text segments from those shown in Table 7, and the multiple tokens generated stored in the cloud server 200 may also be different tokens from those shown in Table 8. This application does not impose any limitations on these embodiments.
[0289] It should be noted that steps S508 to S515 below are repeatable steps. When the cloud server 200 detects that the number of characters in the generated but unsent token is greater than [a certain value], [the process will continue]. At that time, cloud server 200 can execute step S508 and subsequent steps again.
[0290] S509, cloud server 200 performs risk detection on the newly identified text segment and obtains the risk information of the text segment.
[0291] Risk information can be used to indicate whether the text segment carries a risk. In some embodiments, risk information may include: risky and no risk.
[0292] S510, cloud server 200 determines whether the target text segment has been sent to electronic device 100.
[0293] If it is determined that the target text segment has not been sent to the electronic device 100, the cloud server 200 may perform the following step S511.
[0294] If it is determined that a text segment containing the target text has been sent to the electronic device 100, the cloud server 200 may perform the following step S512.
[0295] S511, Cloud Server 200 The newly identified text segment and its risk information are sent to electronic device 100 via a long link.
[0296] It can be used to indicate the number of characters displayed per unit time by an electronic device 100 during the display of target text.
[0297] In some embodiments, the cloud server 200 may also determine whether to send risk information to the electronic device 100 based on whether the text segment is risky. If the risk information of the text segment is no risk, no risk information is sent; if the risk information of the text segment is risky, the risk information of the text segment is sent to the electronic device 100. Optionally, if the text segment is risky, the cloud server 200 may also only send the risk information and not send the text segment.
[0298] After step S511, the electronic device 100 may perform the following step S513.
[0299] S512, cloud server 200 sends the newly determined text segment and the risk information of the text segment to electronic device 100 via a long link.
[0300] After step S512, the electronic device 100 may perform the following step S513.
[0301] S513, Electronic device 100 determines whether the target text is risky based on risk information.
[0302] When the risk information indicates that the target text is at risk, the electronic device 100 can determine that the target text is at risk; when the risk information indicates that the target text is at no risk, the electronic device 100 can determine that the target text is currently at no risk.
[0303] If the target text is determined to be risk-free, the electronic device 100 may perform the following step S514.
[0304] If the target text is determined to be risky, the electronic device 100 may perform the following step S515.
[0305] S514, Electronic device 100 based on After displaying all the previously received text segments, based on Display the newly received text segment.
[0306] When displaying target text, the electronic device 100 at intervals To display an additional piece of text, please refer to the above for specific display methods. Figure 3 The relevant description in step S308 is shown.
[0307] S515, Stop displaying the target text and remove the text already displayed in the target text.
[0308] S516: When the disconnection condition is detected, disconnect the long-lived connection.
[0309] The details of step S516 can be found above. Figure 3 The details of step S311 shown will not be repeated here.
[0310] The text display method provided in this application not only reduces user waiting time, but also enables risk control detection of the target text generated by the cloud server 200, and ensures smooth display of the target text by the electronic device 100, avoiding lag and improving the user experience.
[0311] In some application scenarios, if the user of electronic device 100 chooses to output the target text sent by cloud server 200 via voice, electronic device 100 can also receive and respond to the user's operation, based on... Output the received token (or text segment) at a constant speed, i.e., at each interval. Play a text message. In this application scenario, the process of using voice to output text can be similarly described above. Figure 3 or Figure 5 The relevant steps in the illustrated embodiment will not be repeated here.
[0312] The following is a schematic diagram of the interface of a set of text display methods provided in the embodiments of this application.
[0313] When the electronic device 100 displays the interface 1 of application 11, the electronic device 100 can receive and respond to user input (such as voice input, text input, etc.), display the user-inputted content on the interface 1, determine message 1 based on the user input, and send message 1 to the cloud server 200. The electronic device 100 receives the message from the cloud server 200 indicating the display of a single character. After the token (or a segment of the target text) is displayed in interface 1 at intervals... Display one more character from the target text until all the text in the target text has been displayed. This allows the target text to be displayed while it is being generated by the cloud server 200, reducing the initial waiting time for the user. It also allows for... Control the time taken for the electronic device 100 to display a single character, and avoid stuttering during the display process.
[0314] For example, such as Figure 6A As shown, the electronic device 100 displays an application interface 600, which may include a text input control 601 and a voice input control 602. The text input control 601 can be used to trigger the electronic device 100 to display the user-inputted text in the application interface 600 based on the user's text input. The voice input control 602 can be used to trigger the electronic device 100 to display the text content corresponding to the user's voice input in the application interface 600 based on the user's voice input.
[0315] Electronic device 100 can receive and respond to user input to text input control 601, such as... Figure 6B As shown, a dialog box 603 is displayed in the application interface 600. The text input by the user, such as "Write an article of about 100 words", may be displayed in the dialog box 603. After the dialog box 603 is displayed, the electronic device 100 may further display a waiting indicator 604 below the dialog box 603. The waiting indicator 604 can be used to prompt the user to wait for the generation of the text corresponding to the dialog box 603.
[0316] After the electronic device 100 receives the time for displaying a single character and the token of the target text (or the text segment of the target text) sent by the cloud server 200 as Figure 6C shown, the electronic device 100 may display a dialog box 605 in the application interface 600 and display the first character in the received token (or text segment) in the dialog box 605, such as "In".
[0317] After a period of time as Figure 6D shown, the electronic device 100 may display the first character "I" after "In" in the dialog box 605. Moreover, the display position of "I" is the display position after the display position of the character "In".
[0318] After a period of time as Figure 6E shown, the electronic device 100 may display the first character "We" after "I" in the dialog box 605. Moreover, the display position of "We" is the display position after the display position of the character "I".
[0319] After that, the electronic device 100 may repeat the above process, displaying the next character at each interval until all the characters in the target text are displayed. Exemplarily, after all the characters of the target text are displayed, the electronic device 100 may display the application interface 600 as Figure 6F shown.
[0320] As Figure 6F shown, the electronic device 100 displays all the characters of the target text in the dialog box 605, such as "In our daily life, we always face various challenges. Sometimes, these challenges may come from our work, sometimes from our interpersonal relationships, and sometimes from our health conditions.". The target text is the text generated by the cloud server 200 based on the content input by the user.
[0321] It can be understood that Figures 6A to 6FThe embodiment shown is just an example. In the embodiments of this application, application 11 can be Xiaoyi application or other applications that can use the language model service provided by cloud server 200. This application does not limit it here.
[0322] The following is a schematic diagram of the functional modules of a text display system 10 provided in an embodiment of this application.
[0323] like Figure 7A As shown, the text display system 10 may include an electronic device 100 and a cloud server 200. The electronic device 100 may include an application 11 and a voicekit 12. The cloud server 200 may include an Autonomous System (AS) module 21, a dialogue manager (DM) 22, a natural language understanding (NLU) module 23, and an auto speech recognition (ASR) module 24. In some embodiments, the cloud server 200 may also include a risk control module 25.
[0324] Application 11 may include an interface module 11a and a dialogue recording module 11b. Interface module 11a can display the interface and its animations (such as dynamic text display effects), and can also display user input. Interface module 11a can also be used for user interaction, such as receiving and responding to user text input and determining the text entered by the user. After determining the user's input text, interface module 11a can send the user's input text to the sound toolbox 12. Dialogue recording module 11b can detect user voice input; when user voice input is detected, dialogue recording module 11b can send an enable command to the sound toolbox 12. In application 11, interface module 11a can also receive and respond to data sent by the sound toolbox 12 (such as displaying the time taken for a single character in the target text). (The target text's token, the target text segment, and the risk information of that text segment, etc.) based on Display the target text.
[0325] The voice toolbox 12 may include a connector 12a, a acquisition module 12b, a processing module 12c, an understanding module 12d, and an execution module 12e. In some embodiments, upon receiving and responding to an enable command sent by the dialogue recording module 11b, the voice toolbox 12 can acquire the user's voice input through the acquisition module 12b, process the voice input through the processing module 12c, perform semantic analysis on the processed voice input through the understanding module 12d, determine the command corresponding to the voice input, and send the execution command to the execution module 12e. The execution module 12e can receive and respond to the execution command sent by the understanding module 12d and execute the operation indicated by the execution command. In some embodiments, when the understanding module 12d determines based on semantic analysis that the voice input needs to use the language model in the cloud server 200, it can send execution command 1 to the execution module 12e. This execution command 1 can be used to instruct the execution module 12e to determine message 1 based on the processed voice input, where message 1 is a voice message. In some embodiments, the voice toolbox 12 can receive and respond to text input sent by the interface module 11a, determine message 1 based on the text input, where message 1 is a text message. After identifying message 1, the sound toolbox 12 can establish a long-lived connection (e.g., WebSocket) with the AS module 21 via connector 12a and send message 1 to the AS module 21. Connector 12a can also receive data sent by the dialogue manager 22 through the AS module 21 (e.g., the time taken to display a single character in the target text). The received data (including the target text's token, the target text segment, and the risk information of that text segment) will be sent to the interface module 11a in application 11.
[0326] After receiving message 1, AS module 21 can establish a long-lived connection (e.g., WebSocket) with either dialog manager 22 or ASR module 24, based on the type of message 1. For example, if message 1 is a text message or an event message, AS module 21 can establish a long-lived connection with dialog manager 22 and send message 1 to dialog manager 22 through this connection. If message 1 is a voice message, AS module 21 can establish a long-lived connection with ASR module 24 and send message 1 to ASR module 24. AS module 21 can also receive text content converted based on message 1 sent by ASR module 24 and send this text content to dialog manager 22.
[0327] The dialogue manager 22 may include a dialogue management service module 22a and a streaming proxy service module 22b. After receiving message 1 (or the text content converted from a voice message), the dialogue manager 22 can send message 1 to the NLU module 23 via the streaming proxy service module 22b. The streaming proxy service module 22b can also receive data sent by the NLU module 23 (e.g., the time taken to display a single character in the target text). The target text (including its token, text segment, and risk information) is sent to the voice toolbox 12 via the AS module 21. In some embodiments, the dialogue management service module 22a can receive the text segment sent by the NLU module 23 and send it to the risk control module 25. The dialogue management service module 22a can also receive the risk information sent by the risk control module 25 and send the risk information of the text segment to the streaming proxy service module 22b.
[0328] After receiving a voice message 1, the ASR module 24 can perform speech recognition on the voice message, determine the corresponding text content, and send the text content of the voice message to the AS module 21.
[0329] NLU module 23 may include one or more service modules, such as large model service module 23a, and optionally, may also include modules such as intent service module. Large model service module 23a may store one or more language models, such as LLM. Large model service module 23a can receive message 1 (or the text content converted from a speech message) sent by streaming proxy service module 22b. After receiving message 1 (or the content of message 1), large model service module 23a can use the received message 1 as input to the LLM and generate the target text corresponding to message 1 through the LLM. During the process of large model service module 23a generating the target text, NLU module 23 can also detect the time consumed by generating a single token of the target text. And based on the above formula (9), the time taken to display a single character in the target text is determined. The NLU module 23 can also process data (such as the time taken to display a single character in the target text). The target text's token, the target text segment, etc., are sent to the streaming proxy service module 22b. In some embodiments, the NLU module 23 may also store the word count range of the text segment. ], and based on the word count range [ The NLU module 23 determines the text segment using the generated token. After determining the text segment, the NLU module 23 can send the text segment to the dialog manager 22.
[0330] The risk control module 25 can receive and respond to the text segment sent by the dialogue management service module 22a, perform risk control detection on the text segment, obtain the risk information of the text segment, and send the risk information of the text segment to the dialogue management service module 22a.
[0331] Understandable Figure 7A The illustrated embodiment is merely an example. In this application embodiment, the text display system 10 may include more, fewer, or more text displays. Figure 7A The different modules shown in the embodiments, or the combination of the above multiple modules into one module, or the decomposition of any of the above modules into multiple modules, are not limited in this application.
[0332] Figure 7B Two websocket links provided in embodiments of this application are illustrated.
[0333] like Figure 7B As shown, during the execution of the text display method provided in this application embodiment by the electronic device 100 and the cloud server 200, the network socket (websocket) links between the electronic device 100 and the various modules in the cloud server 200 can be either link 1 or link 2. Link 1 may include websocket 1 between connector 12a and AS module 21, websocket 2 between AS module 21 and dialogue manager 22, and websocket 3 between dialogue manager 22 and NLU module 23. Link 2 may include websocket 1 between connector 12a and AS module 21, websocket 4 between AS module 21 and speech recognition module 24, websocket 2 between AS module 21 and dialogue manager 22, and websocket 3 between dialogue manager 22 and NLU module 23.
[0334] When the message 1 sent by the electronic device 100 is a text message or an event message, the electronic device 100 can establish a link 1 with the relevant module in the cloud server 200 and communicate with the NLU module 23 through the link 1.
[0335] When message 1 sent by electronic device 100 is a voice message, electronic device 100 can establish websocket 1 with AS module 21 through connector 12a. When AS module 21 recognizes that message 1 is a voice message, it can establish websocket 4 with voice recognition module 24. Voice recognition module 24 can convert the voice message into a text message and send the text message to AS module 21. AS module 21 can also establish websocket 2 with dialogue manager 22. Dialogue manager 22 can establish websocket 3 with NLU module 23 and send the text message converted by voice recognition module 24 to NLU module 23 through websocket 2 and websocket 3. Afterwards, NLU module 23 can send the target text and other data of message 1 to electronic device 100 through link 1.
[0336] Since the long-lived connection between the electronic device 100 and the cloud server 200 can include multiple WebSockets, in steps S311 and S516 above, the WebSockets disconnected first can be different when the disconnection conditions are different. For example, Table 9 shows a correspondence between disconnection conditions and the order in which WebSockets are disconnected, provided in an embodiment of this application.
[0337] Table 9
[0338]
[0339] As shown in Table 9, the WebSocket that is disconnected first can vary depending on the disconnection condition. For example, when the disconnection condition is that electronic device 100 receives and responds to the user's operation of exiting application 11 (or the user's operation of releasing the engine, etc.), WebSocket 1 is disconnected first; when the disconnection condition is a network error, WebSocket 1 is disconnected first; when the disconnection condition is that the speech recognition module times out (e.g., 3 seconds), WebSocket 4 is disconnected first; when the disconnection condition is that the AS module times out (e.g., 60 seconds), WebSocket 1 is disconnected first; when the disconnection condition is that the LLM finishes outputting the target text, WebSocket 3 is disconnected first, and so on.
[0340] It is understood that the embodiments shown in Table 9 above are merely illustrative examples illustrating that the websockets that are disconnected first differ under different disconnection conditions. In the embodiments of this application, there may be more, fewer, or different disconnection conditions than those in the above embodiments, and this application does not limit them here.
[0341] Since the overhead of the speech recognition module 24 is greater than that of the dialogue manager 22, and the overhead of maintaining WebSocket 3 is greater than that of maintaining WebSocket 2, the connections (e.g., WebSockets) between different nodes in Link 1 and Link 2 can have different multiplexing time thresholds. Within this time threshold after the current target text transmission is completed, the above links can be reused. The cloud server 200 can store the link structure of different links, the correspondence between the link components and the multiplexing time thresholds.
[0342] For example, Table 10 shows the correspondence between message type, link structure, and multiplexing time threshold of link structure portion provided in the embodiments of this application.
[0343] Table 10
[0344]
[0345] As shown in Table 10, the cloud server 200 can store the correspondence between message type, link structure, and reuse time thresholds for the link structure. For example, when the message type is a text message or an event message, the links corresponding to the long connection can include websocket1, websocket2, and websocket3, and the reuse time threshold for websocket2 can be 60 seconds. That is, if websocket2 is not reused for more than 60 seconds, websocket2 will disconnect. When the message type is a voice message, the links corresponding to the long connection can include websocket1, websocket4, websocket2, and websocket3, and the reuse time threshold for both websocket2 and websocket4 can be 60 seconds. That is, if websocket2 is not reused for more than 60 seconds, websocket2 will disconnect, and if websocket4 is not reused for more than 3 seconds, websocket4 will disconnect.
[0346] It is understood that the embodiments shown in Table 10 above are just examples. In the embodiments of this application, the link multiplexing time thresholds corresponding to different links may also be different from the time shown in Table 10 above. This application does not limit this.
[0347] In this embodiment, if the electronic device 100 generates message 2 based on user input after the target text of message 1 has been sent, the electronic device 100 can send message 2 to the cloud server 200 via a long-lived connection. The types of message 1 and message 2 do not affect the reuse of the long-lived connection, but may affect changes in some websockets in the link. For example, Table 11 shows a correspondence between link reuse and message type provided in this embodiment.
[0348] Table 11
[0349]
[0350] As shown in Table 11, the types of message 1 and message 2 correspond to the following changes in the transmission links: When message 1 is a text message or an event message, the links for transmitting message 1 and its target text include websocket1, websocket2, and websocket3. In this case, if message 2 is a text message or an event message, the links for transmitting message 2 and its target text are the same as those for transmitting message 1 and its target text. When message 1 is a text message or an event message, if message 2 is a voice message, the links for transmitting message 2 and its target text are the same as those for transmitting message 1 and its target text. In contrast, a new connection to WebSocket4 is required. If message 1 is a voice message, the transmission links for message 1 and its target text include WebSocket1, WebSocket4, WebSocket2, and WebSocket3. If message 2 is a voice message, the transmission links for message 2 and its target text are the same as those for message 1. If message 2 is a text message or an event message, and message 1 is a voice message, then compared to the transmission links for message 1 and its target text, WebSocket4 needs to be disconnected.
[0351] It is understood that the embodiments shown in Table 11 above are merely illustrative examples and do not affect the reuse of long connections. Moreover, the embodiments shown in Table 11 above assume that all established websockets are in an unbroken state (i.e., within the time period corresponding to the reuse time threshold). In this application embodiment, the situation where different websockets correspond to different reuse time thresholds can also be considered in conjunction with the embodiments shown in Table 10. This application does not limit this.
[0352] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This embodiment of the invention uses the layered architecture Android system as an example to exemplify the software structure of electronic device 100.
[0353] Figure 8 This is a software structure block diagram of the electronic device 100 according to an embodiment of the present invention.
[0354] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.
[0355] The application layer can include a series of application packages and the above. Figure 7A The Voicekit 12 shown.
[0356] like Figure 8 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and SMS. The application package may also include the aforementioned... Figure 7A Application 11 is shown.
[0357] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0358] like Figure 8 As shown, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc.
[0359] The window manager is used to manage windowed applications. It can retrieve screen size, determine the presence of a status bar, lock the screen, and capture screenshots, among other things.
[0360] Content providers store and retrieve data, making that data accessible to applications. This data may include videos, images, audio, made and received phone calls, browsing history and bookmarks, phone books, etc.
[0361] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon could include views for displaying text and views for displaying images.
[0362] The phone manager is used to provide communication functions for electronic device 100. For example, it manages call status (including connection and disconnection).
[0363] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
[0364] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of completed downloads or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.
[0365] The Android Runtime consists of core libraries and a virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
[0366] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.
[0367] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0368] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.
[0369] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
[0370] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.
[0371] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0372] A 2D graphics engine is a graphics engine for 2D drawing.
[0373] The kernel layer is the layer between hardware and software. The kernel layer contains at least the display driver, camera driver, audio driver, and sensor driver.
[0374] Figure 9 A flowchart illustrating a text display method provided in an embodiment of this application is shown.
[0375] like Figure 9 As shown, the specific process of a text display method provided in this application embodiment may include the following steps:
[0376] S901, Electronic device 100 sends the first message to cloud server 200.
[0377] The first message can be message 1 in the above embodiment.
[0378] S902, cloud server 200 generates the first target text corresponding to the first message through a language model.
[0379] The first target text can be the target text corresponding to message 1 in the above embodiment.
[0380] S903, after generating the first text segment in the first target text, the cloud server 200 sends the first display speed and the first text segment to the electronic device. The first display speed is used to indicate the number of characters in the first target text displayed per unit time.
[0381] The first text segment can be text segment 1 in the above embodiment. The first text segment can also be the one described above. Figure 3 One or more tokens are sent to the electronic device 100 for the first time in step S307 shown.
[0382] The first display speed can refer to the number of characters displayed per unit time. In this embodiment, the number of characters can also be called the number of characters (in this embodiment, characters may include punctuation). The first display speed can also be the display time of a single character in the above embodiments. ,based on It can determine the number of characters displayed per unit of time.
[0383] The method for determining the value can be referred to the relevant description in the above embodiments, and will not be repeated here.
[0384] S904, Electronic device 100 displays a first text segment at a first display speed.
[0385] For details of step S904, please refer to the above. Figure 3Step S308 shown or Figure 5 Step S514 is shown.
[0386] S905, before the electronic device 100 finishes displaying the first text segment at the first display speed, the cloud server 200 generates the second text segment in the first target text, and the second text segment is located after the first text segment in the first target text.
[0387] The first text segment and the second text segment are two adjacent text segments in the first target text. In this embodiment, the second text segment may be text segment 2 as described in the above embodiment.
[0388] S906, after generating the second text segment of the first target text, the cloud server 200 sends the second text segment to the electronic device 100.
[0389] S907, the electronic device 100 receives the second text segment before or after displaying the first text segment at the first display speed.
[0390] S908, after displaying the first text segment at a first display speed, the electronic device 100 displays the second text segment at a first display speed.
[0391] For details of step S908, please refer to the above. Figure 5 Step S514 shown or Figure 3 The relevant content in step S310 shown.
[0392] The text display method provided in this application not only displays the generated text during the generation of the target text, reducing the user's waiting time, but also avoids stuttering during the display process, ensuring smooth text display.
[0393] In one possible implementation, the first text segment includes at least one language symbol token, and the second text segment includes one token; the method further includes: during the generation of the first target text, the cloud server 200 obtains a first generation speed, which is used to indicate the number of tokens generated per unit time; the cloud server 200 determines a first display speed based on the first generation speed and a first constraint relationship; the first constraint relationship is that the first display speed is less than or equal to the product of the first generation speed and a first scale, where the first scale is the ratio of the number of characters corresponding to the language model to the number of tokens.
[0394] In this way, the number of tokens sent in the first transmission is greater than or equal to the number of tokens sent in each subsequent transmission. The longer time required to display all the text sent in the first transmission ensures smooth text display.
[0395] In one possible implementation, the method further includes: during the generation of the first target text, the cloud server 200 obtains a first generation speed, which indicates the number of tokens generated per unit time; the cloud server 200 determines a first display speed based on the first generation speed and a first constraint relationship; the first constraint relationship is that the first display speed is equal to the product of the first generation speed and a first constant, the first constant being less than a first ratio, the first ratio being the ratio of the number of characters corresponding to the language model to the number of tokens; the cloud server 200 sets a word count range, which indicates the word count range of a single text segment of the first target text; during the generation of the first target text, the cloud server 200 determines a first text segment based on the word count range; before sending the first text segment, the cloud server 200 determines that the first text segment is risk-free; during the generation of the first target text, the cloud server 200 determines a second text segment based on the word count range, the word count of the second text segment belonging to the word count range; before sending the second text segment, the cloud server 200 determines that the second text segment is risk-free.
[0396] In this way, by setting the word count range for a text segment and the text display speed, smooth display between two adjacent text segments can be ensured.
[0397] In one possible implementation, the method further includes: during the generation of the first target text, the cloud server 200 determines a third text segment based on a word count range, wherein the third text segment is located after the second text segment in the first target text; the cloud server 200 determines that the third text segment is risky; the cloud server 200 sends the third text segment and first risk information to the electronic device, wherein the first risk information is used to indicate that the first target text is risky; and after receiving the first risk information, the electronic device 100 removes all content already displayed in the first target text.
[0398] In this way, if the target text is detected to be risky, the electronic device can retract the content that has been displayed.
[0399] In one possible implementation, the method further includes: when sending the first text segment, the cloud server 200 sends a second risk information to the electronic device, the second risk information being used to indicate that the first target text is currently safe; when sending the second text segment, the cloud server 200 sends the second risk information to the electronic device.
[0400] In this way, even if the target text is risk-free, the cloud server can still send risk information to the electronic device. This risk information is used to notify the electronic device that the current text segment is risk-free.
[0401] In one possible implementation, the method further includes: the electronic device 100 establishing a long connection with the cloud server before sending the first message to the cloud server.
[0402] In this way, data such as the first message and the first target text can be transmitted via long-lived links.
[0403] In one possible implementation, the method further includes: before establishing a long connection with the cloud server, the electronic device 100 receives the user's first input; the electronic device 100 determines a first message based on the first input.
[0404] The first input type can include: voice input, text input, and event input. The first message type can include: voice message, text message, or event message.
[0405] Determining the first message based on the first input specifically includes: determining the type of the first message based on the type of the first input; and determining the content of the first message based on the content of the first input. The content of the first message can be the same as the content of the first input.
[0406] In one possible implementation, the method further includes: when the electronic device 100 detects that a first disconnection condition is met, it disconnects the long link with the cloud server; the first disconnection condition includes any one or more of the following: network error, receiving a first operation from the user, the first operation being used to trigger the electronic device to stop using the language model service.
[0407] In this way, electronic devices can disconnect the long-lived link with the cloud server if the first disconnection condition is met.
[0408] In one possible implementation, the method further includes: when the cloud server 200 detects that a second disconnection condition is met, it disconnects the long link with the electronic device; the second disconnection condition includes any one or more of the following: network error, completion of sending the first target text, completion of sending the first target text and no message received from the electronic device within a first time period after completion of sending.
[0409] In this way, the cloud server can disconnect the long-lived link with the electronic device if it detects that the second disconnection condition has been met.
[0410] In one possible implementation, after displaying the first target text at a first display speed, the electronic device 100 receives a second input from the user; the electronic device 100 determines a second message based on the second input; the electronic device 100 sends the second message to the cloud server; the cloud server 200 generates the second target text corresponding to the second message through a language model; after generating a fourth text segment in the second target text, the cloud server 200 sends a second display speed and the fourth text segment to the electronic device; the second display speed is used to indicate the number of characters in the second target text displayed per unit time; the electronic device 100 displays the fourth text segment at the second display speed; before the electronic device finishes displaying the fourth text segment at the second display speed, the cloud server 200 generates a fifth text segment in the second target text, the fifth text segment being after the fourth text segment in the second target text; after generating the fifth text segment of the second target text, the cloud server 200 sends the fifth text segment to the electronic device; the electronic device 100 receives the fifth text segment before or after displaying the fourth text segment at the second display speed; after displaying the fourth text segment at the second display speed, the electronic device 100 displays the fifth text segment at the second display speed.
[0411] In this way, the second message and the second target text can also be transmitted through this long link.
[0412] In one possible implementation, the electronic device 100 sends a second message to the cloud server, specifically including: when the time interval between the moment when the first target text is displayed and the moment when the second input is received is less than a second duration, the electronic device 100 sends a second message to the cloud server.
[0413] Long-lived connections can be reused with a time threshold. Within the preset time threshold, a second message can reuse the long-lived connection used to transmit the first message. This way, if a long-lived connection is not used for an extended period, it can be automatically disconnected, reducing energy consumption.
[0414] The various embodiments of this application can be combined arbitrarily to achieve different technical effects.
[0415] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0416] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.
[0417] In summary, the above description is merely an embodiment of the technical solution of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made according to the disclosure of the present invention should be included within the scope of protection of the present invention.
Claims
1. A text display system, characterized in that, The system includes electronic devices and a cloud server; wherein... The electronic device is used to send a first message to the cloud server; The cloud server is used to generate the first target text corresponding to the first message through a language model; The cloud server is also used to obtain a first generation speed during the process of generating the first target text, and the first generation speed is used to indicate the number of tokens generated per unit time. The cloud server is further configured to determine a first display speed based on the first generation speed and the first constraint relationship; wherein, the first constraint relationship is that the first display speed is less than or equal to the product of the first generation speed and the first scale, or, the first constraint relationship is that the first display speed is equal to the product of the first generation speed and the first constant, and the first scale is the ratio of the number of characters to the number of tokens corresponding to the language model; the first constant is less than the first scale. The cloud server is further configured to send the first display speed and the first text segment to the electronic device after generating the first text segment in the first target text; the first display speed is used to indicate the number of characters in the first target text displayed per unit time. The electronic device is also configured to display the first text segment at the first display speed; The cloud server is further configured to generate a second text segment in the first target text before the electronic device finishes displaying the first text segment at the first display speed, wherein the second text segment is located after the first text segment in the first target text; The cloud server is also used to send the second text segment to the electronic device after generating the second text segment of the first target text; The electronic device is further configured to receive the second text segment before or after the first text segment has been displayed at the first display speed; The electronic device is further configured to display the second text segment at the first display speed after displaying the first text segment at the first display speed.
2. The system according to claim 1, characterized in that, The first text segment includes at least one language symbol token, and the second text segment includes one token.
3. The system according to claim 1, characterized in that, The cloud server is also used to set a word count range, which is used to indicate the word count range of a single text segment of the first target text; The cloud server is also used to determine the first text segment based on the word count range during the process of generating the first target text; The cloud server is also used to determine that the first text segment is risk-free before sending the first text segment; The cloud server is also used to determine the second text segment based on the word count range during the process of generating the first target text, wherein the word count of the second text segment belongs to the word count range; The cloud server is also used to determine that the second text segment is risk-free before sending it.
4. The system according to claim 3, characterized in that, The cloud server is also used to determine a third text segment based on the word count range during the generation of the first target text, wherein the third text segment is located after the second text segment in the first target text; The cloud server is also used to determine that the third text segment is risky; The cloud server is also used to send the third text segment and the first risk information to the electronic device, wherein the first risk information is used to indicate that the first target text is risky; The electronic device is also configured to, upon receiving the first risk information, withdraw all content already displayed in the first target text.
5. The system according to claim 3 or 4, characterized in that, The cloud server is also used to send second risk information to the electronic device when sending the first text segment, the second risk information being used to indicate that the first target text is currently safe. The cloud server is also used to send the second risk information to the electronic device when sending the second text segment.
6. The system according to any one of claims 1-4, characterized in that, The electronic device is also used to establish a long connection with the cloud server before sending the first message to the cloud server.
7. The system according to claim 6, characterized in that, The electronic device is also used to receive the user's first input before establishing the long link with the cloud server; The electronic device is further configured to determine the first message based on the first input.
8. The system according to claim 6, characterized in that, The electronic device is further configured to disconnect the long link with the cloud server when a first disconnection condition is detected; the first disconnection condition includes any one or more of the following: network error, receiving a first operation from the user, the first operation being used to trigger the electronic device to stop using the language model service.
9. The system according to claim 6, characterized in that, The cloud server is further configured to disconnect the long link with the electronic device when a second disconnection condition is detected; the second disconnection condition includes any one or more of the following: network error, completion of sending the first target text, completion of sending the first target text and no message sent by the electronic device within a first time period after completion of sending.
10. The system according to any one of claims 1-4, characterized in that, The electronic device is further configured to receive a second input from the user after displaying the first target text at the first display speed; The electronic device is further configured to determine a second message based on the second input; The electronic device is also used to send the second message to the cloud server; The cloud server is also used to generate the second target text corresponding to the second message through a language model; The cloud server is further configured to send the second display speed and the fourth text segment to the electronic device after generating the fourth text segment in the second target text; the second display speed is used to indicate the number of characters in the second target text displayed per unit time. The electronic device is also configured to display the fourth text segment at the second display speed; The cloud server is further configured to generate a fifth text segment in the second target text before the electronic device finishes displaying the fourth text segment at the second display speed, wherein the fifth text segment is located after the fourth text segment in the second target text; The cloud server is also configured to send the fifth text segment to the electronic device after generating the fifth text segment of the second target text; The electronic device is further configured to receive the fifth text segment before or after the fourth text segment has been displayed at the second display speed; The electronic device is further configured to display the fifth text segment at the second display speed after displaying the fourth text segment at the second display speed.
11. The system according to claim 10, characterized in that, The electronic device is also used to send the second message to the cloud server, specifically including: The electronic device is further configured to send the second message to the cloud server when the time interval between the moment the first target text is displayed and the moment the second input is received is less than a second duration.
12. A method for displaying text, characterized in that, Applied to cloud servers, the method includes: Receive the first message sent by the electronic device; The first target text corresponding to the first message is generated using a language model; During the process of generating the first target text, a first generation speed is obtained, which is used to indicate the number of tokens generated per unit time. The first display speed is determined based on the first generation speed and the first constraint relationship; wherein, the first constraint relationship is that the first display speed is less than or equal to the product of the first generation speed and the first scale, or, the first constraint relationship is that the first display speed is equal to the product of the first generation speed and the first constant, and the first scale is the ratio of the number of characters to the number of tokens corresponding to the language model; the first constant is less than the first scale. After generating the first text segment in the first target text, the first display speed and the first text segment are sent to the electronic device; the first display speed is used to indicate the number of characters displayed per unit time. Generate a second text segment in the first target text, wherein the second text segment follows the first text segment in the first target text; Before the electronic device finishes displaying the first text segment at the first display speed, the second text segment is sent to the electronic device.
13. The method according to claim 12, characterized in that, The first text segment includes one or more language symbol tokens, and the second text segment includes one token.
14. The method according to claim 12, characterized in that, The method further includes: Set a word count range, which is used to indicate the range of words in a single text segment of the first target text; During the generation of the first target text, the first text segment is determined based on the word count range; Before sending the first text segment, it is determined that the first text segment is risk-free; During the generation of the first target text, the second text segment is determined based on the word count range, wherein the word count of the second text segment belongs to the word count range; Before sending the second text segment, it is determined that the second text segment is risk-free.
15. The method according to claim 14, characterized in that, The method further includes: During the generation of the first target text, a third text segment is determined based on the word count range, and the third text segment is located after the second text segment in the first target text. The third text segment has been determined to be risky; The third text segment and first risk information are sent to the electronic device, wherein the first risk information is used to indicate that the first target text is risky.
16. The method according to claim 14 or 15, characterized in that, The method further includes: When sending the first text segment, a second risk information is sent to the electronic device, the second risk information being used to indicate that the first target text is currently not at risk; When sending the second text segment, the second risk information is sent to the electronic device.
17. The method according to any one of claims 12-15, characterized in that, The method further includes: Before receiving the first message sent by the electronic device, a long-lived connection is established with the electronic device.
18. The method according to claim 17, characterized in that, The method further includes: When a second disconnection condition is detected, the long link with the electronic device is disconnected; the second disconnection condition includes any one or more of the following: network error, completion of sending the first target text, completion of sending the first target text and no message sent by the electronic device within a first time period after completion of sending.
19. The method according to any one of claims 12-15, characterized in that, The method further includes: After sending the first target text, the second message sent by the electronic device is received; The second target text corresponding to the second message is generated using a language model; After generating the fourth text segment in the second target text, the second display speed and the fourth text segment are sent to the electronic device; Before the electronic device finishes displaying the fourth text segment at the second display speed, a fifth text segment is generated in the second target text, and the fifth text segment is located after the fourth text segment in the second target text. After generating the fifth text segment of the second target text, the fifth text segment is sent to the electronic device.
20. A method for displaying text, characterized in that, Applied to electronic devices, the method includes: Send the first message to the cloud server; The system receives a first display speed and a first text segment from a first target text sent by the cloud server. The first display speed indicates the number of characters displayed in the first target text per unit time. The first target text is text generated by the cloud server based on the first message using a language model. The first display speed is determined based on a first generation speed and a first constraint relationship, where the first constraint relationship is that the first display speed is less than or equal to the product of the first generation speed and a first scale, or the first constraint relationship is that the first display speed is equal to the product of the first generation speed and a first constant. The first scale is the ratio of the number of characters corresponding to the language model to the number of tokens; the first constant is less than the first scale. The first text segment is displayed at the first display speed; Before the electronic device finishes displaying the first text segment at the first display speed, a second text segment in the first target text is received, wherein the second text segment is located after the first text segment in the first target text; After displaying the first text segment at the first display speed, the second text segment is displayed at the first display speed.
21. The method according to claim 20, characterized in that, The first text segment includes one or more language symbol tokens, and the second text segment includes one token.
22. The method according to claim 20, characterized in that, The method further includes: Receive a third text segment and a first risk information sent by the cloud server, wherein the first risk information is used to indicate that the first target text is risky; Upon receiving the first risk information, all content already displayed in the first target text is withdrawn.
23. The method according to claim 22, characterized in that, The process of receiving the first display speed and the first text segment from the first target text sent by the cloud server specifically includes: The system receives a first display speed, a first text segment in a first target text, and second risk information sent by the cloud server. The second risk information is used to indicate that the first target text is currently safe. Receiving the second text segment from the first target text specifically includes: Receive the second text segment and the second risk information from the first target text.
24. The method according to any one of claims 20-23, characterized in that, The method further includes: Before sending the first message to the cloud server, a long-lived connection is established with the cloud server.
25. The method according to claim 24, characterized in that, The method further includes: Before establishing the long connection with the cloud server, receive the user's first input; In response to the first input, the first message is determined based on the first input.
26. The method according to claim 24, characterized in that, The method further includes: When a first disconnection condition is detected, the long link with the cloud server is disconnected; the first disconnection condition includes any one or more of the following: network error, receiving a first operation from the user, the first operation being used to trigger the electronic device to stop using the language model service.
27. The method according to any one of claims 20-23, characterized in that, The method further includes: After displaying the first target text at the first display speed, the user's second input is received. In response to the second input, a second message is determined based on the second input; Send the second message to the cloud server; The system receives a second display speed and a fourth text segment from the second target text sent by the cloud server; the second display speed is used to indicate the number of characters in the second target text displayed per unit time; the second target text is text generated by the cloud server based on the second message through a language model. The fourth text segment is displayed at the second display speed; Before the electronic device finishes displaying the fourth text segment at the second display speed, a fifth text segment in the second target text is received, wherein the fifth text segment is located after the fourth text segment in the second target text; After displaying the fourth text segment at the second display speed, the fifth text segment is displayed at the second display speed.
28. The method according to claim 27, characterized in that, Sending the second message to the cloud server specifically includes: When the time interval between the moment the first target text is displayed and the moment the second input is received is less than the second duration, the second message is sent to the cloud server.
29. A server, characterized in that, include: One or more processors and one or more memories; the one or more memories are coupled to the one or more processors, the one or more memories being used to store computer program code, the computer program code including computer instructions, which, when the one or more processors execute the computer instructions, cause the cloud server to perform the method of any one of claims 12-19.
30. An electronic device, characterized in that, include: One or more processors and one or more memories; the one or more memories are coupled to the one or more processors, the one or more memories being used to store computer program code, the computer program code including computer instructions, which, when executed by the one or more processors, cause the electronic device to perform the method of any one of claims 20-28.
31. A computer-readable storage medium comprising computer instructions, characterized in that, When the computer instructions are run on the cloud server, the cloud server performs the method according to any one of claims 12-19.
32. A computer-readable storage medium comprising computer instructions, characterized in that, When the computer instructions are executed on the electronic device, the electronic device causes the electronic device to perform the method of any one of claims 20-28.
Citation Information
Patent Citations
Reception device, method for controlling same, distribution device, distribution method, program, and distribution system
CN103988520A
Text generation method and device
CN109977390A