User Avatar

Niraj Pandkar

1y ago

Welcome to my Typeshare Social Blog!

Day 2: How does Github Copilot suggest code completions?
Niraj Pandkar

I started using Copilot recently and wondered how to use it optimally. Copilot uses whatever context the IDE, such as Visual Studio Code, can provide. In addition to the filename, file path, and the extension of the file, the prompt engineering pipeline for Copilot involves the following -

Snippeting

Copilot gathers context by using the open tabs (files) in the IDE. If the code in all the open tabs doesn't fit in the context window, it chunks it into snippets of 60 lines. To avoid using overlapping snippets, it uses Jaccard similarity to identify a diverse set of samples.

Wishes

Copilot must make the tough decision to prioritize the various types of contexts (code above and below cursor, metadata, etc.). This is achieved by thinking of code items as wishes. Each wish is assigned a priority. For example, snippets with lower Jaccard similarity scores will have lower priority, while lines above the cursor will have the highest priority.

Speed vs. Accuracy Tradeoff

Copilot needed a highly capable model because quality makes all the difference between a useful suggestion and a distraction. On the other hand, the suggestions should be quick enough for the developers to use them positively. OpenAI developed models with Github to cater to speed because developers seem to get the most mileage out of them.

I would love to hear how you've used Copilot in your daily programming and extracted the most bang for your buck from the suggestions!

The all-in-one writing platform.

Write, publish everywhere, see what works, and become a better writer - all in one place.

Trusted by 80,000+ writers