Funny moments of using the GitHub Copilot

3 minute read

Image source: GitHub

Copilot? or Co-troublemaker.

I have been invited to the GitHub + OpenAI Copilot preview in VSCode for over a week now. While I am aware that many fellow coders have raised serious concern about copyrights of GitHub cashing in open-source codes, here I will report some of my lite usage in Copilot as a computational mathematician, along with what Copilot is instituting me to write during writing this blog post.

Enable and disable the Copilot

Copilot can be enabled by simply clicking the icon in the status bar.

Then we can sit back and enjoy some auto-completions Copilot provides (or institutes us to use), for example:

The good news are me is that, anecdotally, I do not see Copilot scanning my local files in the current workspace to make suggestions (while many others have complained in the preview discussion forums…). For example, the following suggested file does not exist, but just a sequential numbering of the files I have inserted in the current document:

Once enabled, upon clicking the icon again, it shows a toggle to disable Copilot for all languages or just the language of the current file we are working on.

Alternatively, we can set up specific languages to enable and disable Copilot in setting.json:

"github.copilot.enable": {
        "*": true,
        "yaml": false,
        "plaintext": false,
        "markdown": true,
        "latex": false
    },

Python (mainly PyTorch)

The usage in Python is a pleasant surprise as I thought the intellicode is already doing a phenomenal job on autocompletion. However, Copilot is on another level, in both a good and a bad way.

Here are some examples.

Autocomplete code based on comments

Autocomplete code based on the context

Example 1

If Copilot is GPT-based (or Transformer-based), it seems to be totally language-specific syntax-agnostic. For example, it sometimes provides a suggestion that induces a syntax error…

Example 2

Of course, Copilot is reading the current file for possible suggestions. Some examples are as follows:

The following one is a pretty good example of the Copilot’s power in that it can suggest a function that is not in the current scope, but is in the library. BTW, visualize the spectogram is exactly I wanted to achieve.

Copilot’s suggestions when writing this section

What Copilot suggests me to write during writing this section for this blog post.

LaTeX

While GitHub explicitly said that Copilot is not available for LaTeX, I could not help to give a try, and it works poorly unfortunately. Poor GPT…guess Transformers still have huge limitations.

When writing papers, Copilot spills all sorts of suggestions based on the nearest paragraph. Sometimes, it is almost funny in that it just re-iterates the same word, and it is not even making sense…

Example 1

Totally not what I want to write (this sentence is suggested by Copilot after I typed “Totally not”).

Example 2

Absolute nonsense (a pretty good candidate for those fake computer generated papers though).

Copilot’s suggestions when writing this section

What Copilot suggests me to write during writing this section for this blog post.

Summary

While I am not a big fan of Copilot, I do not see any reason to disable it. I am happy to see that GitHub is working on a better Copilot, and I am happy to see that I can use it to write my papers.

This was the suggestion Copilot suggested right after I typed “While”, and too bad I hit Tab too fast and forgot to snap a screenshot of this self-boasting suggestion.

What I meant to type was: while it seems that Copilot is pretty “powerful”, I can see I am only enabling it for Python, javascript, and CSS. For writing posts either in Markdown and LaTeX, the extensions Markdown all-in-one and LaTeX workshop are already doing a fantastic job on autocompleting file names, reading local directories, and other things.

Bonus: use Copilot to write a paper…

Here is a video of how to use the GitHub copilot to write a nonsensical paper…as we can see, even though content-wise Copilot is parroting, in general the Copilot gives pretty good autocomplete suggestions syntax-wise.

Bonus 2: chat with Copilot about mathematics, life, love, and the universe

Click here to go to the embedded video…

Comments