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 3.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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, 0 = from model
  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. /// RoPE scaling type, from `enum llama_rope_scaling_type`
  39. /// </summary>
  40. public RopeScalingType rope_scaling_type;
  41. /// <summary>
  42. /// RoPE base frequency, 0 = from model
  43. /// </summary>
  44. public float rope_freq_base;
  45. /// <summary>
  46. /// RoPE frequency scaling factor, 0 = from model
  47. /// </summary>
  48. public float rope_freq_scale;
  49. /// <summary>
  50. /// YaRN extrapolation mix factor, negative = from model
  51. /// </summary>
  52. public float yarn_ext_factor;
  53. /// <summary>
  54. /// YaRN magnitude scaling factor
  55. /// </summary>
  56. public float yarn_attn_factor;
  57. /// <summary>
  58. /// YaRN low correction dim
  59. /// </summary>
  60. public float yarn_beta_fast;
  61. /// <summary>
  62. /// YaRN high correction dim
  63. /// </summary>
  64. public float yarn_beta_slow;
  65. /// <summary>
  66. /// YaRN original context size
  67. /// </summary>
  68. public uint yarn_orig_ctx;
  69. /// <summary>
  70. /// data type for K cache
  71. /// </summary>
  72. public GGMLType type_k;
  73. /// <summary>
  74. /// data type for V cache
  75. /// </summary>
  76. public GGMLType type_v;
  77. /// <summary>
  78. /// Deprecated!
  79. /// </summary>
  80. private sbyte _mul_mat_q;
  81. /// <summary>
  82. /// Deprecated!
  83. /// </summary>
  84. private sbyte _logits_all;
  85. /// <summary>
  86. /// embedding mode only
  87. /// </summary>
  88. public bool embedding
  89. {
  90. readonly get => Convert.ToBoolean(_embedding);
  91. set => _embedding = Convert.ToSByte(value);
  92. }
  93. private sbyte _embedding;
  94. /// <summary>
  95. /// whether to offload the KQV ops (including the KV cache) to GPU
  96. /// </summary>
  97. public bool offload_kqv
  98. {
  99. readonly get => Convert.ToBoolean(_offload_kqv);
  100. set => _offload_kqv = Convert.ToSByte(value);
  101. }
  102. private sbyte _offload_kqv;
  103. }
  104. }