How AI detectors work, and how far to trust them
AI detectors are now part of grading, hiring and publishing, and most people who rely on them have never been told what the number actually measures. This guide explains how detectors for code and text reach a score, what accuracy and false positive figures mean in practice, and how to use a score without letting it make the decision for you.
Checks every file against classmates, the web and AI, in 65+ languages.
The three approaches behind every AI detector
Products differ in packaging, but nearly all of them use one of three ideas, or a mix.
1. Predictability
A language model generates by choosing likely next tokens. Run the content back through a model and measure how expected each token was. Content that is consistently unsurprising, and uniform in rhythm, is more likely to be generated. Simple, fast and transparent, but easily confused by human writing that happens to be plain or formulaic.
2. Trained classifiers
Collect large sets of human and machine-written examples, label them, and train a model to tell them apart. The classifier learns features no one would list by hand. Its quality depends on the breadth and freshness of the training data and on how it is calibrated.
3. Watermarks
The model provider deliberately biases generation in a detectable way. Strong evidence when present, but only for providers that apply one, only if the reader has the key, and weakened by paraphrasing or rewriting.
Not an approach: source matching
Plagiarism checking finds the original a piece was copied from. Generated content has no original, so AI detection cannot point to one. That is the root of most of its limits. See how plagiarism checkers work for the contrast.
What the number on the screen actually is
Two detectors can show "72%" and mean entirely different things. Before using a score, find out which of these it is:
- A probability for the whole piece. How confident the model is that the content as a whole was generated. A 72% here is a statement about the detector's confidence, not about how much of the work is AI.
- A proportion of the content. The share of sentences, lines or blocks judged generated. 72% here means roughly three quarters of the content was flagged, each part with its own confidence.
- A banded label. "Likely AI", "Mixed", "Likely human". Easier to read, and honest about precision, but it hides how close a result was to the boundary.
None of the three means "72% likely that this person broke the rules". Whether a rule was broken depends on what was allowed, which no detector knows.
A detector that shows its reasoning, by highlighting the passages behind the score and naming the features that drove it, is far more useful than one that shows only the number, because the reader can check the reasons against the content. Codequiry's AI results for code list their reasons and mark the flagged code for this purpose.
Accuracy, unpacked
"99% accurate" is the most common claim in this market and among the least informative. Accuracy blends two different errors, and they have very different consequences.
| Term | Meaning | Who it hurts |
|---|---|---|
| False positive | Human work flagged as AI | An honest author, who now has to defend their own work |
| False negative | AI work passed as human | The integrity of the assessment, and the honest authors marked alongside it |
| Precision | Of everything flagged, how much really was AI | Tells you how often a flag is wrong |
| Recall | Of all AI work, how much was flagged | Tells you how much slips through |
A detector can be "99% accurate" on a test set that is 99% human-written simply by saying "human" every time. The figures that matter are the false positive rate and the recall, measured separately, on content like yours.
Then there is base rate. If 2% of a class actually used AI against the rules and a detector has a 1% false positive rate and catches 90% of AI work, a class of 300 produces about 5 true flags and about 3 false ones. More than a third of the flags are wrong, even though every individual figure sounds excellent. The fewer real cases there are, the larger the share of flags that are mistakes. This is the single most important reason a flag must start an inquiry rather than end one.
Thresholds and trade-offs
Every detector turns a continuous score into decisions by choosing where to draw a line. Raise the line and fewer honest authors are flagged, but more AI work passes. Lower it and the reverse. There is no setting that eliminates both errors, only a choice about which matters more.
For assessment of people, the defensible choice is to keep false positives low and accept that some AI work will pass undetected, then catch more of it through assessment design and conversation. Codequiry's AI detection is tuned that way: it would rather miss a borderline case than flag an honest one.
Thresholds used for decisions should also be published. Codequiry's report, for example, states openly that a Certificate of Originality requires under 60% of the code to read as AI-written, alongside under 30% matched elsewhere. Whatever the number, the reader can see the rule. See code examination reports.
AI detection for code is a different problem from text
A detector should be trained on the kind of content it judges. Code and prose differ in ways that break detectors built for the other.
- Code is predictable by design. Syntax, idioms, style guides and formatters push all code toward regularity. A text detector reads that regularity as machine writing and flags nearly everything.
- Code has features prose lacks. Structure, control flow, naming conventions, error handling, comment density and how a solution is decomposed all carry signal. A code detector can use them; a text detector cannot see them.
- The tools differ. Code is generated by chat assistants and also by inline completion and agents, which mix human and generated lines in one file. Text is mostly generated in whole passages.
Codequiry's detector is trained on source code and used only on source code. It is switched off for essays and written answers, which Codequiry checks for copying instead. More on each: how to tell if code is AI generated and ChatGPT detectors for essays.
AI detection built for code
A likelihood for each file with its reasons, next to a search of classmates, the web, GitHub and Stack Overflow.
Questions to ask before trusting any AI detector
- What does the score measure? A probability, a proportion or a band? For the whole piece or for parts?
- What is the false positive rate, and on what data? Ask for it separately from overall accuracy, and ask whether the test content resembles yours: language, length, level, genre.
- Which models was it tested against, and when? A detector last evaluated two model generations ago may not hold up.
- Does it show reasons? Can you see which passages or features drove the result?
- Is it built for this content? A prose detector applied to code, or the reverse, is not a meaningful test.
- What does the vendor say it should be used for? A responsible vendor will tell you it should not be the sole basis for a decision. Be wary of one that does not.
Using AI scores fairly
The institutions that handle AI cases well share a few habits:
- A written policy on AI use for each course or role, including what must be disclosed. The collaboration policy template has wording you can adapt.
- The same check for everyone in a class or hiring round, so no one is singled out by suspicion.
- A score opens a review; the review decides. Flagged content, earlier work, process evidence and a conversation with the author.
- The author sees the evidence and has a real chance to respond.
- Records of what was relied on, so a decision can be reviewed on appeal.
Used this way, a good detector saves enormous amounts of reading time and surfaces cases a person would miss. Used as a verdict, even an excellent one will eventually harm someone who did nothing wrong.
Frequently asked questions
How do AI detectors work?
They estimate how likely it is that a model produced a piece of text or code, from how it is written. Some measure how predictable each word or token is to a language model; others are classifiers trained on large sets of human and machine-written examples; a few look for watermarks a provider deliberately embedded. All of them return a likelihood, not a match to a source.
Are AI detectors accurate?
Good detectors are useful, but none are certain. Accuracy depends on the content type, length, language, the models involved and how much the output was edited. A single accuracy figure hides the trade-off between catching AI text and wrongly flagging human text, which is the number that matters most for fairness.
What does a 70% AI score mean?
It depends on the detector. In some tools it is the share of the content judged AI-written; in others it is the model's confidence that the whole piece is AI-written. Neither means "70% certain this person cheated". Check what your tool's number measures before using it.
What is a false positive in AI detection?
Human-written work wrongly labelled as AI-generated. False positives are the errors that hurt people, so they should be kept low by design, and any process that uses AI scores should assume some will occur.
Why is AI detection for code different from AI detection for essays?
Code and prose have different statistics. Code is formulaic by nature, so text detectors misread it, and features that matter in code, such as structure, error handling and naming, do not exist in prose. A detector should be trained on the kind of content it judges. Codequiry's detector is trained on code and is not applied to essays.
Can AI detection be fooled?
Yes. Paraphrasing, heavy manual editing and prompting a model to imitate a particular style all lower scores. That is why a low score is not proof of human authorship, and why detection works best alongside process evidence and a conversation with the author.
Should an AI score be used as evidence of misconduct?
Only as one part of the evidence, and never alone. Use it to decide where to look, then rely on the flagged content itself, the author's earlier work, process evidence and the author's explanation.
An AI score with its reasons
Codequiry flags AI-written code with the passages and reasons behind each result, tuned to keep false positives low.
Start a check Pay as you go with credits. Comparing files is free.