LLM for Unity  v2.3.0
Create characters in Unity with LLMs!
Loading...
Searching...
No Matches
LLMUnity.DBSearch Class Reference

Class implementing a search with a vector database. The search results are retrieved with Approximate Nearest Neighbor (ANN) which is much faster that SimpleSearch. More...

Inheritance diagram for LLMUnity.DBSearch:
[legend]

Public Attributes

bool advancedOptions = false
 toggle to show/hide advanced options in the GameObject
 
ScalarKind quantization = ScalarKind.Float16
 The quantisation type used for vector data during indexing.
 
MetricKind metricKind = MetricKind.Cos
 The metric kind used for distance calculation between vectors.
 
ulong connectivity = 32
 The connectivity parameter limits the connections-per-node in the graph.
 
ulong expansionAdd = 40
 The expansion factor used for index construction when adding vectors.
 
ulong expansionSearch = 16
 The expansion factor used for index construction during search operations.
 
- Public Attributes inherited from LLMUnity.SearchMethod
LLMEmbedder llmEmbedder
 

Additional Inherited Members

- Public Member Functions inherited from LLMUnity.SearchMethod
void SetLLM (LLM llm)
 Sets the LLM for encoding the search entries.
 
async Task<(string[], float[])> SearchFromList (string query, string[] searchList)
 Orders the entries in the searchList according to their similarity to the provided query. The entries and distances (dissimilarity) to the query are returned in decreasing order of similarity.
 
- Public Member Functions inherited from LLMUnity.Searchable
string Get (int key)
 Retrieves the phrase with the specific id.
 
Task< int > Add (string inputString, string group="")
 Adds a phrase to the search.
 
int Remove (string inputString, string group="")
 Removes a phrase from the search.
 
void Remove (int key)
 Removes a phrase from the search.
 
int Count ()
 Returns a count of the phrases.
 
int Count (string group)
 Returns a count of the phrases in a specific data group.
 
void Clear ()
 Clears the search object.
 
Task< int > IncrementalSearch (string queryString, string group="")
 Allows to do search and retrieve results in batches (incremental search).
 
ValueTuple< int[], float[], bool > IncrementalFetchKeys (int fetchKey, int k)
 Retrieves the most similar search results in batches (incremental search). The phrase keys and distances are retrieved, as well as a parameter that dictates whether the search is exhausted.
 
void IncrementalSearchComplete (int fetchKey)
 Completes the search and clears the cached results for an incremental search.
 
async Task<(string[], float[])> Search (string queryString, int k, string group="")
 Search for similar results to the provided query. The most similar results and their distances (dissimilarity) to the query are retrieved.
 
virtual ValueTuple< string[], float[], bool > IncrementalFetch (int fetchKey, int k)
 Retrieves the most similar search results in batches (incremental search). The most similar results and their distances (dissimilarity) to the query are retrieved as well as a parameter that dictates whether the search is exhausted.
 
void Save (string filePath)
 Saves the state of the search object.
 
async Task< bool > Load (string filePath)
 Loads the state of the search object.
 

Detailed Description

Class implementing a search with a vector database. The search results are retrieved with Approximate Nearest Neighbor (ANN) which is much faster that SimpleSearch.

Definition at line 17 of file DBSearch.cs.

Member Data Documentation

◆ advancedOptions

bool LLMUnity.DBSearch.advancedOptions = false

toggle to show/hide advanced options in the GameObject

Definition at line 21 of file DBSearch.cs.

◆ connectivity

ulong LLMUnity.DBSearch.connectivity = 32

The connectivity parameter limits the connections-per-node in the graph.

Definition at line 27 of file DBSearch.cs.

◆ expansionAdd

ulong LLMUnity.DBSearch.expansionAdd = 40

The expansion factor used for index construction when adding vectors.

Definition at line 29 of file DBSearch.cs.

◆ expansionSearch

ulong LLMUnity.DBSearch.expansionSearch = 16

The expansion factor used for index construction during search operations.

Definition at line 31 of file DBSearch.cs.

◆ metricKind

MetricKind LLMUnity.DBSearch.metricKind = MetricKind.Cos

The metric kind used for distance calculation between vectors.

Definition at line 25 of file DBSearch.cs.

◆ quantization

ScalarKind LLMUnity.DBSearch.quantization = ScalarKind.Float16

The quantisation type used for vector data during indexing.

Definition at line 23 of file DBSearch.cs.


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