Added a safe method for `llama_get_logits_ith`

This commit is contained in:
Martin Evans 2023-10-28 23:15:45 +01:00
parent cdf20d3c7a
commit 51c292ebd8
1 changed files with 16 additions and 0 deletions

View File

@ -114,6 +114,22 @@ namespace LLama.Native
}
}
/// <summary>
/// Logits for the ith token. Equivalent to: llama_get_logits(ctx) + i*n_vocab
/// </summary>
/// <param name="i"></param>
/// <returns></returns>
public Span<float> GetLogitsIth(int i)
{
var model = ThrowIfDisposed();
unsafe
{
var logits = NativeApi.llama_get_logits_ith(this, i);
return new Span<float>(logits, model.VocabCount);
}
}
#region tokens
/// <summary>
/// Convert the given text into tokens