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.

LLamaContextParams.cs 2.7 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace LLama.Native
  4. {
  5. /// <summary>
  6. /// Called by llama.cpp with a progress value between 0 and 1
  7. /// </summary>
  8. /// <param name="progress"></param>
  9. /// <param name="ctx"></param>
  10. public delegate void LlamaProgressCallback(float progress, IntPtr ctx);
  11. /// <summary>
  12. /// A C# representation of the llama.cpp `llama_context_params` struct
  13. /// </summary>
  14. [StructLayout(LayoutKind.Sequential)]
  15. public struct LLamaContextParams
  16. {
  17. /// <summary>
  18. /// RNG seed, -1 for random
  19. /// </summary>
  20. public uint seed;
  21. /// <summary>
  22. /// text context
  23. /// </summary>
  24. public uint n_ctx;
  25. /// <summary>
  26. /// prompt processing batch size
  27. /// </summary>
  28. public uint n_batch;
  29. /// <summary>
  30. /// number of threads to use for generation
  31. /// </summary>
  32. public uint n_threads;
  33. /// <summary>
  34. /// number of threads to use for batch processing
  35. /// </summary>
  36. public uint n_threads_batch;
  37. /// <summary>
  38. /// ref: https://github.com/ggerganov/llama.cpp/pull/2054
  39. /// RoPE base frequency
  40. /// </summary>
  41. public float rope_freq_base;
  42. /// <summary>
  43. /// ref: https://github.com/ggerganov/llama.cpp/pull/2054
  44. /// RoPE frequency scaling factor
  45. /// </summary>
  46. public float rope_freq_scale;
  47. /// <summary>
  48. /// if true, use experimental mul_mat_q kernels
  49. /// </summary>
  50. public bool mul_mat_q
  51. {
  52. readonly get => Convert.ToBoolean(_mul_mat_q);
  53. set => _mul_mat_q = Convert.ToSByte(value);
  54. }
  55. private sbyte _mul_mat_q;
  56. /// <summary>
  57. /// use fp16 for KV cache
  58. /// </summary>
  59. public bool f16_kv
  60. {
  61. readonly get => Convert.ToBoolean(_f16_kv);
  62. set => _f16_kv = Convert.ToSByte(value);
  63. }
  64. private sbyte _f16_kv;
  65. /// <summary>
  66. /// the llama_eval() call computes all logits, not just the last one
  67. /// </summary>
  68. public bool logits_all
  69. {
  70. readonly get => Convert.ToBoolean(_logits_all);
  71. set => _logits_all = Convert.ToSByte(value);
  72. }
  73. private sbyte _logits_all;
  74. /// <summary>
  75. /// embedding mode only
  76. /// </summary>
  77. public bool embedding
  78. {
  79. readonly get => Convert.ToBoolean(_embedding);
  80. set => _embedding = Convert.ToSByte(value);
  81. }
  82. private sbyte _embedding;
  83. }
  84. }