3.7 KiB
3.7 KiB
Utils
Namespace: LLama
Assorted llama utilities
public static class Utils
Methods
InitLLamaContextFromModelParams(IModelParams)
Caution
Use LLamaWeights.LoadFromFile and LLamaWeights.CreateContext instead
public static SafeLLamaContextHandle InitLLamaContextFromModelParams(IModelParams params)
Parameters
params
IModelParams
Returns
Tokenize(SafeLLamaContextHandle, String, Boolean, Encoding)
Caution
Use SafeLLamaContextHandle Tokenize method instead
public static IEnumerable<int> Tokenize(SafeLLamaContextHandle ctx, string text, bool add_bos, Encoding encoding)
Parameters
text
String
add_bos
Boolean
encoding
Encoding
Returns
GetLogits(SafeLLamaContextHandle, Int32)
Caution
Use SafeLLamaContextHandle GetLogits method instead
public static Span<float> GetLogits(SafeLLamaContextHandle ctx, int length)
Parameters
length
Int32
Returns
Eval(SafeLLamaContextHandle, Int32[], Int32, Int32, Int32, Int32)
Caution
Use SafeLLamaContextHandle Eval method instead
public static int Eval(SafeLLamaContextHandle ctx, Int32[] tokens, int startIndex, int n_tokens, int n_past, int n_threads)
Parameters
tokens
Int32[]
startIndex
Int32
n_tokens
Int32
n_past
Int32
n_threads
Int32
Returns
TokenToString(Int32, SafeLLamaContextHandle, Encoding)
Caution
Use SafeLLamaContextHandle TokenToString method instead
public static string TokenToString(int token, SafeLLamaContextHandle ctx, Encoding encoding)
Parameters
token
Int32
encoding
Encoding
Returns
PtrToString(IntPtr, Encoding)
Caution
No longer used internally by LlamaSharp
public static string PtrToString(IntPtr ptr, Encoding encoding)
Parameters
ptr
IntPtr
encoding
Encoding