Automating Aviation programming tasks with AI-generated code via GitHub Copilot

Dario Martinez

2022-04-20 16:09:51
Reading Time: 2 minutes

AI for my code? What the hell is GitHub Copilot?

GitHub Copilot is an AI tool developed by GitHub and OpenAI (yes, the AI lab founded by Elon Musk). It aims to assist programmers with writing code through autocompletion in the IDE. The extension is made available for Visual Studio Code, Neovim, and JetBrains.

The OpenAI Codex model powers GitHub Copilot. Codex is trained on natural language and billions of lines of source code from the public domain, including GitHub code repositories. GitHub Copilot generates multiple suggestions on the context of the file being edited based on the comments in the file, and the code you’ve written before.

Here’s how it works: you write the docstring or the comment, suggesting a code snippet. In some cases, just the function name or a part of the function is enough to generate the rest of the code. Copilot makes ten suggestions at a time. The accuracy of suggestions improves as you type more code, and it also improves as mode programmers connect it to feed the model with more code, as any AI model.

Copilot isn’t the first of its kind; Tabnine and Kite are two popular tools that cover the same functionality. However, Copilot stands out because it’s powered by Codex, which provides a deeper understanding of the context than other assistants. Codex is a NLP supervised learning model based on GPT3, trained with billions of lines of code as features and docstrings as labels from GitHub public repositories and open-source projects. Furthermore, Github Copilot learns from your own programming patterns and improves recommendations on the fly.

GitHub Copilot solving basic Aviation problems

Let’s see how well Copilot can solve three common aviation coding problems.

  • Easy – Km to Nautical miles:

  • Medium – Calculate the geographic distance (Haversine) between two pairs of coordinates:

  • Hard – Fetch a METAR report from a live public source and convert it to pandas dataframe:

So, are we being replaced?

GitHub Copilot is very impressive and indeed is one the first new generation AI tools that could replace humans. But, as it is now, the Copilot’s code must be “tested, reviewed, and vetted.”

The system “is known to produce undesired outputs, including biased, discriminatory, abusive, or offensive outputs.” Copilot code may even not compile, as it doesn’t test the code it outputs. Ultimately, this makes human interference and supervision mandatory in order to produce functioning code.

Author: Dario Martinez