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

Class implementing a Retrieval Augmented Generation (RAG) system based on a search method and an optional chunking method. More...

Inheritance diagram for LLMUnity.RAG:
[legend]

Public Member Functions

void Init (SearchMethods searchMethod=SearchMethods.SimpleSearch, ChunkingMethods chunkingMethod=ChunkingMethods.NoChunking, LLM llm=null)
 Constructs the Retrieval Augmented Generation (RAG) system based on the provided search and chunking method.
 
void ReturnChunks (bool returnChunks)
 Set to true to return chunks or the direct input with the Search function.
 
- 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.
 

Public Attributes

SearchMethods searchType = SearchMethods.SimpleSearch
 Search method type to use for RAG. SimpleSearch is a simple brute-force search, while DBSearch is a fast Approximate Nearest Neighbor (ANN) method (recommended!).
 
SearchMethod search
 Search method GameObject.
 
ChunkingMethods chunkingType = ChunkingMethods.NoChunking
 Chunking method type to use for RAG for splitting the inputs into chunks. This is useful to have a more consistent meaning within each data part.
 
Chunking chunking
 Chunking method GameObject.
 

Detailed Description

Class implementing a Retrieval Augmented Generation (RAG) system based on a search method and an optional chunking method.

Definition at line 38 of file RAG.cs.

Member Function Documentation

◆ Init()

void LLMUnity.RAG.Init ( SearchMethods searchMethod = SearchMethods::SimpleSearch,
ChunkingMethods chunkingMethod = ChunkingMethods::NoChunking,
LLM llm = null )
inline

Constructs the Retrieval Augmented Generation (RAG) system based on the provided search and chunking method.

Parameters
searchMethodsearch method
chunkingMethodchunking method for splitting the search entries
llmLLM to use for the search method

Definition at line 59 of file RAG.cs.

◆ ReturnChunks()

void LLMUnity.RAG.ReturnChunks ( bool returnChunks)
inline

Set to true to return chunks or the direct input with the Search function.

Parameters
returnChunkswhether to return chunks

Definition at line 71 of file RAG.cs.

Member Data Documentation

◆ chunking

Chunking LLMUnity.RAG.chunking

Chunking method GameObject.

Definition at line 51 of file RAG.cs.

◆ chunkingType

ChunkingMethods LLMUnity.RAG.chunkingType = ChunkingMethods.NoChunking

Chunking method type to use for RAG for splitting the inputs into chunks. This is useful to have a more consistent meaning within each data part.

Definition at line 48 of file RAG.cs.

◆ search

SearchMethod LLMUnity.RAG.search

Search method GameObject.

Definition at line 45 of file RAG.cs.

◆ searchType

SearchMethods LLMUnity.RAG.searchType = SearchMethods.SimpleSearch

Search method type to use for RAG. SimpleSearch is a simple brute-force search, while DBSearch is a fast Approximate Nearest Neighbor (ANN) method (recommended!).

Definition at line 42 of file RAG.cs.


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