How To Detect AI-Generated Code with CodeLeaks (2024)

With LLMs running rampant in education, teachers are forced to adapt by implementing AI detection tools into their arsenal. However, most AI detectors only extend to text, but we all know that there’s more than one kind of assignment.

For instance, what about code?

No worries — CopyLeaks has teachers covered with their feature called CodeLeaks. The only question is, how accurate is it actually? That’s what we’ll discuss in this article, along with how to use CodeLeaks and my overall opinions about it. Stay tuned!

What is CopyLeaks?

CopyLeaks is a platform made to ensure AI misuse and plagiarism gets contained to a minimum. It’s a suite of tools that utilizes advanced algorithms and emerging technologies to dissect text, documents, and even code.

How To Detect AI-Generated Code with CodeLeaks (1)

True to their slogan of “Empowering Originality and Inspiring Authenticity,” CopyLeaks’ most popular features are their plagiarism checker and AI content detector. We’ve tested the latter using our own dataset and found it to be 75% accurate in true positive tests (beating the likes of Content at Scale and Originality) and 80% in false positive tests (which is the second highest score across eight detectors).

What is CodeLeaks?

CodeLeaks is a specific feature of CopyLeaks that targets plagiarized code either from pre-existing codebases or an LLM. Every code input will generate a full report complete with a highlight on copied code and where they’re from, percentage plagiarized, and more. We’ll dive deeper into this later.

How To Detect AI-Generated Code with CodeLeaks (2)

How To Detect AI Code Using CodeLeaks?

Step #1: Create An Account

To start detecting code using CodeLeaks, you need an account. Simply head to their dashboard, and then select the “Login” or “Create Account” button on the top-left side of the screen.

How To Detect AI-Generated Code with CodeLeaks (3)

Step #2: Upload Your Code

Now, you should have full access to their dashboard. To confirm, you should see these six choices on the center of your screen. From there, select the “Code” option.

How To Detect AI-Generated Code with CodeLeaks (4)

Once you’re in, simply drag a code file into the dashboard and all that’s left to do now is the last step.

Step #3: Get A Detailed Report

Before we proceed, let me generate a Python code using ChatGPT and save it as a .py file. So, I asked ChatGPT to create a code based on Fizzbuzz, a popular Leetcode question.

The exercise goes like this: You need to efficiently print all numbers from 1 to 100, but for multiples of 3, there must be a “FIZZ” instead of the number; for multiples of 5, there must be a “BUZZ,” and for multiples of both, the output must be “FIZZBUZZ.”

Here’s what ChatGPT gave me:

How To Detect AI-Generated Code with CodeLeaks (5)

Let’s save that as a .py file and upload it to CodeLeaks. Here’s the output:

How To Detect AI-Generated Code with CodeLeaks (6)

Compared to code plagiarism analysis, AI code analysis only gives you one key information about the input: the percentage likelihood that it came from an AI.

How Accurate is CodeLeaks?

Now that you know how CodeLeaks works, it’s time to test and find out how accurate it is at detecting AI code. This test will be divided into two parts: true positive and false positive. The latter is for AI-generated code, while the latter will measure if CodeLeaks can detect human code. So, without further ado…

True Positive Tests

Test #1 — AI successfully detected!
AI Likelihood Score: 100%

How To Detect AI-Generated Code with CodeLeaks (7)
How To Detect AI-Generated Code with CodeLeaks (8)

Test #2 — AI successfully detected!
AI Likelihood Score: 100%

How To Detect AI-Generated Code with CodeLeaks (9)
How To Detect AI-Generated Code with CodeLeaks (10)

Test #3 — AI successfully detected!
AI Likelihood Score: 100%

How To Detect AI-Generated Code with CodeLeaks (11)
How To Detect AI-Generated Code with CodeLeaks (12)

Test #4 — AI successfully detected!
AI Likelihood Score: 100%

How To Detect AI-Generated Code with CodeLeaks (13)
How To Detect AI-Generated Code with CodeLeaks (14)

Test #5 — AI successfully detected!
AI Likelihood Score: 100%

How To Detect AI-Generated Code with CodeLeaks (15)
How To Detect AI-Generated Code with CodeLeaks (16)

False Positive Tests

Test #1 — Failed, AI detected in human content.
AI Likelihood Score: 100%

How To Detect AI-Generated Code with CodeLeaks (17)

Test #2 — Human content successfully detected!
AI Likelihood Score: 0%

How To Detect AI-Generated Code with CodeLeaks (18)

Test #3 — Human content successfully detected!
AI Likelihood Score: 0%

How To Detect AI-Generated Code with CodeLeaks (19)

Tallied Score and Thoughts on CodeLeaks’ Accuracy

Test

Detected?

True Positive #1

Successful

True Positive #2

Successful

True Positive #3

Successful

True Positive #4

Successful

True Positive #5

Successful

False Positive #1

Failed

False Positive #2

Successful

False Positive #3

Successful

Total

7 out of 8

I didn’t expect CodeLeaks to be this accurate, but it is. Despite having one false positive result, the fact that it successfully detected the sample data as AI or human 7 out of 8 times is a remarkable feat on its own. What’s more is that CodeLeaks was absolutely certain (0% or 100% AI likelihood scores) of their analysis, which mostly turned out to be correct.

It’s also interesting to see that CopyLeaks seems to be more accurate in detecting AI in code than traditional text. I believe that comments play a huge factor in these results, as the only thing that the AI-generated codes and the one false positive test had in common was an abundance of comments and annotations.

The Bottom Line

In a world where AI detection receives so much scrutiny, CopyLeaks continues to not disappoint. We already know that it’s a capable AI detector for text, but who knew it was this good at detecting AI code too?

It’s a good sign that AI detection, whether it’s text or code, is heading in a more positive direction. OpenA caught flack for saying that detection isn’t reliable, even though they were absolutely right. But now, AI detection tools are evolving along with LLMs — and CopyLeaks might be at the forefront of that change.

Want to learn more about CopyLeaks? You can read more about it in our articles like this one. Good luck!

Want To Learn Even More?

If you enjoyed this article, subscribe to our free monthly newsletter
where we share tips & tricks on how to use tech & AI to grow and optimize your business, career, and life.

#AI #Copyleaks

How To Detect AI-Generated Code with CodeLeaks (2024)
Top Articles
Latest Posts
Article information

Author: Ouida Strosin DO

Last Updated:

Views: 6337

Rating: 4.6 / 5 (76 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Ouida Strosin DO

Birthday: 1995-04-27

Address: Suite 927 930 Kilback Radial, Candidaville, TN 87795

Phone: +8561498978366

Job: Legacy Manufacturing Specialist

Hobby: Singing, Mountain biking, Water sports, Water sports, Taxidermy, Polo, Pet

Introduction: My name is Ouida Strosin DO, I am a precious, combative, spotless, modern, spotless, beautiful, precious person who loves writing and wants to share my knowledge and understanding with you.