Behavior intention self-distinguishing method, system and equipment applied to code generation large model and storage medium

By introducing task queue and time interval mechanisms into the code generation large model, the code generation large model is only called when the user operates stably, the invalid reasoning problem caused by frequent cursor changes is solved, and efficient utilization of computing resources and improved user experience is achieved.

CN119987740APending Publication Date: 2025-05-13CHINA PETROLEUM & CHEMICAL CORP +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510158780.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-13
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

When using code generation model for code reasoning, frequent cursor changes lead to invalid reasoning and waste of computing resources.

Method used

By obtaining the task information of the cursor movement event, encapsulate it into a task unit, and adding it to the task queue, scanning the time interval for the task unit to join the queue, and calling the code generation model for code inference only when the time interval reaches the preset threshold.

Benefits of technology

Reduce the number of invalid inferences, avoid the waste of computing resources, and improve the response efficiency and user experience of code generation large models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119987740A_ABST
    Figure CN119987740A_ABST
Patent Text Reader

Abstract

The invention provides a behavior intention self-distinguishing method, system and device applied to a code generation large model and a storage medium, and belongs to the technical field of generative artificial intelligence. The behavior intention self-distinguishing method comprises the steps that task information of a current cursor moving event is obtained, and the task information is packaged into a task unit; adding the packaged task units to a task queue, scanning the task units in the task queue, and obtaining a time interval when the task units are added to the task queue; and calling a code generation type large model to execute code reasoning based on the time interval of adding the task unit into the task queue. Effective programming behaviors of the user can be accurately recognized, frequent calling of a large model for code reasoning is avoided, computing resource consumption is remarkably reduced, and the utilization rate of hardware equipment is increased.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of generative artificial intelligence technology, and in particular to a behavior intention self-identification method, system, device and storage medium applied to a large code generation model. Background Art

[0002] The code-generating big model is an advanced artificial intelligence technology based on deep learning and natural language processing (NLP) technology. It can convert unstructured input (such as text descriptions, etc.) into structured program code, or reason based on the code context. These models are usually trained based on large-scale corpora to learn the syntax, structure, and semantic information of the code, so that they can automatically generate corresponding code based on the input requirements or instructions, greatly improving development efficiency and reducing labor costs. For example, CN118409741A discloses a code generation method based on a big language model, which uses a big language model for code generation.

[0003] In the process of developing a code generation IDE plug-in based on a code generation big model, a mechanism is needed to monitor the user's programming behavior and automatically identify the user's behavior intention to finally determine whether to call the big model service to continue code continuation reasoning. Specifically, the code generation plug-in needs to monitor and capture the movement of the developer's cursor, that is, monitor the user's behavior, and determine whether the user needs the big model to infer the code for completion, that is, determine the user's behavior intention. If necessary, call the code generation service of the big model to perform code reasoning and generation. If not, continue to monitor.

[0004] In the current monitoring mechanism, every time the cursor changes, it is judged that the user needs to call the code generation service. Therefore, every time the cursor changes, a code reasoning generation call will be generated. However, the change of the cursor does not always mean that the user has the need to call the code generation service. If code reasoning is performed every time the cursor changes, then when the user continues to write code, it is easy for the previous reasoning to not end, the code generation suggestion has not appeared, and the next reasoning has already begun, resulting in the invalidation of the previous reasoning, and ultimately generating a large number of invalid reasonings, wasting computing resources.

[0005] Therefore, how to alleviate invalid reasoning when using large code generation models for code reasoning and reduce the number of invalid reasoning is a technical problem that needs to be solved urgently. Summary of the invention

[0006] In response to the above problems, the present invention provides a behavioral intention self-identification method, system, device and storage medium applied to a large code generation model, aiming to solve the problems of over-sensitive response and excessive energy consumption that are common in existing artificial intelligence-assisted programming plug-ins. It can judge the user's true behavioral intention and accurately identify the user's code generation requirements to make effective reasoning responses, reduce invalid reasoning generated in the process of using the large code generation model, and avoid waste of computing resources.

[0007] The present invention provides a behavior intention self-identification method applied to a large code generation model, comprising: Obtaining task information of the current cursor movement event, and encapsulating the task information into a task unit; Adding the encapsulated task unit to a task queue, scanning the task units in the task queue, and obtaining a time interval for the task unit to be added to the task queue; Based on the time interval of the task unit joining the task queue, the code generation model is called to perform code reasoning.

