|
Krotos Modules 3
|
text to preset class for text to preset embeddings calculation and dictionary creation More...
#include <TextToPreset.h>
Classes | |
| struct | Data |
Public Member Functions | |
| TextToPreset () | |
| ~TextToPreset () | |
| float | computeSimilarity (const std::vector< float > &queryEmbedding, const std::vector< float > &resultEmbedding) const |
| compute cosine similarity based of result to query | |
| StringArray | combineSearch (const String &searchTerm, const StringArray &classicResults, const StringArray &ttpResults, std::map< String, std::vector< float > > &embeddingsCache, const size_t &maxResults=25) |
| combine multiple StringArrays, megre and rerank the items based on cosine similarity | |
| StringArray | findClosestPresets (String searchTerm, int maxNumPresetsToFind) const |
| returns a String array that contains K closest presets, | |
| std::string | getPresetPath (std::string presetNameToLoad) const |
| return the preset path | |
| String | logString () const |
| returns the log string | |
| bool | processFileList (Array< File > &filesToProcess) |
| processes a file list to create text embeddings | |
| bool | calculateEmbeddingsForPresetFile (File presetFile) |
| create text embeddings file for the given preset file | |
| bool | appendDataToEmbeddingsFile () |
| appends data to the main embeddings file | |
| File | createFilePath (String filename) |
| creates the path for the embeddings file | |
| void | loadEmbeddings () |
| will load embeddings data from file to all modules that need it | |
| StringArray | performSearch (String query) |
| performs search based on text embeddings and KNN | |
| void | getSampleMetadata (const std::string &input, unsigned char *byteArray) |
Private Member Functions | |
| void | clear () |
| clears internal data | |
| void | run () override |
| void | getPresetAssetNames (ValueTree &root) |
| will get preset asset paths and names to the m_samplePaths and m_sampleFilenames arrays | |
| bool | assetNamesToTags (bool eliminateDuplicates) |
| Splits the asset names, in respect to the excluded terms, and pushes the remaining terms into a new string array. | |
| void | searchForTagAndProperty (ValueTree &root, Identifier tag, Identifier property) |
| this will recursivelly search in a preset ValueTree structure for a given idendtifier and property name | |
| std::vector< float > | destringify (String stringWithNumbers) |
| destrignifies embeddings | |
| bool | saveToFile (File file) |
| saves embeddings to file | |
| bool | readFromFile (File file) |
| load embeddings from file | |
| template<class T > | |
| String | stringify (std::vector< T > numbers) |
Private Attributes | |
| String | m_logString |
| StringArray | m_samplePaths |
| StringArray | m_sampleFilenames |
| File | m_presetFile |
| String | m_presetName |
| StringArray | m_presetTags |
| std::map< String, Data > | m_presetData |
| std::map< std::string, std::string > | m_presetNameAndPresetPathMap |
| StringArray | excludeTerms |
| String | assetPathsDelimiter {"\n"} |
| StringArray | m_treatedAssetPaths |
| String | delimiters {",|._- "} |
| SentenceTransformer | m_sentenceTransformer |
| SharedResourcePointer< UniversalCategorySystem > | m_UCS |
| KDTreeND | m_kNN |
| std::vector< String > | m_presetNames |
| CriticalSection | m_cs |
| unsigned char | m_data [BUFFER_SIZE] |
| bool | m_modelFileAvailable {false} |
text to preset class for text to preset embeddings calculation and dictionary creation
| krotos::TextToPreset::TextToPreset | ( | ) |
| krotos::TextToPreset::~TextToPreset | ( | ) |
| bool krotos::TextToPreset::appendDataToEmbeddingsFile | ( | ) |
appends data to the main embeddings file
|
private |
Splits the asset names, in respect to the excluded terms, and pushes the remaining terms into a new string array.
| eliminateDuplicates | If true, duplicates in the resulting tag list will be excluded |
| bool krotos::TextToPreset::calculateEmbeddingsForPresetFile | ( | File | presetFile | ) |
create text embeddings file for the given preset file
|
private |
clears internal data
| StringArray krotos::TextToPreset::combineSearch | ( | const String & | searchTerm, |
| const StringArray & | classicResults, | ||
| const StringArray & | ttpResults, | ||
| std::map< String, std::vector< float > > & | embeddingsCache, | ||
| const size_t & | maxResults = 25 ) |
combine multiple StringArrays, megre and rerank the items based on cosine similarity
| query | string, |
| classic | search results |
| existing | text to preset results |
| cached | embeddings |
| float krotos::TextToPreset::computeSimilarity | ( | const std::vector< float > & | queryEmbedding, |
| const std::vector< float > & | resultEmbedding ) const |
compute cosine similarity based of result to query
| query | embedding |
| result | embedding |
| File krotos::TextToPreset::createFilePath | ( | String | filename | ) |
creates the path for the embeddings file
|
private |
destrignifies embeddings
| StringArray krotos::TextToPreset::findClosestPresets | ( | String | searchTerm, |
| int | maxNumPresetsToFind ) const |
returns a String array that contains K closest presets,
| query | string, |
| max | presets to return |
|
private |
will get preset asset paths and names to the m_samplePaths and m_sampleFilenames arrays
|
inline |
return the preset path
| the | preset name |
|
inline |
| void krotos::TextToPreset::loadEmbeddings | ( | ) |
will load embeddings data from file to all modules that need it
|
inline |
returns the log string
| StringArray krotos::TextToPreset::performSearch | ( | String | query | ) |
performs search based on text embeddings and KNN
| bool krotos::TextToPreset::processFileList | ( | Array< File > & | filesToProcess | ) |
processes a file list to create text embeddings
| file | list to process |
|
private |
load embeddings from file
|
overrideprivate |
|
private |
saves embeddings to file
|
private |
this will recursivelly search in a preset ValueTree structure for a given idendtifier and property name
|
private |
std::vector to juce::String
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |