# Utils
Namespace: LLama
Assorted llama utilities
```csharp
public static class Utils
```
Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [Utils](./llama.utils.md)
## Methods
### **InitLLamaContextFromModelParams(IModelParams)**
#### Caution
Use LLamaWeights.LoadFromFile and LLamaWeights.CreateContext instead
---
```csharp
public static SafeLLamaContextHandle InitLLamaContextFromModelParams(IModelParams params)
```
#### Parameters
`params` [IModelParams](./llama.abstractions.imodelparams.md)
#### Returns
[SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
### **Tokenize(SafeLLamaContextHandle, String, Boolean, Encoding)**
#### Caution
Use SafeLLamaContextHandle Tokenize method instead
---
```csharp
public static IEnumerable Tokenize(SafeLLamaContextHandle ctx, string text, bool add_bos, Encoding encoding)
```
#### Parameters
`ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
`text` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
`add_bos` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
`encoding` [Encoding](https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding)
#### Returns
[IEnumerable<Int32>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
### **GetLogits(SafeLLamaContextHandle, Int32)**
#### Caution
Use SafeLLamaContextHandle GetLogits method instead
---
```csharp
public static Span GetLogits(SafeLLamaContextHandle ctx, int length)
```
#### Parameters
`ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
`length` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
#### Returns
[Span<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
### **Eval(SafeLLamaContextHandle, Int32[], Int32, Int32, Int32, Int32)**
#### Caution
Use SafeLLamaContextHandle Eval method instead
---
```csharp
public static int Eval(SafeLLamaContextHandle ctx, Int32[] tokens, int startIndex, int n_tokens, int n_past, int n_threads)
```
#### Parameters
`ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
`tokens` [Int32[]](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
`startIndex` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
`n_tokens` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
`n_past` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
`n_threads` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
#### Returns
[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
### **TokenToString(Int32, SafeLLamaContextHandle, Encoding)**
#### Caution
Use SafeLLamaContextHandle TokenToString method instead
---
```csharp
public static string TokenToString(int token, SafeLLamaContextHandle ctx, Encoding encoding)
```
#### Parameters
`token` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
`ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
`encoding` [Encoding](https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding)
#### Returns
[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
### **PtrToString(IntPtr, Encoding)**
#### Caution
No longer used internally by LlamaSharp
---
```csharp
public static string PtrToString(IntPtr ptr, Encoding encoding)
```
#### Parameters
`ptr` [IntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.intptr)
`encoding` [Encoding](https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding)
#### Returns
[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)