[0008] As a further improvement of the present invention, the obtaining of task information of the current cursor movement event and encapsulating the task information into task units includes obtaining the task information including the current cursor position, associated code context and task creation timestamp.

[0009] As a further improvement of the present invention, calling the code generation large model to execute code reasoning based on the time interval of the task unit joining the task queue includes comparing the time interval of the task unit joining the task queue with a preset interval threshold, and identifying the user behavior intention based on the comparison result.

[0010] As a further improvement of the present invention, when the time interval for the task unit to join the task queue is less than the interval threshold, it indicates that the user is still in the code editing stage and the code reasoning logic is not executed; when the time interval for the task unit to join the task queue reaches the interval threshold, it indicates that the user has entered a stable thinking or observation stage and the code reasoning logic is executed.

[0011] As a further improvement of the present invention, when the time interval between the task units being added to the task queue is less than an interval threshold, the unprocessed old task units in the task queue are deleted.

[0012] As a further improvement of the present invention, when the time interval for the task unit to join the task queue reaches an interval threshold, a pre-configured code generation model interface is called, and the associated code context in the task information of the task unit is taken as input to request the code generation model to generate code suggestions.

[0013] As a further improvement of the present invention, the interval threshold ranges from 2 to 4 seconds.

[0014] As a further improvement of the present invention, the task queue is a priority queue or a linked list with a timestamp.

[0015] The present invention provides a behavior intention self-identification system applied to a large code generation model, including an event monitoring module, a task creation module, and a task processing module, wherein: The event monitoring module is used to monitor the user's cursor movement events; The task creation module is used to obtain the task information of the current cursor movement event and encapsulate the task information into a task unit; add the encapsulated task unit to the task queue, scan the task units in the task queue, and obtain the time interval for the task unit to join the task queue; The task processing module is used to call the code generation model to perform code reasoning based on the time interval of the task unit joining the task queue.

[0016] As a further improvement of the present invention, the task processing module includes a code reasoning sub-module, which is used to call the code generation big model interface when the interval time of the task unit joining the task queue reaches a preset interval threshold, and takes the associated code context in the current task unit as input to request the code generation big model to generate code suggestions.

[0017] The present invention provides a device, including a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the above-mentioned behavior intention self-identification method applied to a large code generation model.

[0018] The present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the above-mentioned behavior intention self-identification method applied to a large code generation model are implemented.

[0019] The present invention provides a behavioral intention self-identification method, system, device and storage medium applied to a code generation large model, which obtains task information of a current cursor movement event and encapsulates the task information into a task unit; adds the encapsulated task unit to a task queue, scans the task units in the task queue, and obtains the time interval for the task unit to join the task queue; based on the time interval for the task unit to join the task queue, calls the code generation large model to perform code reasoning, thereby avoiding frequent calls to the large model when the user quickly edits the code, reducing the number of invalid reasoning times, and effectively suppressing unnecessary computing resource consumption. Reasoning is performed only when the user operation tends to be stable, which not only meets the real-time requirements but also achieves significant energy consumption reduction. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 It is a flowchart of a method for self-identifying behavioral intentions applied to a large code generation model according to an embodiment of the present invention.

[0021] Figure 2 It is a flowchart of a behavior intention self-identification method applied to a large code generation model according to an embodiment of the present invention. DETAILED DESCRIPTION

[0022] The following is combined with specific embodiments and appendix Figure 1-2 The invention is described in detail so that those skilled in the art can more fully understand the purpose, features and effects of the invention.

[0023] Unless otherwise specified, all technical and scientific terms used in the present invention have the same meanings as commonly understood by those skilled in the art to which the present invention belongs. When the definition of a term in the present invention conflicts with the meaning commonly understood by those skilled in the art to which the present invention belongs, the definition described in the present invention shall prevail.

[0024] The present invention improves the existing user behavior monitoring mechanism by providing a behavior intention self-identification method, system, device and storage medium applied to a code generation large model, improves the monitoring accuracy, identifies the user's true behavior intention, and guides the large model to perform effective reasoning for code generation, thereby reducing the number of invalid reasonings and unnecessary calculations of the code generation large model, thereby achieving energy consumption reduction.

