Object-oriented large model code generation

Many considerations, the large model is very dependent on the context, in order for the large model to generate better code, it is necessary to accurately transfer the context information and instructions to the large model.

Pain Points
At present, large models mainly interact with natural language. The advantage of natural language interaction is to lower the threshold for using large models. However, due to the inaccuracy and divergence of language, the same function, described by different people, is the result of large model generation. no the same.

How to solve it?
Based on object-oriented thinking, software programming is essentially an operation on objects. Therefore, in the object operation room, the large model must show the situation of knowing the object, so the whole prompt is mainly divided into two parts:

  1. object description
  2. A description of the operation on the object where the operation on the object must reveal the object from 1.

For example: perform crud on users.

  1. First define which attributes the user object contains
  2. Perform crud on user.
    Here, the user in step 2 must be an English object, not Chinese. Since the large model can understand crud, the generated code will contain the crud method for user.

The overall idea is like this. Specifically, in different languages ​​and different scenarios, other constraints need to be defined according to the scenario. Such as what to rely on, what is the technology stack, what language and so on.

To sum up, the core of this article is to describe the object in a precise language to improve the robustness of the large model in generating code. In fact, for the operation of objects, a set of simple constraints can also be defined, which can ensure the quality of the code generated by the large model.

Guess you like

Origin blog.csdn.net/wenxueliu/article/details/132550759