29

I am seeking some clarification around the policy of not allowing AI-generated content on Stack Overflow, specifically in relation to the use of GitHub Copilot (and, I suppose, similar AI tools which are specifically built to assist with software development, rather than more general purpose large language models). I understand, and broadly support, the reason for introducing the policy - Stack Overflow is a fantasically useful resource, and we don't want people lazily filling it up with confident sounding but misleading or downright wrong AI slop. However, since I've started using Copilot, I'm no longer sure whether I'm able to post answers to Stack Overflow without violating the policy.

First, I'd like to describe the role that Copilot plays in my workflow.

I have been employed as a software developer for over 20 years now. Last year, my employer adopted Copilot and made it available to all of us developers, along with plenty of training on how to make the best use of it. I've been using it, mostly the flavour which is integrated into Visual Studio, for maybe 9 months now, and I've been so impressed with it that I've even bought a subscription with my own money for my own personal use.

The Copilot feature that I use the most is the inline code suggestions - I start typing (for example) a method signature and then a block of grey text (being Copilot's prediction of what I might be about to type next) appears, and I can press tab to accept the suggestion, or I can ignore it and carry on typing. Sometimes the suggestion is completely wrong, not what I was intending, or doesn't even compile. But often it's close enough to what I was about to type that it's quicker for me to accept the suggestion and then edit it than for me to type it myself. And I'm an experienced enough developer to be able to tell the difference. Copilot, for me, is a productivity tool. It is absolutely not (and I always emphasise this point when talking with non-technical colleagues about it) a substitute for knowing how to write code, or for having an understanding of the problem domain that the code is to be used for.

So now I've got a chunk of code, some of it was typed by me, some of it was suggested by Copilot, and maybe edited by me afterwards.

Did I write that code? I'll leave that question to the philosophers.

Am I responsible for that code? Hell yeah, even if I didn't type every single character, I'm still responsible for it. It's my name on the pull request, and if a code review determines that the pull request isn't up to scratch then it's up to me to fix it. And if some dodgy code with my name on the pull request somehow makes it into production and causes a problem, it's my neck on the line, I can't just blame the AI. And rightly so, I'm still responsible for doing the thinking, understanding the codebase, and making sure that the solution as a whole is fit for purpose. If I don't understand the code that Copilot has suggested then I dive into the documentation and research it (and maybe ask the Copilot chat to explain it, but I never treat the response as gospel) until I do understand it, just the same as I would with some code I've copied from SO which appears to solve my problem but which I don't yet understand.

Consider the scenario. I see a question on SO which doesn't have an answer yet, and I understand the question and write an answer, and I include some code to illustrate the answer. I didn't ask Copilot to answer the question for me - if I needed to do that then it's a strong sign that I'm the wrong person to post an answer. But it's likely that some of the code I include in my answer was originally suggested by Copilot, although you can be sure that I'll have tested it to make sure that it works as intended.

Would that answer be a violation of the policy? Reading through Policy: Generative AI (e.g., ChatGPT) is banned and all its answers, this use case isn't explicitly covered.


Related discussions

I don't believe this question is a duplicate of Should we flag human-written questions that use code generated by ChatGPT?, because that question is about whether it's OK to ask questions about AI-generated code, whereas my question is about whether it's OK to use use code which may have been suggested by Copilot, but which I understand and know works correctly, to illustrate an answer to a question.

I also don't believe this is a duplicate of Is it acceptable to post answers generated by an AI, such as GitHub Copilot? [duplicate] because that question specifically calls out the fact that the answer being discussed says that

This code was written by Github Copilot with minimal supervision

And raises the following potential problems which may arise from this

  • user submitting such an answer might not be able to reason about the answer at all
  • there is high rate of incorrectness with Copilot generated code
  • does the user even have the rights to submit such code into Stack Overflow

I'll admit that the third bullet point may be problematic, but the rest of that question doesn't really apply to the situation I'm asking about, because I wouldn't be asking Copilot to generate an answer, I'd be writing an answer myself, based on my own experience gained from working with the subject matter in the question (so I'd be able to reason about it), and illustrated using some code that I'd part typed myself and part accepted from Copilot suggestions (and of course tested) whilst gaining that experience.