[0025] Embodiment 1 As a specific embodiment of the present invention, this embodiment provides a behavior intention self-identification method applied to a code generation large model, referring to Figure 1 , Figure 2 , the specific steps are as follows: S100, obtaining task information of a current cursor movement event, and encapsulating the task information into a task unit; S200, adding the encapsulated task unit to a task queue, scanning the task units in the task queue, and obtaining a time interval for the task unit to be added to the task queue; S300: Based on the time interval of the task unit joining the task queue, call the code generation model to perform code reasoning.

[0026] The present invention reduces the number of calls to the code generation large model by accurately screening the user's effective programming behavior and introducing a task delay processing mechanism, thereby maintaining the coordination and coherence of the code before and after, thereby improving resource utilization and optimizing the user experience.

[0027] Specifically, in this embodiment, the plug-in development provided by IDE (taking IntelliJ IDEA as an example) is used to monitor the cursor movement event. When the user moves the cursor in the IDE editor, the event capture mechanism is triggered, and a lightweight thread is created to handle the event. After receiving the cursor movement event, the lightweight thread is responsible for collecting necessary task information.

[0028] In S100, the task information includes the current cursor position, the associated code context, and the task creation timestamp. Each time the cursor moves, a cursor movement event is triggered, and the task information of the cursor movement event needs to be re-acquired, thereby realizing continuous monitoring of the cursor movement event.

[0029] By monitoring the core programming behavior of user cursor movement in the IDE, we can accurately capture the code area that the user is focusing on, ensuring that the code reasoning service is highly consistent with the user's current thinking activities.

[0030] Afterwards, the acquired task information is packaged to obtain a task unit. Packaging the task information into independent task units can improve the efficiency of task management, especially in a multi-thread or multi-process environment, this packaging method can effectively improve resource utilization and execution efficiency.

[0031] In S200, a task queue is first created, and the encapsulated task units are added to the created task queue one by one to form a list of tasks to be processed. When a task unit is added to the task queue for the first time, the task processing thread is awakened at the same time.

[0032] The task queue is a priority queue or a linked list with a timestamp, which is used to effectively manage tasks according to the order of task creation time and waiting time. The order of the task units in the task queue is arranged according to the time of joining. After the task processing thread is awakened, it enters the periodic task scanning state and scans the task units added to the task queue. Each task unit added to the task queue is scanned, and the time interval of each task unit from joining the task queue to the present is calculated, and the time interval is compared with the preset interval threshold to determine whether the time interval reaches the interval threshold, so as to screen the effectiveness of the user's cursor movement behavior. Among them, the longest time interval of the task unit is from the time the task unit joins the task queue to the time the next task unit joins the task queue.

[0033] Therefore, when making a comparison, what is compared is the relationship between the time interval of the task unit that was most recently added to the task queue and the interval threshold, that is, the size between the time interval of the latest task unit and the interval threshold. When a new task unit is added to the task queue, the previous task unit becomes the old task unit.

[0034] The interval threshold can be set as needed, and the range of the interval threshold can be 2-4s, such as 2.5s, 3s, 3.5s, and can be optimized during use to balance the relationship between real-time performance and energy consumption. Preferably, the interval threshold is 3s, and the following description is based on the interval threshold of 3s.

[0035] Through the collaborative work of task queues and task processing threads, tasks triggered by user behaviors can be dynamically managed to ensure that code inference services can still be executed efficiently and orderly in multi-tasking scenarios, avoiding resource competition and response delays.

[0036] Specifically, when the time interval for the latest task unit to join the task queue is less than 3s, that is, the waiting time of the latest task unit is less than 3s, it means that the user is still in the code editing stage. At this time, the code generation model is not called for code reasoning, and in order to avoid excessive response or invalid operations, the existing and unprocessed old task units in the task queue are deleted to reduce unnecessary computing resource consumption.

[0037] If the longest time interval of the task unit is less than the interval threshold, it means that the user has no need to generate code for this cursor movement event, and the task unit is temporarily saved in the task queue as an unprocessed old task unit.

[0038] It should be noted that what is deleted are the unprocessed old task units, that is, the task units with the longest time interval less than 3s. The processed task units or the task units being processed are not deleted to avoid code generation interruption or loss.

