CodeGeeX User Guide

    

CodeGeeX is a multi-programming language code generation pre-training model with 13 billion parameters, trained using more than twenty programming languages. The plug-in developed based on CodeGeeX can realize a series of functions such as generating code through description, completing code, and translating code. CodeGeeX also provides a customizable prompt mode (Prompt Mode) to build exclusive programming assistants. Happy Coding!

Search "codegeex" in the VS Code plugin market to use it for free (VS Code version not lower than 1.68.0 is required). For more information about CodeGeeX, please see our homepage  and  GitHub repository .

If you encounter problems during use or have any suggestions for improvement, please send an email to [email protected] for feedback!

basic usage

It is necessary to ensure that the VS Code version >= 1.68.0. Install the plugin and activate CodeGeeX globally, there are four usage modes:

  • Stealth Mode : Keep CodeGeeX active, when you stop typing, it will start generating from the current cursor (the CodeGeeX icon in the lower right corner circles to indicate that it is generating). After the generation is complete, it will be displayed in gray, press Tabto insert the generated result.
  • Interactive mode : Press to Ctrl+Enteractivate the interactive mode, CodeGeeX will generate Xcandidates and display them in the right window ( X the number can be modified in the settings Candidate Num). Click above the candidate code use codeto insert.
  • Translate mode : Select the code, then press to Ctrl+Alt+Tactivate the translate mode, CodeGeeX will translate the code into the code that matches your current editor language. Click Insert above the translation results use code. You can also choose in the settings what you want to do with translated code when inserting, you can choose to comment them or override them.
  • Prompt mode (experimental function) : Select the code that needs to be input, press Alt/Option+tthe trigger prompt mode, a list of predefined templates will be displayed, select one of the templates, and the code can be inserted into the template for generation. This mode is highly customizable, you can  Prompt Templatesmodify or add template content in the settings, and add additional hints to the model.

Privacy statement

We highly respect the privacy of user code, and the code is only used to assist programming. When you use it for the first time, we will ask you to agree to use the generated code for research purposes to help CodeGeeX become better (this option is turned off by default ).

user's guidance

The following are the detailed usage of CodeGeeX several modes:

stealth mode

In this mode, CodeGeeX will start generating from the cursor when you stop typing (the CodeGeeX icon in the lower right corner circles to indicate that it is generating). After the generation is complete, it will be displayed in gray, press Tabto insert the generated result. In case multiple candidates are generated, it is possible to use Alt/Option+[ or  ]switch between several candidates. If you are not satisfied with the existing proposals, you can use Alt/Option+Ngo to get new candidates. Can be changed in the settings Candidate Num(increasing the number will result in a relatively slower generation speed). NOTE : The build always starts from the current cursor position, if you move the cursor position before the build ends, it may cause some bugs. We are working hard to make the generation faster to improve user experience.

interactive mode

In this mode, press to Ctrl+Enteractivate the interactive mode, CodeGeeX will generate Xcandidates and display them in the right window ( X the number can be modified in the settings Candidate Num). Click above the candidate code use codeto insert the result at the current cursor position.

translation mode

Input or paste codes in other languages ​​in the text editor of the current language, you select these codes with the mouse, and then press to activate the Ctrl+Alt+Ttranslation mode, you select the language of the code according to the prompts, and CodeGeeX will help you translate the code into A code that matches your current editor language. Click above the translation use codeto insert it. You can also choose in the settings what you want to do with translated code when inserting, you can choose to comment them or override them.

Hint mode (experimental feature)

In this mode, you can add additional hints to the input to achieve some interesting functions, including but not limited to code interpretation, generalization, generation in a specific style, etc. The principle of this mode is to take advantage of the powerful few-sample generation capabilities of CodeGeeX. When you provide some examples in the input, CodeGeeX will imitate these examples and implement the corresponding functions. For example, you can provide an example that explains the code line by line in a custom template. Select the code you want to explain, press Alt/Option+tthe trigger prompt mode, select the template you wrote (for example explanation), CodeGeeX will explain the code you input. Below we will introduce in detail how to make a template.

The template in the above example is shown in the figure below, consisting of [示例代码]<INPUT>[带解释的示例代码] and  [输出函数头] . <INPUT>Indicates where the code you selected will be inserted. <INPUT0:1> This sentence is used to ensure that the model explains the same function. When using the prompt mode, CodeGeeX will combine the code you choose (inserted into the section) and the template code as input to the model.

# language: Python

def sum_squares(lst):
    sum = 0
    for i in range(len(lst)):
        if i % 3 == 0:
            lst[i] = lst[i]**2
        elif i % 4 == 0:
            lst[i] = lst[i]**3
        sum += lst[i]
    return sum

<INPUT>

# Explain the code line by line
def sum_squares(lst):
    # initialize sum
    sum = 0
    # loop through the list
    for i in range(len(lst)):
        # if the index is a multiple of 3
        if i % 3 == 0:
            # square the entry
            lst[i] = lst[i]**2
        # if the index is a multiple of 4
        elif i % 4 == 0:
            # cube the entry
            lst[i] = lst[i]**3
        # add the entry to the sum
        sum += lst[i]
    # return the sum
    return sum

# Explain the code line by line
<INPUT:0,1>

Here is another example of Python docstring generation, CodeGeeX mimics the format of this comment when you write new functions:

def add_binary(a, b):
    '''
    Returns the sum of two decimal numbers in binary digits.

    Parameters:
            a (int): A decimal integer
            b (int): Another decimal integer

    Returns:
            binary_sum (str): Binary string of the sum of a and b
    '''
    binary_sum = bin(a+b)[2:]
    return binary_sum

<INPUT>

The template files are highly customizable, you can add custom templates in the plugin settings Prompt TemplateskeyIndicates the name of the template,  valuewhich is the path of the template file (it can be any path on your computer, and files in formats such as .txt.py,  , etc. are acceptable). .hThrough this function, you can let CodeGeeX generate code with a specific style or function, try to define your own exclusive template!

Currently CodeGeeX, we have the following open forms:

1) Codes and models are completely open source: https://models.aminer.cn/codegeex

2) Online demonstration demo:

Code generation: https://models.aminer.cn/codegeex/playground

Code translation: https://models.aminer.cn/codegeex/codeTranslator

3) Provide VS code plugin:

https://marketplace.visualstudio.com/items?itemName=aminer.codegeex

Other platform plug-ins, if you are interested, we can work together to develop

4) Provide API interface:

https://tianqi.aminer.cn/open/document/code_ref/codegeex_generation

Guess you like

Origin blog.csdn.net/qq_51588894/article/details/129271632