Maybe it would help if I provide some background to the answer I'm thinking of posting, which prompted me to ask this question. I was looking for a way to add particular functionality to an application, and found an answer containing the key knowledge that I needed to get started, but which I feel is an incomplete and not very flexible implementation. Since then I've incorporated it into a class library which I was writing anyway, and extensively refactored it for ease of unit testing and extensibility, we're talking about a number of weeks work here, and I thought it would be helpful to add another answer showing the improvements I've made and the thinking which led me to make them. In this case the code wasn't written specifically for an answer, and that's why I couldn't tell you now which lines I typed and which ones were suggested by Copilot.

11
  • 14
    My understanding is that "All use of generative AI is banned" - there is no room for nuance in the wording. However, the use of AI assists is becoming more and more common with even experienced developers. I would certainly like some nuance, but its hard to introduce a gray area and still be enforceable on bad actors. "AI is ok but only if you checked it" is not a good enough policy. Commented Apr 6 at 16:39
  • 11
    We just want code that you write. What you describe with CoPilot and the way you use it ... that's your code. You get a suggestion for a line of code, and, if it looks wrong you don't use it. I don't see a problem with it, and more practically, there's no way anyone would detect whatever machine intelligence there might be behind it. You're really just asking for someone's blessing. If it's good enough for you, you have mine. Commented Apr 6 at 17:14
  • 6
    “Would that answer be a violation of the policy?” It absolutely would. In the amount of time you take to verify the AI generated garbage you could just write the code yourself. I don’t have much faith in the inline suggestion code, having seen it wrong more times then it’s right Commented Apr 6 at 22:36
  • 7
    "Did I write that code? I'll leave that question to the philosophers." -- Is this a Ship of Theseus situation? Commented Apr 7 at 2:58
  • 3
    "But it's likely that some of the code I include in my answer was originally suggested by Copilot, although you can be sure that I'll have tested it to make sure that it works as intended." If there are some small snippets of code written by Copilot in sense that it was used as a more powerful code completion, and you use such code snippets from your own codebase, then posting such code is most likely fine. But this is somewhat gray area and it is always possible that for some larger chunks of code you may end up with recognizable AI code which will be flagged as such. Commented Apr 7 at 11:10
  • In any way, taking some small pieces of your existing code and tailoring it for some question is one thing, but using Copilot for completion when writing answer directly might be a completely different story. Also if the completed code falls into some common "template" category which only outlines some common workflow where basically most of the developers would write very similar or identical code as there are not too many different ways to write it, then it is OK. But for the rest of the code, you basically don't know from where it originated and this opens up a whole different can of worms. Commented Apr 7 at 11:18
  • 4
    This question is similar to: Should we flag human-written questions that use code generated by ChatGPT?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Apr 7 at 20:58
  • "But it's likely that some of the code I include in my answer was originally suggested by Copilot..." If you write code for every answer new, you would probably know exactly if you used Copilot and could say for every answer exactly what part is your own and what part is from Copilot. Or do you look up code when answering? Commented Apr 8 at 5:31
  • 3
    @philipxy This question, while similar to the target, is specifically about answers, and the target (and its answer) is specifically about questions. As such I don't think they're duplicates. Commented Apr 8 at 13:18
  • 3
    This question is similar to: Is it acceptable to post answers generated by an AI, such as GitHub Copilot?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Apr 8 at 19:00
  • 1
    My 2cts: A Title that might convey your "intention" a bit better maybe...: "Can I use auto-complete Copilot-suggested code snippets that I've verified?" (=> mentioning "auto-complete" in the Title already, that the "essence" of your Question/Workflow), and "Auto-complete" has existed long-long before AI became a "scary-hype" (more than 20 years)... Commented Apr 9 at 0:11

4 Answers 4

17

My understanding is that yes, you can post that code. If you don't feel comfortable claiming it all as your work, you can specify that it was created with the help of Copilot. It's different from using ChatGPT (or other LLMs such as Copilot Edits) to come up with the entirety of the answer. You are still sharing your knowledge and your way of doing things. The explanation of that code must be your own words.

