44 ms·
Copilot Internals
- gavinray 4y agoI stumbled upon this repo by accident a few days ago when its source code appeared to contain the only usage the term "GH_COPILOT_TOKEN" in any repo on Github: https://github.com/search?q=GH_COPILOT_TOKEN&type=code https://github.com/search?q=GH_COPILOT_TOKEN&type=code (My Copilot was broken and this was in the error output I was seeing, see: https://github.com/community/community/discussions/41878 https://github.com/community/community/discussions/41878) What I found there was some truly impressive reverse-engineering work by a single individual. I really like the "JOURNAL" daily-diary they kept of progress and random thoughts so you could see the progression day-by-day. -------- One thing I found interesting: The author says that it queries only the 20 recently most opened files of the same language. But in an AMA, I asked about how much "context" Copilot has available, and one of the devs says it can, for example, read header files that pair with C/C++ files that are open in separate tabs: https://github.com/orgs/community/discussions/29932#discussioncomment-3473154 https://github.com/orgs/community/discussions/29932#discussi... > "I assume Copilot uses the contents of the current project (IE, all files) as contextual information to offer suggestions. Is this the case?" > "Yes, copilot looks at what we call "related tabs", for example .c files are often paired with .h files, so copilot considers the contents of other tabs open in the editor to try to feed a more complete prompt to the model."
- thakkarparth007 4y agoHey Gavin, that's consistent with what I said in the blog post. Header files (.h) and (.c) files are classified as having the same language (C). As a result, if you have the header file open in a tab (or in the workspace -- I'm not sure if unaccessed files from workspace are used), then it'll be considered for the prompt.
- dj_mc_merlin 4y agoHuh, was this post revitalized? I remember seeing it (and upvoting it) in /new yesterday, but it didn't reach critical mass for the front page. Seems to be gone now.
- jjwiseman 4y agoYes, I think it was.
- modeless 4y agoFree idea for GitHub: a huge bit of missing context for the model right now is the last few edits made by the user. If you move your cursor to a different part of a long file, Copilot immediately forgets about that part of the file. If it knew the last few edits you did then it would be able to make much more intelligent suggestions based on the task you're working on, rather than just current cursor position.
- letitgo12345 4y agoNot sure how easy it would be to make work. Code edit data is not that prevalent. The best I can think of is looking at github commit changes. That's one place where Repl.it has a big advantage as it has live editing data from its users
- modeless 4y agoThey could start by simply including the code around previous cursor positions as additional context the same way they do with code from other files. Nothing specific to the edits themselves. That alone would help a lot I think. Maybe they already do but I don't think so based on the behavior I see, and this article doesn't mention anything like that. But Copilot is getting tons of live editing data from its users too, and soon should be able to construct a nice dataset of edits. There's no way they aren't already doing that.
- letitgo12345 4y agoYou would be taking snippets of code (that are potentially unparseable), concating them together and putting it in the prompt. The issue is that it would be kind of prompt the model has never seen before in the training data. Maybe it would work with some clever 0-shot prompt. But if you look at the fill in the middle paper from OpenAI for example, they specifically pretrain the model with that kind of data to make it work. The live data is gonna be useful though ya. Is Copilot allowed to use it though under ToS?
- 4y ago
- melony 4y agoWhy does “cushman-ml” suggest a 12B model instead of the 175B model?
- peaslock 4y agoThe model with the most similar name in this list is code-cushman-001 which is described as "Codex model that is a stronger, multilingual version of the Codex (12B) model in the paper". https://crfm-models.stanford.edu/static/help.html https://crfm-models.stanford.edu/static/help.html The next stronger Codex model is called code-davinci-001 which appears to be a fine-tuned version of the GPT-3 Davinci model which is known to have 175B parameters. The model naming is alphabetical in the order of the model size: https://blog.eleuther.ai/gpt3-model-sizes/ https://blog.eleuther.ai/gpt3-model-sizes/ See also A.2 here: https://arxiv.org/pdf/2204.00498.pdf#page=6 https://arxiv.org/pdf/2204.00498.pdf#page=6
- alextheparrot 4y agoCode is the base model in more recent iterations [0] [0] https://beta.openai.com/docs/model-index-for-researchers https://beta.openai.com/docs/model-index-for-researchers
- varunkmohan 4y agoMost likely latency and cost reasons. A model that's 10x as big requires 10x the hardware to serve at the same latency. Since most generations are not too long, a smaller finetuned model should work well enough.
- peaslock 4y agoAmazing if this is only a 12B model. If this already increases coding productivity by up to 50% (depending on kind of work), imagine what a 1T model will be capable of! I do wonder if some programmers at FAANG are already having access to a way more powerful coding assistants, and whether they code much at all at this point, or only make high level code specifications and then fix up the automatically generated code.
- gear54rus 4y ago'fix up generated code' but do you agree that finding a mistake (without even knowing if it's there) might be even harder than writing from scratch?
- PetahNZ 4y agoWe are doing this all the time anyway during code reviews.
- jrockway 4y agoIt's likely that programmers have this skill somewhere. We all make mistakes when typing in code, and many of them do get found. Some of them don't, that's what we call a bug. So AI isn't exactly breaking any ground here. I played with ChatGPT and asked it interview questions, and I thought it was a pretty interesting exercise to find its mistakes and get it to fix them. Good tool for training interviewers, perhaps.
- whazor 4y agoIn my eyes, the limitation of these models is that they only fit a limited amount of context. Not the complete API of your code base, or the latest version of the libraries you are using. I also don't believe a bigger model would resolve these limitations. However, I do believe there could be a meta model that can query code and libraries.
- IshKebab 4y agoPresumably if you had access to them you could fine tune them on your codebase.
- vbezhenar 4y agoMy biggest issue with Copilot is that it only wants to add code. That's useful but I edit code a lot. And if I have 10 similar lines and made one edit, it'd be very convenient for Copilot to suggest edit following line or even lines.
- ftufek 4y agoYou can look into Copilot Labs extension in vscode, it does the editing and bunch of other stuff too (like explain what the highlighted code does, etc). It's not as smooth, but it's getting there.
- varunkmohan 4y agoCurious, what functionality did you find the most useful? Sometimes on edits, I find it adding more than expected (potentially entirely new files) which causes me to not accept the suggestion. Explain does work well sometimes though!
- TillE 4y agoThat's interesting, even IntelliCode (generally less capable than Copilot afaik) will do exactly that. I've had it trigger a few times in C# recently, where I make one or two similar edits, and it prompts me to make more.
- albertzeyer 4y agoThis is about the VSCode extension, which is obfuscated (maybe compiled) JS. The plugin for IntelliJ (PyCharm etc), is this written in Java? Reverse compiling this might give some additional insights.
- fortenforge 4y agoTheir JetBrains plugin is written in Kotlin / Java but it spins up a agent server written in node.js which handles the business logic (building the prompt, caching, making completion requests to their API). I assume most of the code is shared between the VSCode extension and this javascript agent.
- bluelightning2k 4y agoJust wanted to say great job on the analysis and explanation!
- thakkarparth007 4y agoThank you! :)
- abraxas 4y agoHonestly I get more value out of ChatGPT than I do from Copilot even though both generate the wrong stuff now and then. But I like to describe the desired functionality by writing in plain English than trying to goad copilot in the right direction by coming up with method and variable names that copilot will "like"
- bibabaloo 4y agoHave you tried writing a comment as a prompt for copilot?
- thakkarparth007 4y agoYeah, I second what bibabloo said. Sometimes when I want to edit something, I comment out existing thing, and start writing what'd be the new version. Then copilot autocompletes what I have in mind (often enough).
- thakkarparth007 4y agoHeh this blew up here :D Didn't know till a friend told me about it. I'd love to know if you guys have any specific questions about copilot's internals that I can try to answer by staring at the code or if you have any feedback for the tool/post!
- 152334H 4y agoAny word on what the neovim plugin does? Considering some features like, > Then, most recently accessed 20 files of the same language are queried from VSCode. are probably not available by default in nvim? --- Also, do you think there's any chance you get in trouble for reverse engineering copilot?
- thakkarparth007 4y agoRE: neovim Looks like the 20 file logic is present in neovim as well. I went through its code (https://github.com/github/copilot.vim/blob/release/copilot/dist/agent.js https://github.com/github/copilot.vim/blob/release/copilot/d...) after beautifying it (https://codebeautify.org/jsviewer https://codebeautify.org/jsviewer), and found it present. I couldn't exactly trace it to a specific neovim event but I'm guessing it corresponds to buffer-update-events (https://neovim.io/doc/user/api.html#api-buffer-updates https://neovim.io/doc/user/api.html#api-buffer-updates) or something like that. Re: getting in trouble I surely hope not :P. I mean, the code is basically public (available on every user's computer).
- 152334H 4y agoInteresting, thanks.
- varunkmohan 4y agoThe neovim plugin mostly actually communicates with a node-js service seen here (https://github.com/github/copilot.vim/tree/release/copilot/dist https://github.com/github/copilot.vim/tree/release/copilot/d...). This is why they require you to install node for using the plugin and allows them to share logic with the vscode extension (also in javascript). I think all the features should be available even in neovim.
- oefrha 4y agoOne problem I’ve always had with Copilot is that it tends to introduce extra parentheses and braces. Say I already have a pair of braces for a function body, and Copilot decides to write the whole function, it will write everything including the closing brace, leaving me with an extra and a syntax error to fix. It really shouldn’t be that hard to tell I already have a closing brace, especially when they’re already considering the suffix.
- mulberrybush 4y agoI had to disable Copilot for Clojure because of this. Structural editing relies on parens being always balanced, and gets confused when Copilot re-inserts already existing closing parens.