A logic scenario generation method, device and equipment based on a large language model
By using a large language model-based approach, autonomous driving logic scenarios are automatically analyzed and generated, solving the problems of low efficiency and long time consumption in scenario creation in existing technologies, and realizing an efficient scenario construction process.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING SAIMO TECH CO LTD
- Filing Date
- 2023-10-18
- Publication Date
- 2026-07-24
AI Technical Summary
In existing technologies, the creation of autonomous driving logic scenarios is inefficient and time-consuming, mainly relying on manual construction.
The method adopts a large language model-based approach. By analyzing the target natural language of the autonomous driving logic scenario to be created, target labels are obtained. The target labels are then used to search for matching target use cases in the scenario use case library, and target prompt words are constructed. Finally, the logic scenario is automatically generated through the language model.
It enables the automatic construction of autonomous driving logic scenarios, improves scenario creation efficiency, reduces creation time, and avoids the inefficiency problem of manual intervention.
Smart Images

Figure CN117370496B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of autonomous driving technology, and more specifically, to a method, apparatus, and device for generating logical scenes based on a large language model. Background Technology
[0002] Before commercial application, autonomous driving requires extensive testing. Simulation testing based on autonomous driving scenarios is an essential step in the testing process. Autonomous driving scenarios can be categorized according to their level of abstraction: functional scenarios, logical scenarios, and concrete scenarios. ASAM OSC (Open Scenario) defines a standard scenario description language that is compatible with various simulation testing software. To meet the needs of more users, the OSC 2.0 standard is a high-level domain-specific language (DSL) for scenario description, supporting concrete, logical, and abstract scenarios, covering programming language content, corresponding scenario generation conditions, and scenario content information.
[0003] However, in existing technologies, when creating autonomous driving logic scenarios using scenario description languages, developers mainly create logic scenarios manually. This manual creation of logic scenarios leads to low scenario creation efficiency and long creation time. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a method, apparatus and device for generating logical scenes based on a large language model, so as to solve the problems of low scene creation efficiency and long scene creation time when creating logical scenes for autonomous driving.
[0005] In a first aspect, embodiments of this application provide a method for generating logical scenes based on a large language model, including:
[0006] Analyze the target natural language corresponding to the autonomous driving logic scenario to be created, and obtain the target label corresponding to the target natural language.
[0007] Using target tags, search for target use cases that match the target's natural language from a scenario use case library;
[0008] Based on the target use cases and target natural language, construct target prompt words;
[0009] Input the target prompt words into the first language model to obtain the autonomous driving logic scenario.
[0010] Optionally, using target tags, target use cases that match the target natural language are searched from a scenario use case library. This includes: standardizing the target natural language to obtain normalized natural language; performing feature transformation on the normalized natural language and the candidate natural language corresponding to each candidate use case in the scenario use case library to obtain first language features and multiple second language features, where the first language features are the features corresponding to the normalized natural language and each second language feature is the feature corresponding to a single candidate natural language; and selecting target use cases from multiple candidate use cases based on the similarity between the first language features and each second language feature.
[0011] Optionally, before analyzing the target natural language corresponding to the autonomous driving logic scenario to be created and obtaining the target label corresponding to the target natural language, the method further includes: determining multiple initial natural languages corresponding to different autonomous driving test requirements; for each initial natural language, determining the initial logical language and initial label corresponding to that initial natural language; constructing initial use cases corresponding to that initial natural language based on the initial natural language, initial logical language and initial label; and constructing a scenario use case library from multiple initial use cases.
[0012] Optionally, before performing feature transformation on the candidate natural language corresponding to each candidate use case in the normalized natural language and scenario use case library to obtain the first language features and multiple second language features, the method further includes: obtaining the initial label corresponding to each initial use case from the scenario use case library; determining the overlap between the initial label and the target label for each initial label; and selecting candidate use cases from multiple initial use cases in the scenario use case library based on the overlap.
[0013] Optionally, the target use cases include a first target use case and a second target use case. The first target use case is used to describe the participants in the autonomous driving scenario, and the second target use case is used to describe different stages of the autonomous driving scenario. Based on the target use cases and target natural language, target prompt words are constructed, including: combining the first target use case, the second target use case, and the target natural language with the prompt word template to obtain target prompt words.
[0014] Optionally, the target natural language corresponding to the autonomous driving logic scenario to be created is analyzed to obtain the target label corresponding to the target natural language, including: constructing analysis instructions and multiple analysis use cases corresponding to different autonomous driving scenarios; inputting the analysis instructions, multiple analysis use cases and target natural language into a second language model to obtain the target label.
[0015] Optionally, feature transformation is performed on the candidate natural language corresponding to each candidate use case in the normalized natural language and scenario use case library to obtain first language features and multiple second language features, including: inputting the normalized natural language and each candidate natural language into the language model encoder to obtain first language features and multiple second language features.
[0016] Optionally, target use cases are selected from multiple candidate use cases based on the similarity between the first language feature and each second language feature, including: for each second language feature, determining the cosine similarity between the second language feature and the first language feature; sorting the multiple candidate use cases in descending order of cosine similarity, and selecting a preset number of candidate use cases with the highest ranking as target use cases.
[0017] Secondly, embodiments of this application also provide a logic scene generation device based on a large language model, the device comprising:
[0018] The language analysis module is used to analyze the target natural language corresponding to the autonomous driving logic scenario to be created, and obtain the target label corresponding to the target natural language.
[0019] The use case matching module is used to find target use cases that match the target's natural language from the scenario use case library by utilizing target tags;
[0020] The prompt word construction module is used to construct target prompt words based on the target use cases and target natural language;
[0021] The scene generation module is used to input target prompt words into the first language model to obtain autonomous driving logic scenes.
[0022] Thirdly, embodiments of this application also provide an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, the steps of the logic scene generation method based on the large language model described above are performed.
[0023] The embodiments of this application bring the following beneficial effects:
[0024] This application provides a method, apparatus, and device for generating logical scenarios based on a large language model. It can obtain target tags through analysis of the target natural language, search for target use cases matching the target tags in a scenario use case library, and achieve automatic conversion from natural language to use cases. Then, it constructs target prompt words using the target use cases, and automatically generates autonomous driving logical scenarios using the target prompt words and a first language model. The entire logical scenario construction process is automatic and requires no manual intervention. Compared with existing methods for generating logical scenarios based on large language models, this solves the problems of low scenario creation efficiency and long scenario creation time when creating autonomous driving logical scenarios.
[0025] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0026] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 A flowchart of the logical scene generation method based on a large language model provided in an embodiment of this application is shown;
[0028] Figure 2 A schematic diagram of the structure of the logic scene generation device based on a large language model provided in an embodiment of this application is shown;
[0029] Figure 3 A schematic diagram of the structure of the electronic device provided in the embodiments of this application is shown. Detailed Implementation
[0030] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. Based on the embodiments of this application, every other embodiment obtained by those skilled in the art without inventive effort falls within the scope of protection of this application.
[0031] It is worth noting that prior to this application, autonomous driving required extensive testing before commercial application. Simulation testing based on autonomous driving scenarios is an essential step in autonomous driving testing. Autonomous driving scenarios can be categorized according to their level of abstraction: functional scenarios, logical scenarios, and concrete scenarios. ASAM OSC (Open Scenario) defines a standard scenario description language that is compatible with different simulation testing software. To meet the needs of more users, the OSC 2.0 standard is a high-level domain-specific language (DSL) for scenario description, supporting concrete, logical, and abstract scenarios, covering programming language content, corresponding scenario generation conditions, and scenario content information. However, in existing technologies, when creating autonomous driving logical scenarios using scenario description languages, developers mainly create logical scenarios manually. This manual creation of logical scenarios leads to low efficiency and long creation times.
[0032] Based on this, this application provides a logical scene generation method based on a large language model to improve the scene creation efficiency and shorten the scene creation time when creating autonomous driving logical scenes.
[0033] Please see Figure 1 , Figure 1 This is a flowchart illustrating a logical scene generation method based on a large language model, provided as an embodiment of this application. Figure 1 As shown in the embodiments of this application, the logical scene generation method based on a large language model includes:
[0034] Step S101: Analyze the target natural language corresponding to the autonomous driving logic scenario to be created, and obtain the target label corresponding to the target natural language.
[0035] In this step, the target natural language can refer to the natural language describing the autonomous driving logic scenario to be created. For example, the natural language can be Chinese or English. Specifically, the target natural language could be "Vehicle A cuts in front of Vehicle B, and Vehicle B brakes and stops."
[0036] Logical scenarios are further detailed descriptions of functional scenarios based on state-space variables, used to generate requirements during the project development phase. For each logical scenario with a continuous range of values, any number of specific scenarios can be derived.
[0037] Target labels can refer to labels that represent important information in the target natural language.
[0038] In this embodiment, when creating a logical scenario, the target natural language describing the autonomous driving logical scenario to be created is first obtained. This target natural language is then input into a language analysis module, which splits the target natural language into multiple target labels. These target labels include four categories: participants, whether participants require constraints, scenario stage, and whether different stages include different sequences.
[0039] Suppose the target natural language input to the language analysis module is "Vehicle A cuts in front of Vehicle B, Vehicle B brakes and stops". The output of the language analysis module would be: "Participants: Vehicle A, Vehicle B; Do participants need constraints: Yes; Scene stages: Free driving, cutting in, braking and stopping; Do different stages include different sequences: No, Yes, Yes". The "Yes" in "Do participants need constraints?" means that Vehicle A is restricted to being in front of Vehicle B and in adjacent lanes. The "No, Yes, Yes" in "Do different stages include different sequences?" respectively indicate that different sequences are not included in the free driving stage (i.e., the participant's state does not change), while different sequences are included in the cutting in and braking and stopping stages (i.e., the participant's state changes).
[0040] In an optional embodiment, step S101 includes: step a1 and step a2.
[0041] Step a1: Construct analysis instructions and multiple analysis use cases corresponding to different autonomous driving scenarios.
[0042] Specifically, OSC defines a standard simulation test case format. This application uses the OSC language to construct analysis instructions. The analysis instructions are a brief introduction to the OSC language, as shown below:
[0043] "System Description: The OSC2.0 language has 6 types of entities: participants, actions, phases, temporal composition operators, constraints / modifiers, and overrides. Participants include cars, motorcycles, and pedestrians. Phases include cutting in, cutting out, overtaking, changing lanes, following, turning, braking, and shifting gears."
[0044] The analysis instruction is a fixed set of content, and each analysis use case also has fixed content. Each analysis use case corresponds to a type of autonomous driving scenario. Multiple analysis use cases should include the autonomous driving scenario corresponding to the target natural language to facilitate analysis of the target natural language. For example, a single analysis use case can be:
[0045] "You need to perform the following tasks: Divide a given sentence into participants. Each sentence can have multiple participants. Classify whether participants need constraints. Divide a given sentence into stages. Each sentence can have multiple stages. Determine whether stages need a sequence."
[0046] Step a2: Input the analysis instructions, multiple analysis use cases, and target natural language into the second language model to obtain the target label.
[0047] Here, the second language model can be a large language model (LLM). For example, the second language model can be any one of GPT-3, GPT-4, XLNET, BLOOM, T5, and BERT.
[0048] Specifically, the analysis instructions are combined with multiple analysis use cases as fixed inputs, and the target natural language is used as variable inputs. The fixed inputs are combined with the variable inputs in the order of fixed inputs first and variable inputs second to form a combined input. The combined input is then input into the second language model in English form to obtain the target label output by the second language model.
[0049] For example, if the target natural language is "Car A cuts in front of Car B, and Car B slows down", this target natural language can be placed after the analysis command and multiple analysis use cases. These three parts together form the combined input. Putting the combined input into a large language model yields the following output:
[0050] Participants: Car A, Car B; Participant constraints required: Yes; Scene phase: Cut in, Decelerate; Different phases include different sequences: true, true. Approach: The sentence contains two participants: Car A and Car B. This requires a constraint because Car A cuts in front of Car B, indicating a change in their relative positions. It comprises two phases: one phase involves Car A cutting in front of Car B, and the other phase involves Car B decelerating. In the first phase, Car A is ahead of Car B, thus requiring a different sequence. In the second phase, Car B decelerates, indicating a change in its speed, also requiring a different sequence. The target labels are: "Participants: Car A, Car B; Participant constraints required: Yes; Scene phase: Cut in, Decelerate; Different phases include different sequences: true, true".
[0051] It should be noted that the language analysis module includes two classifiers: a participant and stage classifier, and a participant constraint and sequence composition classifier. The participant and stage classifier is used to determine the participants and scene stages included in the target natural language, while the participant constraint and sequence composition classifier is used to determine whether constraints need to be added to participants and whether different stages include different sequences. This application utilizes an LLM model to implement the classifier function. Since the fixed input remains unchanged for different autonomous driving logic scenarios to be created, only the target natural language needs to be changed; therefore, the target labels corresponding to the target natural language can be obtained quickly.
[0052] In an optional embodiment, before step S101, the method further includes steps b1, b2, b3, and b4.
[0053] Step b1: Determine multiple initial natural languages corresponding to different autonomous driving test requirements.
[0054] In order to quickly determine the logical scenario corresponding to the target natural language, a mapping relationship between natural language, scenario stage, and tags is established in advance. That is, before splitting the target natural language, a scenario use case library is first built.
[0055] The scenario use case library covers different use cases corresponding to different logical scenarios. Each use case library includes multiple use cases, and each use case includes an initial natural language. Each initial natural language is established according to the requirements of autonomous driving testing. For example, for the scenario where car A cuts in front of car B, and car B accelerates or decelerates, the initial natural language is: Car A cuts in front of car B, and then car B decelerates. A corresponding initial natural language is established for each autonomous driving testing scenario requirement.
[0056] Step b2: For each initial natural language, determine the initial logical language and initial label corresponding to that initial natural language.
[0057] For each initial natural language, obtain the corresponding initial logical language and four initial labels. For example, the initial natural language for a single use case is: defining a vehicle traveling at a minimum speed v1 and a maximum speed v2, then the corresponding initial logical language is:
[0058] v:car;
[0059] min_speed:v1;
[0060] max_speed:v2;
[0061] keep(min_speed <max_speed)
[0062] do serial:
[0063] v.drive()with:
[0064] speed([min_speed..max_speed]).
[0065] Here, in order to improve the accuracy of matching between target use cases and candidate use cases, the scenario use case library is divided into two use case libraries: the participant use case library and the scenario stage use case library. The participant use cases in one participant use case library correspond to one or more scenario stage use cases in one scenario stage use case library.
[0066] Taking the above example, the initial use cases can be divided into actor use cases and scenario phase use cases. The actor use cases are placed in the actor use case library, and the scenario phase use cases are placed in the scenario phase use case library. For example, it can be split into the following two use cases:
[0067] The initial natural language in the participant's use case is: a vehicle with a speed limit of [v1, v2]; the initial logical language in the participant's use case is: v:car; min_speed:v1; max_speed:v2; keep(min_speed) <max_speed)。
[0068] The initial natural language in the scenario phase use case is: A car is driving on the road; the initial logical language in the scenario phase use case is: do serial:v.drive().
[0069] The actor use case library is primarily used for the initialization of logical scenarios. The purpose of initialization is to describe the initial state of the scenario. Actors are the main units that constitute the logical scenario; common actors include vehicles, pedestrians, and traffic lights. Different scenarios impose different constraints on actors during initialization, for example:
[0070] The two cars, v1 and v2, have different colors: keep(v1.color!=v2.color);
[0071] v1 overtaking (passing v2) scenario: speed([10..15]kph,faster_than:v1);
[0072] Limit vehicle weight: keep(weight in [500..4000]kg).
[0073] The scenario-stage use case library is mainly used to describe different stages of autonomous driving scenarios, including the behavior of participants at different times. For example, the scenario of the preceding vehicle cutting in can include the following three stages: Stage 1, the preceding vehicle and the following vehicle are traveling at the same speed of 30km / h in different lanes; Stage 2, the preceding vehicle changes lanes and is in the same lane as the following vehicle; Stage 3, the preceding vehicle is traveling at 25km / h, and the following vehicle brakes and continues to travel at 25km / h.
[0074] For participants in the same scenario phase, there is also the concept of sequence, i.e., different states or behaviors. Taking the example above, in phase two, the car in front has two states, located in two lanes respectively; in phase three, the car in front has one state, and the car behind has two states, namely braking and decelerating.
[0075] In addition, each use case in the scenario use case library includes a label, which is divided into four categories: participants, whether participants need constraints, scenario stage, and whether different stages include different sequences.
[0076] Step b3: Based on the initial natural language, initial logical language, and initial labels, construct the initial use cases corresponding to the initial natural language.
[0077] For each initial natural language, the initial natural language, its corresponding initial logical language, and its corresponding initial label are combined to form an initial use case. Thus, each use case includes three parts: the initial natural language, its corresponding initial logical language, and the initial label. The initial natural language is a human-readable language; the initial logical language is a logical scenario language used to describe the logical scenario (it is a programming language); and the initial label represents the label information in the initial use case.
[0078] Step b4: The scenario use case library is composed of multiple initial use cases.
[0079] All initial use cases together constitute the scenario use case library, which reflects the mapping relationship between natural language, scenario stage, and labels in different autonomous driving simulation tests.
[0080] Step S102: Using target tags, search for target use cases that match the target natural language from the scenario use case library.
[0081] In this step, the scenario use case library includes multiple initial use cases, each with a corresponding initial label. The target label is compared with the initial label, and the target use case that matches the target natural language can be selected from the multiple initial use cases based on the comparison results, so as to generate a logical scenario based on the target use case.
[0082] In an optional embodiment, step S102 includes: step c1, step c2, and step c3.
[0083] Step c1: Standardize the target natural language to obtain normalized natural language.
[0084] Specifically, to improve the accuracy of tag matching, specific numerical values in the target natural language are standardized. For example, if the target natural language includes a distance of 50m, then 50m is changed to xm; if the target natural language includes a specific color such as red or blue, then red or blue is changed to color; if the target natural language includes specific subject names such as vehicle and motorcycle, then vehicle and motorcycle are changed to subject a and subject b. In essence, standardizing the target natural language is essentially template-based processing to obtain standardized natural language.
[0085] Step c2 involves performing feature transformation on the candidate natural language corresponding to each candidate use case in the standardized natural language and scenario use case library to obtain first language features and multiple second language features.
[0086] Here, the first language feature is the feature corresponding to the normalized natural language, and the single second language feature is the feature corresponding to the single candidate natural language.
[0087] Specifically, the normalized natural language and each candidate natural language are input into a large-scale language model to obtain first language features and multiple second language features. Each first language feature and each second language feature is a 768-dimensional feature vector.
[0088] In an optional embodiment, step c2 includes: step c21.
[0089] Step c21: Input the normalized natural language and each candidate natural language into the language model encoder to obtain the first language features and multiple second language features.
[0090] Specifically, the normalized natural language is input into the encoder of the large language model to output the first language features corresponding to the normalized natural language, and each candidate natural language is input into the language model encoder to obtain the second language features corresponding to each candidate natural language.
[0091] The encoder can be an encoder in a large language model. For example, the encoder can be the encoder of the BERT (Bidirectional Encoder Representation from Transformers) model, or it can be the encoder of other large language models.
[0092] Taking the encoder of the BERT model as an example, the encoder output includes bits C, T1, T2, and up to T. N The result of the bit transformation is the feature output at the first position (C position) of all positions output by the encoder, which is taken as the result of the feature transformation, i.e., as the language feature.
[0093] Step c3: Select the target use case from multiple candidate use cases based on the similarity between the first language feature and each second language feature.
[0094] The similarity between the first language feature and each second language feature is determined. A higher similarity indicates a better match between the first language feature and the second language feature; a lower similarity indicates a worse match. Therefore, a predetermined number of candidate use cases with the highest similarity ranking can be selected as target use cases.
[0095] In an optional embodiment, step c3 includes: step c31 and step c32.
[0096] Step c31: For each second language feature, determine the cosine similarity between the second language feature and the first language feature.
[0097] Here, the cosine similarity (inner product) between the first language feature and each second language feature can be calculated. The higher the cosine similarity between the two, the more the first language feature matches the second language feature; the lower the cosine similarity between the two, the less the first language feature matches the second language feature.
[0098] Step c32: Sort the multiple candidate use cases in descending order of cosine similarity, and select the top-ranked number of candidate use cases as the target use cases.
[0099] Each cosine similarity score is represented by a numerical value. Candidate use cases corresponding to each candidate natural language are ranked according to their numerical values from highest to lowest, and the top 10 candidate use cases are selected as the target use cases. Here, 10 represents a preset number; those skilled in the art can choose a specific value for the preset number based on actual circumstances, and this application does not impose any limitation on this.
[0100] In an optional embodiment, before step c2, the method further includes steps d1 and d2.
[0101] Step d1: Obtain the initial label corresponding to each initial use case from the scenario use case library.
[0102] Before performing feature transformation on the normalized natural language and the candidate natural language corresponding to each candidate use case, it is first necessary to select candidate use cases from multiple initial use cases in the scenario use case library. Here, the initial use cases in the participant use case library are called the first initial use cases, and the initial use cases in the scenario stage use case library are called the second initial use cases. The first initial label corresponding to each first initial use case is obtained from the participant use case library, and the second initial label corresponding to each second initial use case is obtained from the scenario stage use case library.
[0103] Step d2: For each initial label, determine the overlap between the initial label and the target label; based on the overlap, select candidate use cases from multiple initial use cases in the scenario use case library.
[0104] Calculate the label overlap between the target label and each first initial label. Select the first initial use case corresponding to the first initial label with a label overlap higher than a first set threshold as the first candidate use case. Alternatively, sort the multiple first initial use cases in descending order of overlap and select the first preset number of first initial use cases with the highest ranking as the first candidate use cases.
[0105] Calculate the label overlap between the target label and each second initial label. Select the second initial use cases corresponding to the second initial labels with a label overlap higher than a second set threshold as second candidate use cases. Alternatively, sort the second initial use cases in descending order of overlap and select the second preset number of second initial use cases with the highest overlap as second candidate use cases.
[0106] The candidate use cases are composed of the first candidate use case and the second candidate use case. Meanwhile, the target use case selected from the first candidate use case is designated as the first target use case, and the target use case selected from the second candidate use case is designated as the second target use case.
[0107] Step S103: Construct target prompt words based on the target use case and target natural language.
[0108] In this step, the target use case, target natural language, and prompt word template are combined to obtain target prompt words, which are then used to generate autonomous driving logic scenarios.
[0109] In an optional embodiment, the target use case includes a first target use case and a second target use case. The first target use case is used to describe the participants in the autonomous driving scenario, and the second target use case is used to describe different stages of the autonomous driving scenario. Step S103 includes: step e1.
[0110] Step e1: Combine the first target use case, the second target use case, and the target natural language with the prompt word template to obtain the target prompt word.
[0111] The prompt template includes system instructions, the first target use case to be input, language rules, the second target use case to be input, and the target natural language to be input. The system instructions include an introduction to OSC2.0, and the language rules include the format of the DSL language.
[0112] For example, system instructions could be: OpenSCENARIO 2.0 aims to establish a declarative, domain-specific language. This declarative language describes what should happen during scenario execution (including required parameters / changes).
[0113] For example, the language rules could be: OSC 2.0 has a top-level paragraph that initializes participants and additional paragraphs that describe actions; additional type definitions and type extensions may exist in the additional paragraphs: a scenario describes the behavior of participants over a period of time; a participant is a “participant” (behavioral entity) in the scenario (e.g., vehicle, person, etc.); an action (e.g., drive) defines the basic capabilities of a participant; a phase is a period of time in the scenario, and a compound phase is a phase composed of invoking time composition operators (e.g., serial or parallel).
[0114] The first target use case is filled in the position where the first target use case is to be input, the second target use case is filled in the position where the second target use case is to be input, and the target natural language is filled in the position where the target natural language is to be input, so that the first target use case, the second target use case, and the target natural language are combined with the prompt word template to obtain the complete target prompt word.
[0115] Step S104: Input the target prompt word into the first language model to obtain the autonomous driving logic scene.
[0116] In this step, the first language model may refer to a large language model (LLM). The first language model may be the same as the second language model or may be different from the second language model.
[0117] In this embodiment, the target prompt words are input into the first language model in DSL language format, and the first language model outputs the logical scene language, which is the autonomous driving logical scene. The target prompt words can also be input into the first language model using other domain-specific language formats. Those skilled in the art can choose the language format according to the actual situation, and this application does not impose any limitations on this.
[0118] Compared with existing logical scene generation methods based on large language models, this application can obtain target tags by analyzing the target natural language, find target use cases that match the target tags in the scene use case library, realize the automatic conversion from natural language to use cases, and then construct target prompt words through target use cases. The target prompt words and the first language model are used to automatically generate autonomous driving logical scenes. The entire logical scene construction process is completed automatically without human intervention, which solves the problems of low scene creation efficiency and long scene creation time when creating autonomous driving logical scenes.
[0119] Based on the same inventive concept, this application also provides a logic scene generation device based on a large language model, which corresponds to the logic scene generation method based on a large language model. Since the principle of the device in this application is similar to the logic scene generation method based on a large language model described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0120] Please see Figure 2 , Figure 2 This is a schematic diagram of the structure of a logic scene generation device based on a large language model, provided in an embodiment of this application. Figure 2 As shown, the logic scene generation device 200 based on a large language model includes:
[0121] The language analysis module 201 is used to analyze the target natural language corresponding to the autonomous driving logic scenario to be created, and to obtain the target label corresponding to the target natural language.
[0122] The use case matching module 202 is used to find target use cases that match the target natural language from the scenario use case library by utilizing target tags;
[0123] The prompt word construction module 203 is used to construct target prompt words based on the target use cases and target natural language;
[0124] The scene generation module 204 is used to input the target prompt words into the first language model to obtain the autonomous driving logic scene.
[0125] Please see Figure 3 , Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 3 As shown, the electronic device 300 includes a processor 310, a memory 320, and a bus 330.
[0126] The memory 320 stores machine-readable instructions executable by the processor 310. When the electronic device 300 is running, the processor 310 and the memory 320 communicate via the bus 330. When the machine-readable instructions are executed by the processor 310, they can perform the operations described above. Figure 1 The steps of the logical scene generation method based on a large language model in the method embodiment shown are described in detail in the method embodiment, and will not be repeated here.
[0127] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0128] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the shown or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0129] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0130] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0131] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0132] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The scope of protection of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for generating logical scenes based on a large language model, characterized in that, include: The target natural language corresponding to the autonomous driving logic scenario to be created is analyzed using a second language model to obtain the target label corresponding to the target natural language; Candidate use cases are selected from the scenario use case library based on the overlap between the target label and the initial label. Target use cases that match the target natural language are searched from the candidate use cases. The scenario use case library includes use cases covering different logical scenarios. Each use case includes an initial label. The target use cases include a first target use case for describing the participants in an autonomous driving scenario and a second target use case for describing different stages of an autonomous driving scenario. Based on the first target use case, the second target use case, and the target natural language, construct target prompt words; The target prompt words are input into the first language model to obtain the autonomous driving logic scenario; The step of finding target use cases that match the target natural language from candidate use cases includes: The target natural language is standardized to obtain normalized natural language; The normalized natural language and the candidate natural language corresponding to each candidate use case in the scenario use case library are respectively subjected to feature transformation to obtain a first language feature and multiple second language features. The first language feature is the feature corresponding to the normalized natural language, and the single second language feature is the feature corresponding to a single candidate natural language. Target use cases are selected from multiple candidate use cases based on the similarity between the first language feature and each second language feature.
2. The method according to claim 1, characterized in that, Before analyzing the target natural language corresponding to the autonomous driving logic scenario to be created using a second language model to obtain the target label corresponding to the target natural language, the method further includes: Determine multiple initial natural language samples corresponding to different autonomous driving test requirements; For each initial natural language, determine the corresponding initial logical language and initial label; Based on the initial natural language, the initial logical language, and the initial labels, construct the initial use cases corresponding to the initial natural language; The scenario use case library consists of multiple initial use cases.
3. The method according to claim 1, characterized in that, The step of selecting candidate use cases from the scenario use case library based on the overlap between the target label and the initial label includes: Obtain the initial label corresponding to each initial use case from the scenario use case library; For each initial tag, determine the degree of overlap between the initial tag and the target tag; Based on the degree of overlap, candidate use cases are selected from multiple initial use cases in the scenario use case library.
4. The method according to claim 1, characterized in that, The step of constructing target prompt words based on the first target use case, the second target use case, and the target natural language includes: The first target use case, the second target use case, and the target natural language are combined with the prompt word template to obtain the target prompt word.
5. The method according to claim 1, characterized in that, The process of using a second language model to analyze the target natural language corresponding to the autonomous driving logic scenario to be created, and obtaining the target label corresponding to the target natural language, includes: Construct analysis commands and multiple analysis use cases corresponding to different autonomous driving scenarios; The analysis instructions, the multiple analysis use cases, and the target natural language are input into the second language model to obtain the target label.
6. The method according to claim 1, characterized in that, The step involves performing feature transformation on the normalized natural language and the candidate natural language corresponding to each candidate use case in the scenario use case library to obtain first language features and multiple second language features, including: The normalized natural language and each candidate natural language are input into the language model encoder to obtain the first language features and multiple second language features.
7. The method according to claim 1, characterized in that, The step of selecting a target use case from multiple candidate use cases based on the similarity between the first language feature and each second language feature includes: For each second language feature, determine the cosine similarity between the second language feature and the first language feature; The candidate use cases are sorted in descending order of cosine similarity, and a predetermined number of the top-ranked candidate use cases are selected as the target use cases.
8. A logic scene generation device based on a large language model, characterized in that, include: The language analysis module is used to analyze the target natural language corresponding to the autonomous driving logic scenario to be created using a second language model, and obtain the target label corresponding to the target natural language. The use case matching module is used to select candidate use cases from the scenario use case library based on the overlap between the target label and the initial label, and to find target use cases that match the target natural language from the candidate use cases. The scenario use case library includes use cases covering different logical scenarios. Each use case includes an initial label. The target use cases include a first target use case for describing the participants in the autonomous driving scenario and a second target use case for describing different stages of the autonomous driving scenario. The prompt word construction module is used to construct target prompt words based on the first target use case, the second target use case, and the target natural language; The scene generation module is used to input the target prompt words into the first language model to obtain the autonomous driving logic scene; The test case matching module is specifically used for: The target natural language is standardized to obtain normalized natural language; The normalized natural language and the candidate natural language corresponding to each candidate use case in the scenario use case library are respectively subjected to feature transformation to obtain a first language feature and multiple second language features. The first language feature is the feature corresponding to the normalized natural language, and the single second language feature is the feature corresponding to a single candidate natural language. Target use cases are selected from multiple candidate use cases based on the similarity between the first language feature and each second language feature.
9. An electronic device, characterized in that, include: The device includes a processor, a storage medium, and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the logical scene generation method based on a large language model as described in any one of claims 1 to 7.