Polyphase Game Engine
Loading...
Searching...
No Matches
TinyLLMAsset Class Reference

Asset containing a tiny LLM model and tokenizer. More...

#include <TinyLLMAsset.h>

Inheritance diagram for TinyLLMAsset:
Asset Object

Public Member Functions

 DECLARE_ASSET (TinyLLMAsset, Asset)
 
 TinyLLMAsset ()
 
virtual ~TinyLLMAsset ()
 
virtual void Create () override
 
virtual void Destroy () override
 
virtual void LoadStream (Stream &stream, Platform platform) override
 
virtual void SaveStream (Stream &stream, Platform platform) override
 
virtual bool Import (const std::string &path, ImportOptions *options) override
 
virtual void GatherProperties (std::vector< Property > &outProps) override
 
virtual glm::vec4 GetTypeColor () override
 
virtual const char * GetTypeName () override
 
virtual const char * GetTypeImportExt () override
 
const TinyLLMConfigGetConfig () const
 
float * GetTokenEmbedding () const
 
float * GetRmsAttWeight () const
 
float * GetWq () const
 
float * GetWk () const
 
float * GetWv () const
 
float * GetWo () const
 
float * GetRmsFfnWeight () const
 
float * GetW1 () const
 
float * GetW2 () const
 
float * GetW3 () const
 
float * GetRmsFinalWeight () const
 
float * GetWcls () const
 
void SetTokenizer (TinyLLMTokenizerAsset *tokenizer)
 
TinyLLMTokenizerAssetGetTokenizer () const
 
void Encode (const char *text, bool addBos, bool addEos, std::vector< int32_t > &outTokens)
 
std::string Decode (int prevToken, int token)
 
size_t GetWeightMemorySize () const
 
size_t GetKVCacheMemorySize (int32_t maxSeqLen) const
 
- Public Member Functions inherited from Asset
 DECLARE_FACTORY_MANAGER (Asset)
 
 DECLARE_FACTORY (Asset, Asset)
 
 DECLARE_OBJECT (Asset, Object)
 
 Asset ()
 
virtual ~Asset ()
 
virtual void Copy (Asset *srcAsset)
 
const std::string & GetName () const
 
bool IsLoaded () const
 
bool IsRefCounted () const
 
int32_t GetRefCount () const
 
bool IsEmbedded () const
 
void SetEmbedded (bool embed)
 
bool IsEngineAsset () const
 
void SetEngineAsset (bool engineAsset)
 
void SetName (const std::string &name)
 
void IncrementRefCount ()
 
void DecrementRefCount ()
 
void LoadFile (const char *path, AsyncLoadRequest *request=nullptr)
 
void LoadEmbedded (const EmbeddedFile *embeddedAsset, AsyncLoadRequest *request=nullptr)
 
void SaveFile (const char *path, Platform platform)
 
virtual bool ShouldSnapshotForPie () const
 
bool IsTransient () const
 
void SetTransient (bool transient)
 
uint64_t GetUuid () const
 
void SetUuid (uint64_t uuid)
 
void EnsureUuid ()
 
void WriteHeader (Stream &stream)
 
- Public Member Functions inherited from Object
virtual ~Object ()=default
 
virtual const char * RuntimeName () const =0
 
virtual const char * RuntimeParentName () const =0
 
virtual RuntimeId InstanceRuntimeId () const =0
 
virtual ObjectQueryInterface (RuntimeId id) const
 
virtual bool Is (RuntimeId id) const
 
virtual bool Is (const char *name) const
 
virtual bool DrawCustomProperty (Property &prop)
 
template<typename T >
T * As () const
 
virtual bool Equals (const Object *rhs) const
 

Protected Member Functions

void SetupWeightPointers ()
 

Static Protected Member Functions

static bool HandlePropChange (Datum *datum, uint32_t index, const void *newValue)
 

Protected Attributes

TinyLLMConfig mConfig
 
float * mTokenEmbedding = nullptr
 
float * mRmsAttWeight = nullptr
 
float * mWq = nullptr
 
float * mWk = nullptr
 
float * mWv = nullptr
 
float * mWo = nullptr
 
float * mRmsFfnWeight = nullptr
 
float * mW1 = nullptr
 
float * mW2 = nullptr
 
float * mW3 = nullptr
 
float * mRmsFinalWeight = nullptr
 
float * mWcls = nullptr
 
std::vector< float > mWeightData
 
AssetRef mTokenizer
 
- Protected Attributes inherited from Asset
uint32_t mVersion = 0
 
TypeId mType = INVALID_TYPE_ID
 
uint64_t mUuid = 0
 
bool mEmbedded = false
 
bool mLoaded = false
 
bool mEnableRefCount = true
 
bool mEngineAsset = false
 
bool mTransient = false
 
std::string mName = "Asset"
 
int32_t mRefCount = 0
 

Additional Inherited Members

- Static Public Member Functions inherited from Asset
static AssetHeader ReadHeader (Stream &stream)
 
static std::string GetNameFromPath (const std::string &path)
 
static std::string GetDirectoryFromPath (const std::string &path)
 
static const char * GetNameFromTypeId (TypeId id)
 
static TypeId GetTypeIdFromName (const char *name)
 
- Static Public Member Functions inherited from Object
static const char * ClassRuntimeName ()
 

Detailed Description

Asset containing a tiny LLM model and tokenizer.

Constructor & Destructor Documentation

