You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ITokenDataProcessor.cs 1.1 kB

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using LLama.Native;
  3. namespace LLama.Sampling.Tokens;
  4. using llama_token = Int32;
  5. /// <summary>
  6. /// Processes token logits before sampling, applying penalties to certain tokens
  7. /// </summary>
  8. public interface ITokenDataProcessor
  9. : IDisposable
  10. {
  11. /// <summary>
  12. /// Process token logits in a LLamaTokenDataArray
  13. /// </summary>
  14. /// <param name="ctx">The context this is operating in</param>
  15. /// <param name="tokens">The token data array to process</param>
  16. /// <param name="lastTokens">The most recent tokens output</param>
  17. /// <returns>LLamaTokenDataArray, created from logits</returns>
  18. void ProcessTokens(SafeLLamaContextHandle ctx, LLamaTokenDataArray tokens, ReadOnlySpan<llama_token> lastTokens);
  19. /// <summary>
  20. /// Inform this process when a token is accepted by the model
  21. /// </summary>
  22. /// <param name="ctx"></param>
  23. /// <param name="token"></param>
  24. void AcceptToken(SafeLLamaContextHandle ctx, int token);
  25. /// <summary>
  26. /// Reset all internal sampling state
  27. /// </summary>
  28. void Reset();
  29. }