3
  • 8
    If some small snippets of user's existing codebase are written by Copilot where it was only used for code completion then saying Copilot was used would only backfire. There are more than single tool that is called Copilot and some pretty much fall into not allowed category. Having said that, in general I would not say that using any LLM as code completion is allowed as this can be too broadly interpreted and again used as excuse for planting AI generated content on site. Commented Apr 7 at 11:07
  • 10
    I'm slightly confused by this answer. Not that I want to argue that it's not sensible policy but it seems to deviate from the original decision that no AI generation help is valid under any circumstances even only in part or indirectly. Here the argumentation seems to be more like, it's not the whole post and the author understands the code so it's fine. As far as I remember this didn't play any role in the original ban reasoning. Can it maybe be clarified a bit more how this interacts with the original ban of AI generated content? Commented Apr 8 at 5:23
  • 7
    @NoDataDumpNoContribution you have hit the nail squarely on the head - that's exactly the sort of clarification I'm seeking Commented Apr 8 at 21:15
8

The spirit of the rule is that the code is expected to completely reflect your own thought process, and you have appropriately verified it yourself before posting. The Copilot use pattern you describe sounds perfectly fine to me; it's not really different from a traditional IDE autocomplete feature, it's just more sophisticated.

Of course, in answers you should ensure that the code corresponds to the question code where it makes sense to do so (unless it's clear that you're making a new example and have a good pedagogic reason to do so); and in questions you'll need to make a proper MRE anyway, so you may as well take the time to simplify and anonymize the code - and in these situations it's a bit hard to imagine that AI code completion tools are especially helpful, or that their effect would be detectable in the final result.

