@@ -733,7 +733,7 @@ export class LlamaModel {
733733 if ( modelLoaded )
734734 await model . _model . dispose ( ) ;
735735
736- throw loadSignal . reason ;
736+ throw loadSignal ! . reason ;
737737 } else if ( ! modelLoaded )
738738 throw new Error ( "Failed to load model" ) ;
739739
@@ -757,12 +757,17 @@ export class LlamaModelTokens {
757757 /** @internal */ private _bosToken ?: Token ;
758758 /** @internal */ private _eosToken ?: Token ;
759759 /** @internal */ private _eotToken ?: Token ;
760+ /** @internal */ private _clsToken ?: Token ;
761+ /** @internal */ private _sepToken ?: Token ;
760762 /** @internal */ private _nlToken ?: Token ;
761763 /** @internal */ private _bosString ?: string ;
762764 /** @internal */ private _eosString ?: string ;
763765 /** @internal */ private _eotString ?: string ;
766+ /** @internal */ private _clsString ?: string ;
767+ /** @internal */ private _sepString ?: string ;
764768 /** @internal */ private _nlString ?: string ;
765769 /** @internal */ private _shouldPrependBosToken ?: boolean ;
770+ /** @internal */ private _shouldAppendEosToken ?: boolean ;
766771
767772 private constructor ( model : AddonModel , disposedState : DisposedState ) {
768773 this . _model = model ;
@@ -826,6 +831,36 @@ export class LlamaModelTokens {
826831 return this . _eotToken ;
827832 }
828833
834+ /**
835+ * @returns The CLS (Classification) token.
836+ */
837+ public get cls ( ) : Token | null {
838+ this . _ensureNotDisposed ( ) ;
839+
840+ if ( this . _clsToken == null )
841+ this . _clsToken = this . _model . clsToken ( ) ;
842+
843+ if ( this . _clsToken === - 1 )
844+ return null ;
845+
846+ return this . _clsToken ;
847+ }
848+
849+ /**
850+ * @returns The SEP (Sentence Separator) token.
851+ */
852+ public get sep ( ) : Token | null {
853+ this . _ensureNotDisposed ( ) ;
854+
855+ if ( this . _sepToken == null )
856+ this . _sepToken = this . _model . sepToken ( ) ;
857+
858+ if ( this . _sepToken === - 1 )
859+ return null ;
860+
861+ return this . _sepToken ;
862+ }
863+
829864 /**
830865 * @returns The NL (New Line) token.
831866 */
@@ -892,6 +927,40 @@ export class LlamaModelTokens {
892927 return this . _eotString ;
893928 }
894929
930+ /**
931+ * @returns The CLS (Classification) token text representation.
932+ */
933+ public get clsString ( ) : string | null {
934+ this . _ensureNotDisposed ( ) ;
935+
936+ const clsToken = this . cls ;
937+
938+ if ( clsToken == null )
939+ return null ;
940+
941+ if ( this . _clsString == null )
942+ this . _clsString = this . _model . getTokenString ( clsToken ) ;
943+
944+ return this . _clsString ;
945+ }
946+
947+ /**
948+ * @returns The SEP (Sentence Separator) token text representation.
949+ */
950+ public get sepString ( ) : string | null {
951+ this . _ensureNotDisposed ( ) ;
952+
953+ const sepToken = this . sep ;
954+
955+ if ( sepToken == null )
956+ return null ;
957+
958+ if ( this . _sepString == null )
959+ this . _sepString = this . _model . getTokenString ( sepToken ) ;
960+
961+ return this . _sepString ;
962+ }
963+
895964 /**
896965 * @returns The NL (New Line) token text representation.
897966 */
@@ -921,6 +990,18 @@ export class LlamaModelTokens {
921990 return this . _shouldPrependBosToken ;
922991 }
923992
993+ /**
994+ * @returns Whether we should append an EOS (End Of Sequence) token for evaluations with this model.
995+ */
996+ public get shouldAppendEosToken ( ) : boolean {
997+ this . _ensureNotDisposed ( ) ;
998+
999+ if ( this . _shouldAppendEosToken == null )
1000+ this . _shouldAppendEosToken = this . bos != null && this . _model . shouldAppendEosToken ( ) ;
1001+
1002+ return this . _shouldAppendEosToken ;
1003+ }
1004+
9241005 /** @internal */
9251006 private _ensureNotDisposed ( ) {
9261007 if ( this . _disposedState . disposed )
0 commit comments