[0039] When the time interval between the latest task unit joining the task queue is equal to 3s, it means that the user has entered a stable thinking or observation phase, and the code reasoning logic needs to be executed. When executing the code reasoning logic, the pre-configured code generation model interface is first called, and the associated code context in the encapsulated task information in the current task unit is input, requesting the model to generate responsive code suggestions.

[0040] After obtaining the suggested code returned by the code generation model, the plug-in displays it in the IDE interface in an intuitive and friendly form for users to choose. After checking the suggested code, the user decides to adopt or ignore the suggestions given by the big model.

[0041] After completing one code reasoning, the task processing thread enters the next cycle and continues to monitor the task units in the task queue.

[0042] In this embodiment, under normal circumstances, the user will move the cursor after the code reasoning is completed. However, there are also cases where the cursor moves during code reasoning, such as cursor movement caused by an accidental touch, in which case a new task unit will be added to the task queue. When the time interval of the latest task unit obtained is less than 3s, the old task unit in the task queue will be deleted. Since the deletion operation is for the unprocessed old task unit, it does not affect the code generation task being reasoned, that is, the code will be generated continuously without interruption.

[0043] In this embodiment, the user's behavioral intention is automatically identified based on the waiting time after the cursor moves, and the code inference instruction is sent in a delayed manner. The code inference logic is executed only when the cursor change reaches the interval threshold. If the time interval between two cursor movements is less than the interval threshold, or the interval time of the cursor change has not reached the interval threshold, the code inference logic is not executed.

[0044] The present invention obtains the task processing unit by monitoring the cursor movement events of the user's core programming behavior in the IDE, and determines whether to call the code generation large model by combining the comparison of the task unit interval time with the interval threshold. This method can effectively filter out temporary or invalid operations and avoid frequent calls to the large model for code reasoning, thereby significantly reducing computing resource consumption and improving the utilization rate of hardware equipment.

[0045] While ensuring the real-time assisted programming function, it reduces the interference caused by irrelevant or instantaneous operations, so that the code reasoning suggestions provided by the plug-in are more in line with the user's current programming thinking and work rhythm, ensuring the continuity of programming and improving the accuracy of programming assistance and user experience.

[0046] Embodiment 2 As a specific embodiment of the present invention, this embodiment provides a behavior intention self-identification system applied to a large code generation model, including an event monitoring module, a task creation module, and a task processing module; Wherein, the event monitoring module is used to monitor the user's cursor movement event; The task creation module is used to obtain the task information of the current cursor movement event and encapsulate the task information into a task unit; add the encapsulated task unit to the task queue, scan the task units in the task queue, and obtain the time interval for the task unit to join the task queue; The task processing module is used to call the code generation model to perform code reasoning based on the time interval of the task unit joining the task queue.

[0047] Specifically, the event monitoring module is used to monitor the cursor movement events of the user in the IDE, and when a cursor movement event is received, a lightweight thread is created to process the cursor movement event. The event monitoring module registers a listener for the cursor movement event through the API interface provided by the IDE, and implements the logic of the task creation module inside the listener, and triggers the task creation logic when a cursor movement event is received.

[0048] The task creation module is used to collect necessary task information corresponding to the cursor movement event in the lightweight thread, such as the current position of the cursor, the associated code context, and the task creation timestamp, encapsulate the task information into a task unit, and add the task unit to the task queue; at the same time, when the task unit is added to the task queue for the first time, the task processing thread is awakened.

[0049] The task processing module, after the task processing thread is awakened, periodically scans the task queue, and for each task unit in the queue, determines whether the time interval from the time it joins the task queue to the present reaches a preset interval threshold; if the latest task interval time (waiting time) is less than the preset interval threshold, deletes the unprocessed old task units in the task queue, and does not execute the code reasoning logic; otherwise, if the latest task interval time (waiting time) reaches the preset interval threshold, executes the code reasoning logic.

[0050] Furthermore, the task processing module includes a code reasoning submodule, which is used to call the code generation model interface when the task unit interval time reaches a preset interval threshold, take the associated code context in the current task unit as input, and request the code generation model to generate corresponding code suggestions.

[0051] Specifically, the code reasoning submodule is connected to a pre-configured large model service interface. The large model service interface provides a stable interface for the plug-in to call. The plug-in implements the calling logic in the code reasoning module, takes the code context in the task unit as an input parameter, and processes the suggested code returned by the large model.

