# Interface: com.pnfsoftware.jeb.core.units.code.android.IMethodEmbeddingManager

Interface for an embedding manager for decompiled dex methods. The manager is responsible for  generating embeddings as well as comparing good candidate matches to a base embedding.  

  Implementations of this interface must have a no\-arg constructor to allow instantiation.

## Abstract Method: findBestMatch
- parameter: `target`, type: `com.pnfsoftware.jeb.core.units.code.MethodEmbedding`
- parameter: `matches`, type: `java.util.List<com.pnfsoftware.jeb.core.units.code.MethodMatch>`
- return type: `com.pnfsoftware.jeb.core.units.code.MethodMatch`

Description: Given a target embedding and a collection of top candidate matches for that embedding,  determine which one is better. This is used to select the best match among several good  candidates.  

  Note that this method is optional and may simply return the first embedding in the provided  collection of candidates \(that is, the one with the best vector similarity score according to  the vector database\). However, it can be implemented to perform a more in\-depth analysis of  the candidates and select the best one among them \(that may not have the best vector  similarity\), for example, by using the extra data stored provided during embedding  generation.
parameter: target: the target embedding representing the method for which we are looking for a             match
parameter: matches: a non\-empty list of candidate matches for the target embedding; the list is             ordered by descending similarity scores; these candidates passed the thresholds             defined by [#getDatabaseQuerySettings()](#getDatabaseQuerySettings()), but they may still be of             varying quality; this collection is never null and contains at least one candidate
return: the best embedding

## Abstract Method: generateEmbedding
- parameter: `m`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDMethodContext`
- parameter: `extras`, type: `java.util.Map<java.lang.String,java.lang.Object>`
- parameter: `unstoredExtras`, type: `java.util.Map<java.lang.String,java.lang.Object>`
- return type: `float[]`

Description: Generate a method embedding, given an IR method context for that method.
parameter: m: method context
parameter: extras: a sink map that may receive extra information about the embedding; the extra             \(key, value\) pairs stored in this method when generating the embedding will be             stored in the final computed [MethodEmbedding](com.pnfsoftware.jeb.core.units.code.MethodEmbedding.md) object; watch out\! the             accepted value types are: Integer, Long, Float, Double, String, byte\[\]
parameter: unstoredExtras: a sink map that may receive extra information about the embedding, but             that will not be stored in the final computed [MethodEmbedding](com.pnfsoftware.jeb.core.units.code.MethodEmbedding.md) object, and             will not be stored in the vector database
return: the embedding object, or null if no decent embedding can be generated for the given          method \(e.g. the method is too small or too simple to be meaningfully represented as          an embedding\)

## Abstract Method: getDatabaseQuerySettings
- return type: `int[]`

Description: Get vector database query thresholds.
return: an 3\-element array \(k, n, s\) of integers defining the thresholds for candidate          matches:          
          
- `k`: the number of embeddings to find and consider          
- `n`: the top number of hits, among a maximum pool of \`k\` embeddings, to be          returned when searching for a match; \`k\` must be greater than \`n\`          
- `s`: the minimal similarity score \(in percentages, from \-100 to 100\)          between two vectors to be considered a good candidate match; if the score is below          this threshold, the match will be discarded and not returned as a candidate

## Default Method: getSimilarityMethod
- return type: `java.lang.String`

Description: Get the similarity method name.
return: the similarity method used by the vector database to find good matches approximating          a target embedding; currently, the only supported value is "COSINE", and this method          must return it\)

## Abstract Method: getVectorDimension
- return type: `int`

Description: Get the vector dimension.
return: the count of dimensions for embeddings generating by [#generateEmbedding](#generateEmbedding); all          vectors generated and used by this manager must have this dimension

