Understanding Stack Overflow’s Duplicate Detection: How the System Finds Similar Questions
A concise look at how Stack Overflow’s duplicate detection works—from title similarity and tag overlap to an ML‑scored review queue—and how you can verify or influence its outcome.
24 Sept 2026, 09:29 UTC

When you ask a question on Stack Overflow and see a banner that says “This question may already have an answer here”, the duplicate‑detection system has already run behind the scenes. Knowing how it works helps you craft questions that are either more likely to be caught as duplicates (when you want to avoid reposting) or less likely to be incorrectly closed (when you have a genuine nuance).
How the algorithm generates candidate duplicates
As soon as a new question is submitted, the system builds a short list of potential matches using three lightweight signals:
- Title similarity – a token‑based Jaccard score between the new title and existing titles.
- Tag overlap – the proportion of tags shared with existing questions; high‑traffic tags get a boost.
- Body text hashing – a MinHash signature of the question body (after stripping code fences) to catch lexical similarity even when wording differs.
Only questions that exceed a low threshold on any of these signals become candidates; this keeps the candidate set small enough for the next step.
Scoring candidates with a machine‑learning model
Each candidate pair is fed into a gradient‑boosted tree model that was trained on thousands of moderator‑validated duplicate and non‑duplicate pairs. The model combines:
- the three raw signals above,
- recent activity (e.g., votes, edits) on the older question,
- tag popularity (to weight duplicates in high‑traffic areas more heavily),
- and a few meta‑features such as the age of the older question.
The output is a probability score. If the score surpasses a high‑confidence threshold, the pair is pushed to the Close Votes review queue; otherwise it is stored as a low‑confidence suggestion that may later appear in the “Related” sidebar.
Worked example: from new question to review queue
Imagine a user posts:
Title: How do I convert a List<String> to an array in Java 8?
Tags: java, arrays, list, java-8
Body: I have a List<String> called names and I want a plain String[].
The system might produce the following candidate generation (illustrative only):
- Title similarity finds an existing question titled “Converting List to array in Java” (Jaccard = 0.42).
- Tag overlap matches three of four tags (overlap = 0.75).
- Body hash yields a MinHash distance of 0.18 against a post with the same code snippet.
- These raw signals are combined with the older question’s recent up‑votes (+12 in the last hour) and the high popularity of the
javatag. - The ML model outputs a score of 0.87, which exceeds the high‑confidence threshold, so the pair lands in the Close Votes queue.
Users with the “Close Votes” privilege can then vote to close, leave open, or dismiss the suggestion.
Practical ways to verify the system’s behavior
You don’t need special tooling to observe the duplicate detector in action:
- After posting a question, watch for the yellow banner that appears if a high‑confidence duplicate is found. Clicking “linked” shows the original post.
- If you have the Close Votes privilege (≥ 250 reputation on Stack Overflow), go to Review → Close Votes and look for entries marked “Duplicate”.
- For a broader view, run a query in the Stack Exchange Data Explorer:
SELECT Id, CreationDate, ClosedDate
FROM Posts
WHERE PostTypeId = 1
AND ClosedDate IS NOT NULL
AND ClosedReason = 'Duplicate'
ORDER BY CreationDate DESC;
This returns recently closed duplicates; comparing The detector is tuned for precision and recall across the site’s massive volume, but two practical limits arise: These limits mean that, as a asker, you should still search manually before posting, and as a reviewer, you should examine the full context rather than relying solely on the automated banner. If you want to increase the chance that a genuine duplicate is caught: Conversely, if you believe your question is a legitimate variation, edit the title or body to highlight the distinguishing constraint; this often lowers the similarity score enough to keep the question open.CreationDate and ClosedDate
Trade‑offs and limitations
Actionable takeaway
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.