How a TA Reads a Code Similarity Score Before Acting

A code similarity score is the percentage of one submission's code fingerprints that also appear in another. It is a measure of overlap, not of intent. A 100% match and a 40% match can both be innocent, and the only reliable way to tell them apart is to open the matched blocks and read the source.

What a code similarity score actually measures

Every serious tool in this space does roughly the same four things. It strips comments and whitespace. It tokenizes what remains, usually normalizing identifiers so that total and sum both collapse to the same placeholder. It breaks the token stream into overlapping k-grams, hashes each one, and keeps a subset of those hashes as a fingerprint. Then it intersects two fingerprints and divides by something.

The subset selection is where tools diverge. MOSS uses winnowing, the algorithm from Schleimer, Wilkerson and Aiken's 2003 paper: slide a window of size w across the hashed k-grams and keep only the minimum hash in each window. Winnowing gives a useful guarantee. If two documents share a run of at least k + w - 1 tokens, at least one shared fingerprint survives. JPlag has historically relied on greedy string tiling over tokens, which finds maximal common substrings and then marks those tokens as used. Dolos uses a fingerprinting approach in the same family as winnowing.

Here is the pipeline on a five-line Java method, with k set to 5:

public static int sum(int[] a) {
    int t = 0;
    for (int i = 0; i < a.length; i++) t += a[i];
    return t;
}

// token stream, identifiers and literals normalized
public static int ID ( int [ ] ID ) { int ID = NUM ;
for ( int ID = NUM ; ID < ID . length ; ID ++ )
ID += ID [ ID ] ; return ID ; }

That stream is around 40 tokens, so there are roughly 36 five-token k-grams, and after winnowing with w = 4 you keep somewhere in the neighborhood of nine fingerprints. Rename every variable in the file and regenerate the stream: the fingerprints do not move, because the identifiers were already normalized away.

The denominator is the part students and instructors argue about. Some tools report matched tokens over the smaller file, some over the larger, some over the union. A 60-token shared block inside a 90-token file reads as 67%. The same block inside a 400-token file reads as 15%. Same copying, different number, and neither number is wrong. They just answer different questions.

Why a 100% match can mean nothing at all

Boilerplate is the first thing to rule out. An intro Java assignment that opens with a Scanner and a main signature, or an assignment that ships with a provided Node class and a test harness, will produce very high scores between submissions that share nothing but the scaffolding the instructor handed out.

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // student work starts here
    }
}

Six of those seven lines are fixed. On a short file, that is enough to push the percentage past 80 before anyone has written a loop. The fix is procedural, not algorithmic: run the check against the starter repository itself and against an empty solution before you run it against the cohort. Whatever score the scaffold produces is your floor, and every number in the report should be read relative to it.

Generated code is the second source of false alarms. IDE-generated getters and setters, Lombok annotations, and framework scaffolding all converge on identical text because they come from a generator, not a person. If the assignment is a Spring controller or a React component, expect a baseline of structural similarity that has nothing to do with copying.

Side-by-side code comparison in Codequiry showing a 91% match between two student submissions
Side-by-side comparison: Codequiry lines up matching code between two submissions, with confirmed and false-positive review labels.

Why a 34% match can be the real problem

Now run the logic the other way. A low score is an average over a whole file, and copying is rarely uniform. Say two 400-token submissions share one 55-token block that contains a distinctive, slightly wrong approach to a problem: the same off-by-one guard, the same unusual helper name, the same early continue in the same position. Fifty-five tokens out of four hundred is under 15% of the file, and it will sit at the bottom of a report sorted by score.

// Submission A
int total = 0, count = 0;
for (String line : lines) {
    if (line.isEmpty()) continue;
    count++;
    total += line.length();
}
double avg = (double) total / count;

// Submission B
int sum = 0, n = 0;
for (String s : lines) {
    if (s.length() == 0) continue;
    n = n + 1;
    sum = sum + s.length();
}
double mean = sum / (double) n;

Everything is renamed. One statement is rewritten. The shape is identical, down to the division order in the last line, which is the kind of detail students rarely converge on independently. A token tool will report a modest number here because the surrounding code differs. A reader who sorts by percentage and stops at the top twenty will never see it.

Sort by the length of the longest matched block, not by the overall percentage. The percentage tells you how much of the file overlaps. The longest block tells you whether there is anything worth reading.

Where the winnowing parameters hide a match

With k = 5 and w = 4, the guarantee threshold is eight tokens. Any shared run shorter than that can slip through undetected, and tools tune these parameters differently depending on language. In a language where a single logical step spans many tokens, like Java or C++, eight tokens is a fragment. In Python, where a whole operation fits in three tokens, eight tokens is a meaningful line.

The noise threshold matters just as much. Fingerprints that appear in a large fraction of the corpus get discarded so that if (x == null) return; and for (int i = 0; i < n; i++) do not drown the report in false positives. That filtering is correct on average and wrong in specific cases, particularly when the copied fragment happens to be a common idiom. A student who pastes one common pattern from a classmate gets no signal. A student who pastes four in a row usually does.

The practical consequence is that no single run is authoritative. If you have reason to suspect copying on a short or heavily scaffolded assignment, re-run with a smaller k and a lower noise threshold, or compare at the AST level, and see whether the picture changes.

