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.

NativeApi.BeamSearch.cs 1.5 kB

12345678910111213141516171819202122232425
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace LLama.Native;
  4. public partial class NativeApi
  5. {
  6. /// <summary>
  7. /// Type of pointer to the beam_search_callback function.
  8. /// </summary>
  9. /// <param name="callback_data">callback_data is any custom data passed to llama_beam_search, that is subsequently passed back to beam_search_callbac</param>
  10. /// <param name="state"></param>
  11. public delegate void LLamaBeamSearchCallback(IntPtr callback_data, LLamaBeamsState state);
  12. /// <summary>Deterministically returns entire sentence constructed by a beam search.</summary>
  13. /// <param name="ctx">Pointer to the llama_context.</param>
  14. /// <param name="callback">Invoked for each iteration of the beam_search loop, passing in beams_state.</param>
  15. /// <param name="callback_data">A pointer that is simply passed back to callback.</param>
  16. /// <param name="n_beams">Number of beams to use.</param>
  17. /// <param name="n_past">Number of tokens already evaluated.</param>
  18. /// <param name="n_predict">Maximum number of tokens to predict. EOS may occur earlier.</param>
  19. /// <param name="n_threads">Number of threads.</param>
  20. [DllImport(libraryName, EntryPoint = "llama_beam_search", CallingConvention = CallingConvention.Cdecl)]
  21. public static extern void llama_beam_search(SafeLLamaContextHandle ctx, LLamaBeamSearchCallback callback, IntPtr callback_data, ulong n_beams, int n_past, int n_predict, int n_threads);
  22. }