| @@ -1,4 +1,4 @@ | |||||
| using LLama.Exceptions; | |||||
| using LLama.Exceptions; | |||||
| using LLama.Native; | using LLama.Native; | ||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| @@ -521,6 +521,17 @@ namespace LLama | |||||
| return candidates_p; | return candidates_p; | ||||
| } | } | ||||
| /// <summary> | |||||
| /// Gets whether or not the Bos token should be added. | |||||
| /// From common.cpp https://github.com/ggerganov/llama.cpp/blob/60325fa56f61c228464c9f065db3aa6a61f2156e/common/common.cpp#L2417 | |||||
| /// </summary> | |||||
| /// <returns></returns> | |||||
| public bool ShouldAddBosToken() | |||||
| { | |||||
| var addBos = NativeApi.llama_add_bos_token(NativeHandle.ModelHandle); | |||||
| return addBos != -1 ? Convert.ToBoolean(addBos) : NativeHandle.LLamaVocabType == LLamaVocabType.SentencePiece; | |||||
| } | |||||
| #region eval overloads | #region eval overloads | ||||
| /// <summary> | /// <summary> | ||||
| /// </summary> | /// </summary> | ||||
| @@ -1,4 +1,4 @@ | |||||
| using System; | |||||
| using System; | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Runtime.InteropServices; | using System.Runtime.InteropServices; | ||||
| using System.Text; | using System.Text; | ||||
| @@ -19,6 +19,8 @@ namespace LLama.Native | |||||
| /// </summary> | /// </summary> | ||||
| public int VocabCount => ThrowIfDisposed().VocabCount; | public int VocabCount => ThrowIfDisposed().VocabCount; | ||||
| public LLamaVocabType LLamaVocabType => ThrowIfDisposed().VocabType; | |||||
| /// <summary> | /// <summary> | ||||
| /// Total number of tokens in the context | /// Total number of tokens in the context | ||||
| /// </summary> | /// </summary> | ||||