ML functions
 
Loading...
Searching...
No Matches
RAG Class Reference

Implements a Retrieval-Augmented Generation (RAG) function for machine learning. More...

#include <RAG.h>

Inheritance diagram for RAG:
MLFunction

Public Member Functions

 RAG (std::vector< std::string > document, std::vector< std::vector< float > > embedding, int dimension)
 Constructor for RAG.
 
void apply (const SelectivityVector &rows, std::vector< VectorPtr > &args, const TypePtr &outputType, exec::EvalCtx &context, VectorPtr &output) const override
 Applies the RAG function to the input data.
 
float * getTensor () const override
 Returns the tensor associated with the function.
 
std::string getFuncName ()
 Returns the name of the function.
 
std::string getWeightsFile ()
 Returns the path to the weights file.
 
void setWeights (float *weights)
 Sets the weights for the function.
 
CostEstimate getCost (std::vector< int > inputDims)
 Estimates the cost of the function.
 
- Public Member Functions inherited from MLFunction
virtual ~MLFunction ()=default
 Virtual destructor.
 
virtual std::vector< int > getDims ()
 Returns the dimensions of the function.
 
virtual int getNumDims ()
 Returns the number of dimensions of the function.
 

Static Public Member Functions

static std::vector< std::shared_ptr< exec::FunctionSignature > > signatures ()
 Returns the function signatures.
 
static std::string getName ()
 Returns the name of the function.
 

Additional Inherited Members

- Protected Member Functions inherited from MLFunction
double getWeightedCost (std::string name, float cost)
 Calculates the weighted cost of the function.
 
std::vector< double > getCoefficientVector (std::string name)
 Retrieves the cost coefficients for the function.
 
- Protected Attributes inherited from MLFunction
std::vector< int > dims
 Dimensions of the function.
 

Detailed Description

Implements a Retrieval-Augmented Generation (RAG) function for machine learning.

Constructor & Destructor Documentation

◆ RAG()

RAG::RAG ( std::vector< std::string > document,
std::vector< std::vector< float > > embedding,
int dimension )
inline

Constructor for RAG.

Parameters
documentA vector of documents.
embeddingA 2D vector of embeddings corresponding to the documents.
dimensionThe dimensionality of the embeddings.

Member Function Documentation

◆ apply()

void RAG::apply ( const SelectivityVector & rows,
std::vector< VectorPtr > & args,
const TypePtr & outputType,
exec::EvalCtx & context,
VectorPtr & output ) const
inlineoverride

Applies the RAG function to the input data.

Parameters
rowsSelectivity vector indicating which rows to process.
argsVector of input arguments.
outputTypeType of the output vector.
contextEvaluation context.
outputOutput vector to store the results.

◆ getCost()

CostEstimate RAG::getCost ( std::vector< int > inputDims)
inlinevirtual

Estimates the cost of the function.

Parameters
inputDimsDimensions of the input.
Returns
Cost estimate.

Reimplemented from MLFunction.

◆ getFuncName()

std::string RAG::getFuncName ( )
inlinevirtual

Returns the name of the function.

Returns
Function name.

Reimplemented from MLFunction.

◆ getName()

static std::string RAG::getName ( )
inlinestatic

Returns the name of the function.

Returns
Function name.

◆ getTensor()

float * RAG::getTensor ( ) const
inlineoverridevirtual

Returns the tensor associated with the function.

Returns
Pointer to the tensor.

Implements MLFunction.

◆ getWeightsFile()

std::string RAG::getWeightsFile ( )
inline

Returns the path to the weights file.

Returns
Path to the weights file.

◆ setWeights()

void RAG::setWeights ( float * weights)
inline

Sets the weights for the function.

Parameters
weightsPointer to the weights array.

◆ signatures()

static std::vector< std::shared_ptr< exec::FunctionSignature > > RAG::signatures ( )
inlinestatic

Returns the function signatures.

Returns
Vector of function signatures.

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