◆ TinyLLMAsset()

TinyLLMAsset::TinyLLMAsset ( )

◆ ~TinyLLMAsset()

TinyLLMAsset::~TinyLLMAsset ( )
virtual

Member Function Documentation

◆ Create()

void TinyLLMAsset::Create ( )
overridevirtual

Reimplemented from Asset.

◆ DECLARE_ASSET()

TinyLLMAsset::DECLARE_ASSET ( TinyLLMAsset  ,
Asset   
)

◆ Decode()

std::string TinyLLMAsset::Decode ( int  prevToken,
int  token 
)

◆ Destroy()

void TinyLLMAsset::Destroy ( )
overridevirtual

Reimplemented from Asset.

◆ Encode()

void TinyLLMAsset::Encode ( const char *  text,
bool  addBos,
bool  addEos,
std::vector< int32_t > &  outTokens 
)

◆ GatherProperties()

void TinyLLMAsset::GatherProperties ( std::vector< Property > &  outProps)
overridevirtual

Reimplemented from Asset.

◆ GetConfig()

const TinyLLMConfig & TinyLLMAsset::GetConfig ( ) const
inline

◆ GetKVCacheMemorySize()

size_t TinyLLMAsset::GetKVCacheMemorySize ( int32_t  maxSeqLen) const

◆ GetRmsAttWeight()

float * TinyLLMAsset::GetRmsAttWeight ( ) const
inline

◆ GetRmsFfnWeight()

float * TinyLLMAsset::GetRmsFfnWeight ( ) const
inline

◆ GetRmsFinalWeight()

float * TinyLLMAsset::GetRmsFinalWeight ( ) const
inline

◆ GetTokenEmbedding()

float * TinyLLMAsset::GetTokenEmbedding ( ) const
inline

◆ GetTokenizer()

TinyLLMTokenizerAsset * TinyLLMAsset::GetTokenizer ( ) const

◆ GetTypeColor()

glm::vec4 TinyLLMAsset::GetTypeColor ( )
overridevirtual

Reimplemented from Asset.

◆ GetTypeImportExt()

const char * TinyLLMAsset::GetTypeImportExt ( )
overridevirtual

Reimplemented from Asset.

◆ GetTypeName()

const char * TinyLLMAsset::GetTypeName ( )
overridevirtual

Reimplemented from Asset.

◆ GetW1()

float * TinyLLMAsset::GetW1 ( ) const
inline

◆ GetW2()

float * TinyLLMAsset::GetW2 ( ) const
inline

◆ GetW3()

float * TinyLLMAsset::GetW3 ( ) const
inline

◆ GetWcls()

float * TinyLLMAsset::GetWcls ( ) const
inline

◆ GetWeightMemorySize()

size_t TinyLLMAsset::GetWeightMemorySize ( ) const

◆ GetWk()

float * TinyLLMAsset::GetWk ( ) const
inline

◆ GetWo()

float * TinyLLMAsset::GetWo ( ) const
inline

◆ GetWq()

float * TinyLLMAsset::GetWq ( ) const
inline

◆ GetWv()

float * TinyLLMAsset::GetWv ( ) const
inline

◆ HandlePropChange()

bool TinyLLMAsset::HandlePropChange ( Datum datum,
uint32_t  index,
const void *  newValue 
)
staticprotected

◆ Import()

bool TinyLLMAsset::Import ( const std::string &  path,
ImportOptions options 
)
overridevirtual

Reimplemented from Asset.

◆ LoadStream()

void TinyLLMAsset::LoadStream ( Stream stream,
Platform  platform 
)
overridevirtual

Reimplemented from Asset.

◆ SaveStream()

void TinyLLMAsset::SaveStream ( Stream stream,
Platform  platform 
)
overridevirtual

Reimplemented from Asset.

◆ SetTokenizer()

void TinyLLMAsset::SetTokenizer ( TinyLLMTokenizerAsset tokenizer)

◆ SetupWeightPointers()

void TinyLLMAsset::SetupWeightPointers ( )
protected

Member Data Documentation

◆ mConfig

TinyLLMConfig TinyLLMAsset::mConfig
protected

◆ mRmsAttWeight

float* TinyLLMAsset::mRmsAttWeight = nullptr
protected

◆ mRmsFfnWeight

float* TinyLLMAsset::mRmsFfnWeight = nullptr
protected

◆ mRmsFinalWeight

float* TinyLLMAsset::mRmsFinalWeight = nullptr
protected

◆ mTokenEmbedding

float* TinyLLMAsset::mTokenEmbedding = nullptr
protected

◆ mTokenizer

AssetRef TinyLLMAsset::mTokenizer
protected

◆ mW1

float* TinyLLMAsset::mW1 = nullptr
protected

◆ mW2

float* TinyLLMAsset::mW2 = nullptr
protected

◆ mW3

float* TinyLLMAsset::mW3 = nullptr
protected

◆ mWcls

float* TinyLLMAsset::mWcls = nullptr
protected

◆ mWeightData

std::vector<float> TinyLLMAsset::mWeightData
protected

◆ mWk

float* TinyLLMAsset::mWk = nullptr
protected

◆ mWo

float* TinyLLMAsset::mWo = nullptr
protected

◆ mWq

float* TinyLLMAsset::mWq = nullptr
protected

◆ mWv

float* TinyLLMAsset::mWv = nullptr
protected

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