Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
rkochanowski
searching Neon…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
12 ms
·
1.
▲
by
rkochanowski
27d ago
1.5 months ago I showed here my tool for detecting code duplication with embedding models: https://news.ycombinator.com/item?id=48762038 I got valuable feedback and some questions I was not able to answer precisely. Now I h
2.
▲
My own embedding models benchmark focused on code duplication detection
(rkochanowski.com)
2 points
by
rkochanowski
27d ago
|
1 comments
3.
▲
by
rkochanowski
3mo ago
Thanks, I will look at this in more detail. To give more context, the current version is already an optimized one I considered good enough and didn't spend more time on it. In the first attempt, I used a vector database with indexes, t
4.
▲
by
rkochanowski
3mo ago
"Non-exact" may be interpreted in different ways, so let's look at the example report: https://github.com/rafal-qa/slopo/tree/main/doc/example-repo... * cluster-01.md has the highest
5.
▲
by
rkochanowski
3mo ago
Do you mean to verify if similar code units produce the same result? The goal of the tool is to also detect code that is similar and behaves differently. There are not ideal duplicates, but still a code that can be refactored, abstracted, o
6.
▲
by
rkochanowski
3mo ago
Slopo doesn't deduplicate. It only reports similar code units, which in most cases are not duplicates. This needs to be cleaned up by the user, which is fast and easy with coding agents. Embedding calculation is also outsourced externa
7.
▲
by
rkochanowski
3mo ago
PHP was added in the latest release.
8.
▲
by
rkochanowski
3mo ago
Elixir was added in the latest release.
9.
▲
by
rkochanowski
3mo ago
It can be added with https://pypi.org/project/tree-sitter-elixir/ similar to other languages. I will add this and plan to release a new version today.
10.
▲
by
rkochanowski
3mo ago
Function level only. I will add more granular chunking in next versions.
11.
▲
by
rkochanowski
3mo ago
It's the opposite. jscpd is advertised as "Copy/paste detector", Slopo is advertised as "non-exact code duplication". Slopo also detects copy/pasted code, but this is not the main goal and the report focus
12.
▲
by
rkochanowski
3mo ago
Finding similar code is something different than deduplication, even when the final goal looks similar. Deduplication backend is the easiest part of the tool and it doesn't need any additional libraries. Just calculate embeddings and f
13.
▲
by
rkochanowski
3mo ago
My solution for false positives is simpler: 1. The tool uses only cosine similarity plus boost depending on distance in the codebase. 2. Classification with LLM. This can be done by coding agent used with project giving better results than
14.
▲
by
rkochanowski
3mo ago
I just focused on embeddings without comparing them to deterministic solutions. But I plan to do my own analysis of different embedding models in the context of code similarity detection. Including BM25 in the comparison is a very good idea
15.
▲
by
rkochanowski
3mo ago
Currently, only whole functions (including function-like constructs depending on language) are considered as unit. Skipping the extraction of conditional branches was my decision to not overcomplicate the first versions, which was intended
16.
▲
by
rkochanowski
3mo ago
Based on your example there is only a single function a() which is embedded. The rest is just a code and dependencies are not resolved. Did you think about adding this feature in your tool?
17.
▲
by
rkochanowski
3mo ago
Generally, I chunk by function/method (not by whole class), but different languages have specific concepts and features. Nested code units, anonymous functions, lambdas, closures are extracted as separate chunks. The chunk size has all
18.
▲
by
rkochanowski
3mo ago
There are good mature tools for deterministic duplication detection and I intentionally focused on embedding-based to fill this gap (I didn't find other tools using this approach). If by "more efficient" you mean to avoid emb
19.
▲
by
rkochanowski
3mo ago
Recently there was a popular article on HN saying that sometimes code duplication is better than abstraction, so I assume that this question is not a joke. While testing this tool, one detected duplication was interesting for a use case. P
20.
▲
by
rkochanowski
3mo ago
No. It depends the most on general code quality and architecture. Some implementations require more code similarity by design. Some languages, like Java, may tend to have more duplication, but it's only a theoretical guess. It also dep
21.
▲
by
rkochanowski
3mo ago
PHP support can be easily added, I will release a new version soon.
22.
▲
by
rkochanowski
3mo ago
I built Slopo to solve one specific problem: finding similar code that is hardest to detect by other tools, coding AI agents, and humans. It finds similar-looking code with embeddings. This detects more than just copy-paste clones or even c
23.
▲
Show HN: CLI tool for detecting non-exact code duplication with embedding models
(github.com)
91 points
by
rkochanowski
3mo ago
|
54 comments
24.
▲
by
rkochanowski
3mo ago
That's why it's so important to design a solution before letting AI implement it. I noticed that AI often can't see clean, elegant and primitive solutions that fit best for a given problem. Even when I ask if it can be design
25.
▲
by
rkochanowski
3mo ago
There are bunch of tools to manage context or fix what Claude does wrong. They may be popular because non software engineers want to improve their workflows, like you mentioned. But are they really working instead of making it worse? Are th
26.
▲
by
rkochanowski
3mo ago
I realized how easily it can be confused and generate a bad answer in effect. It's difficult to control context when we have instructions in AGENTS/CLAUDE.md, memory, SKILLs, sometimes additional tools for optimization. On top of
27.
▲
by
rkochanowski
3mo ago
I think "lack of effort required" is the key. We can just throw prompts without understanding and caring about output. This way we can build something in 10 min we don't own. We can also do real engineering with our architect