When refactoring drops the number but not the copying

Renaming and reformatting are free. Token-based tools normalize them away, which is why the first thing a student tries after being caught is cosmetic. The transformations that actually move the score are structural, and they are worth understanding because they are also the ones that can be legitimate.

// Submission A
for (int i = 0; i < n; i++) {
    total += data[i];
}

// Submission B
int i = 0;
while (i < n) {
    total += data[i];
    i++;
}

Converting a for to a while changes keywords and statement order, so the k-gram overlap collapses and a purely token-based comparison reports a much lower score. An AST comparison still sees a loop whose body accumulates the same array element into the same variable under the same bound. Extracting a method, unrolling a loop, or replacing a loop with a comprehension or a stream pipeline does the same thing to the number while leaving the control flow and the order of operations intact.

This is where tools that compare only the token stream stop being enough, and where a checker that layers token fingerprints, AST structure, and per-file similarity earns its keep. Our own source code plagiarism checker reports those signals separately rather than blending them into one opaque figure, because the disagreement between them is often the most informative thing in the report.

Reading the report in the right order

A TA who has done this a few hundred times reads in a fixed order, and the score is not first. Start with which files matched, because a match between two test files is usually the instructor's own harness. Then look at the longest matched region and its token count: a 12-token match is a shared idiom, a 60-token match is a shared function, and a 200-token match is a shared file. Then open the side-by-side view and look for identifier divergence inside an identical structure, which is the signature of an attempt to disguise. Finally check whether the matched region falls inside code that both students were given.

Codequiry peer similarity report with a risk distribution and a smart review queue ranking cohort outliers
The peer report: a class-wide risk distribution and a smart review queue that surfaces the strongest outliers first.

If all four checks clear, you have a case worth a conversation. If any of them points to scaffolding or to a single common idiom, you probably do not.

Setting a review threshold for a specific course

There is no universal number, and any vendor who quotes one is guessing about your assignment. What works is a baseline. Run the check against the starter repository, against two or three of your own reference solutions, and against the previous semester's submissions if you keep them. Note where the innocent distribution sits. On a 60-line assignment with 15 lines of scaffolding, scores often cluster below 30 and anything above 50 is worth opening. On a 400-line assignment with a provided framework, a match of 60 might be entirely normal and the threshold has to move up. (Courses also vary in how much collaboration they permit, which changes the threshold as much as the code does.)

Set the review threshold, not the accusation threshold. The number determines which reports you open, and nothing else. Everything after that is a human reading source code.

Peer similarity, web match, and AI score are three different numbers

Reports increasingly show three figures side by side, and they do not share a scale. Peer similarity is a fingerprint overlap, bounded and symmetric in the way described above. A web match tells you that a block also appears in a GitHub repository, a Stack Overflow answer, or a tutorial, and the percentage there reflects how much of the submission was found somewhere online, which is a completely different denominator. An AI score is a model output, typically per file, estimating whether the text resembles machine-generated code.

Averaging them is meaningless, and a single composite "integrity score" hides exactly the information a reviewer needs. Keep them apart. A submission at 8% peer similarity, 62% web similarity, and a high AI score is not three weak signals, it is one clear story about where the code came from. A submission at 70% peer similarity with a low AI score and no web matches is a different story entirely.

Codequiry insights score breakdown separating peer similarity, web similarity and AI generation, with match sources
The score breakdown: peer similarity, web similarity and AI probability reported separately, with where the matches came from.

On the AI side, treat the number as a triage signal with real error rates in both directions. Short files, heavily commented files, and files that use unusual but human idioms all confuse the models. Current AI code detection is useful for ranking a stack of submissions so you read the top of the list first. It is not evidence on its own, and the Codequiry report shows the per-file indicators precisely so a reviewer can argue with them.

The conversation, once the score has done its job

The score's only legitimate function is to route a submission to a human. What follows is a conversation, and the useful ones are short and specific. Ask the student to walk through the matched block and explain why the code does what it does. Ask about a shared bug: if both submissions mishandle the same edge case in the same way, the explanation usually tells you whether it came from a shared source or a shared understanding. Show both files side by side and ask what they notice.

Students who wrote their own code can explain it, including the parts that are awkward or wrong. Students who copied usually can explain the syntax and not the choice. That gap, not the percentage, is what an honor code panel actually evaluates. Instructors running a full cohort should also know how the tooling compares: our Codequiry vs MOSS writeup covers where fingerprinting alone leaves gaps and where a structural comparison fills them.

Frequently Asked Questions

Is a 100% code similarity score proof of plagiarism?

No. Scaffolding, provided classes, test harnesses, and IDE-generated code all produce 100% matches between submissions that share nothing original. Always compare against the starter repository before reading any score.

What similarity threshold should a professor use?

There is no fixed number. Run the checker against the assignment scaffold and your own reference solutions first, then set the review threshold above whatever floor the scaffold produces. The threshold decides which reports you open, not who gets referred.

Can a code similarity score be wrong in the other direction?

Yes. A 30% match can contain a 60-token copied function, and structural transformations like converting a loop to a while or extracting a method can push the token-based score down while the logic stays identical. Sort by longest matched block as well as by percentage.

If you want to see what these three signals look like on your own assignment before the semester starts, you can run a check on a small sample set and read the report yourself.