And, of course (and to reiterate Dharman's answer) the prose of your questions and answers is a whole other story.

2
  • 3
    "it's not really different from a traditional IDE autocomplete feature" That's one possible way to describe GenAI as just a sophisticated auto completion. CoPilot is still also AI? Commented Apr 8 at 5:26
  • 2
    @NoDataDumpNoContribution The poster said "traditional" & moreover you used "sophisticated". So, not a reasonable "possible way". Commented Apr 8 at 21:36
6

I think your usage is sensible and okay, if only because otherwise we might at some point run out of expert answerers (more and more people use AI tools).

However, contrary to other answers, I don't think that this usage would be covered by the existing ban on the use of generative AI. It would clearly violate this ban and it would need to be modified before.

To me, the ban reads quite categorically: "All use of generative AI (e.g., ChatGPT1 and other LLMs) is banned when posting content on Stack Overflow.". Github Copilot is generative AI and basing your code on Github Copilot output can only be seen as use of generative AI in my eyes, therefore there is no grey zone, it's simply not possible under the current rules.

Something has to give. Either we cannot use generative AI at all or there are circumstances where we can and the ban needs to be adapted.

Some kind of: if you understand everything and checked everything and always maintain "creative" leadership of the whole process it's okay, was proposed right from the beginning. It was also clear that SO cannot stop generative AI from getting more and more widely used to the point that a blanket ban would severely limit our ability to create new content. It was only a matter of time.

But are there pitfalls? Yes, there are. Some words of caution. Understanding code of others (including the output of a tool) is necessary but not sufficient to create high-quality programming knowledge. Additionally it is important to have an overview over the topic, to be able to compare alternatives and in general to optimize code. Copilot or other such tools could make programmers over-confident, letting them forget to check alternatives or adapting and optimizing the output of such tools. I don't say you do or that Copilot isn't perfect for you. My observation in my small area is that Copilot suggestions tend to result in slightly more complex code than necessary. In one case I ended up with a proposal of 60 lines of code just to include one obscure edge case, which I decided to go against and use 3 lines instead and deal with the edge case in another way.

So I take it that the categorical ban on generative AI use is history and is replaced by "if you checked, verified and adapted every bit of the code, checked and reformulated every single word or character of the text and if you really are an expert in the topic and if you invested a lot of your own time, explored alternatives, and can honestly say that you are convinced that this is the best practice and others should follow you there", then by all means go for it.

And finally, for generating truly new knowledge, i.e. answering the really hard to answer questions that would be useful to be answered, Copilot or others might not give much useful output. It's also a useful skill to recognize when Copilot doesn't solve a problem and one needs to resort to human help, which can be found here.

7
  • "and in general maintain "creative" leadership", => shouldn't it rather be "always" instead of "in general"...? "in general" sounds like introducing (back) a grey area, I would think... Commented Apr 9 at 17:35
  • 1
    @chivracq It's not meant as a backdoor, more like acknowledging realities. You don't have full control over the Copilot output. You work with what is offered. Therefore you will never have full creative control. The idea was to convey that the broad strategy is yours, but the details may not completely. However changed to always. Commented Apr 9 at 18:05
  • 1
    I'm wondering now whether I should have framed the question in terms of "should the rules be changed to allow this?" rather than "am I allowed to do this?" Commented Apr 9 at 19:14
  • 2
    @sbridewell Why? All answers say you are allowed to. What more do you want? Also, all these rules discussions tend in my eyes to get bogged down in details too much. It's easier and more interesting to talk about what should be the best case and where possible risks are, not to write legislation. If you know what a good answer is and what a bad answer is, you know how exactly and where AI should or shouldn't be used. Highest quality of content is the goal. The rest follows from that. Commented Apr 9 at 19:36
  • 5
    The policy, if interpreted fully literally, produces an absurd result. Interpreted literally, it would mean a user who asks an LLM how to do something as part of researching the problem is banned from ever answering the question, even if they were just using it to, say, locate documentation resources, then subsequently wrote all code and prose fully themself, because there was "use of generative AI ... when posting content on Stack Overflow." That was never what the policy meant. Commented Apr 10 at 9:17
  • 3
    @RyanM I always kind of interpreted it that way, but I also felt that I'm overstepping the general ban somewhat. I remember quite a number of posts actually arguing towards a more pragmatical and less strict approach towards GenAI, but I also remember they were all downvoted heavily. People really meant it that strictly. Look at all the answers to the original ban. My slight discomfort comes from us not acknowledging that it was already pointed out two years ago, that a general and literal ban is neither good for the network nor viable. I want to give credit there. Commented Apr 10 at 9:59
  • 2
    What more do I want? On reflection, the serenity to not answer when I shouldn't, the courage to answer when I should, and the wisdom to know the difference. And yes, that can only come from myself. Commented Apr 10 at 16:13
5

I agree with the other answers that what you describe should be allowed, based on the rationale for the AI policy (and thus, I will not restate what they've already said). I'm writing separately to help clarify, at least somewhat, where the line is, lest those be misinterpreted as something like "LLMs may write code but not prose", "in-IDE LLMs are always allowed no matter how they're used", etc.

What would definitely not be allowed would be something like:

try this:

def frob_widget(widget_to_frob, foo, bar):
  """Frobs the specified widget.  If bar is not nil, it is used as the frobber's context."""
  # [hit tab and fill in Copilot code here, then submit answer]

Despite the fact that the LLM didn't literally write the entire answer, nor any explanation, this process (which is very different from the process you describe) still has all the problems with wholly LLM-generated code, including hallucinations. Unlikely with what you describe, there's substantially no human input or verification here, and substantially the entire code was written by an LLM, with the function signature essentially being a restatement of the question for the LLM.

There are certainly gray areas in between these two extremes. Drawing the line in exactly the correct spot is hard, and may require a bit of trial and error as moderators and the community see what sorts of things appear to be problematic.

3
  • 6
    All Answers starting with "Try this:" should anyway always have gotten an automatic -1 from Day_1, 15+ years ago... Commented Apr 9 at 1:10
  • 3
    @chivracq Only if they start with "Try this:" and then only contain code afterward, with no other explanation. I don't want to unfairly impugn the honor of answers which start that way but then go on to provide thorough explanations :-) Commented Apr 9 at 15:21
  • 2
    @TylerH Yeah-yeah, that's what I meant indeed also... But generally, when somebody is "confident" enough about the Code they post in their Answer (from experience or from testing it for that specific Question) and takes the effort to explain what it does, they won't be using "Try this..." which undermines directly the "solidity" of their Answer... Commented Apr 9 at 15:35

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.