[0052] Furthermore, the system also includes a user interface module, which is used to display the suggested code in an intuitive and friendly form in the IDE interface after obtaining the suggested code returned by the code generation model for user selection.

[0053] Specifically, the user interface module designs and implements plug-in interactive elements in the IDE, such as code suggestion pop-up windows and code snippet insertion buttons, to ensure that after code reasoning is completed, the plug-in can accurately and timely display the suggested code returned by the large model in the corresponding position of the IDE for users to review and select.

[0054] Embodiment 3 As a specific embodiment of the present invention, this embodiment provides a device, including a memory, a processor and a computer program stored in the memory, and the processor executes the computer program to implement the steps of the behavioral intention self-identification method applied to the code generation large model described in Example 1.

[0055] Embodiment 4 As a specific embodiment of the present invention, this embodiment provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the behavioral intention self-identification method applied to the code generation large model described in Example 1 are implemented.

[0056] The behavioral intention self-identification method, system, device and storage medium applied to the code generation large model of the present invention accurately identify the user's effective programming behavior by delaying task processing, thereby reducing the number of code reasoning responses of the code generation large model, reducing the number of invalid reasonings, reducing the energy consumption of using the large model for code generation, improving the utilization rate of hardware equipment, and thus reducing costs.

[0057] The present invention has good versatility and adaptability, and can flexibly cope with different programming languages, project scales, and personal habits of developers, ensuring efficient code reasoning services in various programming scenarios and improving development efficiency.

[0058] The above description is only a preferred embodiment of the present invention and does not constitute any other form of limitation to the present invention. Any modification or equivalent change made based on the technical essence of the present invention still falls within the scope of protection required by the present invention.

Claims

1. A behavioral intention self-identification method applied to a large code generation model, characterized in that: The method comprises: Obtaining task information of the current cursor movement event, and encapsulating the task information into a task unit; Adding the encapsulated task unit to a task queue, scanning the task units in the task queue, and obtaining a time interval for the task unit to be added to the task queue; Based on the time interval of the task unit joining the task queue, the code generation model is called to perform code reasoning.

2. The behavioral intention self-identification method applied to the code generation large model according to claim 1 is characterized in that: The obtaining of task information of the current cursor movement event and packaging the task information into task units includes obtaining the task information including the current cursor position, the associated code context, and the task creation timestamp.

3. The behavior intention self-identification method applied to the code generation large model according to claim 2 is characterized in that: The calling of the code generation large model to perform code reasoning based on the time interval of the task unit joining the task queue includes comparing the time interval of the task unit joining the task queue with a preset interval threshold, and identifying the user behavior intention according to the comparison result.

4. The behavior intention self-identification method applied to the code generation large model according to claim 3 is characterized in that: When the time interval for the task unit to join the task queue is less than the interval threshold, the code reasoning logic is not executed; when the time interval for the task unit to join the task queue reaches the interval threshold, the code reasoning logic is executed.

5. The behavior intention self-identification method applied to the code generation large model according to claim 4 is characterized in that: When the time interval between the task unit being added to the task queue is less than an interval threshold, the unprocessed old task unit in the task queue is deleted.

6. The behavior intention self-identification method applied to the code generation large model according to claim 4 is characterized in that: When the time interval for the task unit to join the task queue reaches an interval threshold, a pre-configured code generation model interface is called, and the associated code context in the task information of the task unit is used as input to request the code generation model to generate code suggestions.

7. The behavior intention self-identification method applied to the code generation large model according to claim 3 is characterized in that: The interval threshold ranges from 2 to 4 seconds.

8. A behavioral intention self-identification system applied to code generation large model, characterized in that: The system includes an event monitoring module, a task creation module, and a task processing module, wherein: The event monitoring module is used to monitor the user's cursor movement events; The task creation module is used to obtain the task information of the current cursor movement event and encapsulate the task information into a task unit; add the encapsulated task unit to the task queue, scan the task units in the task queue, and obtain the time interval for the task unit to join the task queue; The task processing module is used to call the code generation model to perform code reasoning based on the time interval of the task unit joining the task queue.

9. A device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Code generation method based on large language model

    CN118409741A