ArKanjo 0.5.1
A tool for find code duplicated functions in codebases
EmbeddingMethod Class Reference

Semantic duplication detector using LLM embeddings. More...

#include <embedding_method.hpp>

+ Inheritance diagram for EmbeddingMethod:
+ Collaboration diagram for EmbeddingMethod:

Public Member Functions

 EmbeddingMethod (const fs::path &base_path_, double similarity_, std::vector< std::string > pass_through_args_={})
 Constructs the LLM detector. More...
 
void on_function (const FunctionData &fd) override
 
void execute () override
 
- Public Member Functions inherited from IMethod
virtual ~IMethod ()=default
 
virtual void save_duplications (std::vector< DuplicationEntry > &)
 Output line format: More...
 
virtual void on_function (const FunctionData &fd)=0
 
virtual void execute ()=0
 

Detailed Description

Semantic duplication detector using LLM embeddings.

Materializes each function body as a file under the source feature directory (same as the other methods), then invokes a Python script that embeds every function with a Hugging Face model and prints the pairwise similarities, which are parsed back into duplication entries.

Definition at line 29 of file embedding_method.hpp.

Constructor & Destructor Documentation

◆ EmbeddingMethod()

EmbeddingMethod::EmbeddingMethod ( const fs::path &  base_path_,
double  similarity_,
std::vector< std::string >  pass_through_args_ = {} 
)

Constructs the LLM detector.

Parameters
base_path_Root path of the codebase cache.
similarity_Minimum similarity threshold (0-100) to consider as duplicate.
pass_through_args_Raw arguments forwarded to the embedding script (e.g. –max-seq-length, –batch-size, –model).

Definition at line 17 of file embedding_method.cpp.

Member Function Documentation

◆ execute()

void EmbeddingMethod::execute ( )
overridevirtual

Implements IMethod.

Definition at line 116 of file embedding_method.cpp.

◆ on_function()

void EmbeddingMethod::on_function ( const FunctionData &  fd)
overridevirtual

Implements IMethod.

Definition at line 103 of file embedding_method.cpp.


The documentation for this class was generated from the following files: