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.5 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, NaN = 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. /// if true, use experimental mul_mat_q kernels
  71. /// </summary>
  72. public bool mul_mat_q
  73. {
  74. readonly get => Convert.ToBoolean(_mul_mat_q);
  75. set => _mul_mat_q = Convert.ToSByte(value);
  76. }
  77. private sbyte _mul_mat_q;
  78. /// <summary>
  79. /// use fp16 for KV cache
  80. /// </summary>
  81. public bool f16_kv
  82. {
  83. readonly get => Convert.ToBoolean(_f16_kv);
  84. set => _f16_kv = Convert.ToSByte(value);
  85. }
  86. private sbyte _f16_kv;
  87. /// <summary>
  88. /// the llama_eval() call computes all logits, not just the last one
  89. /// </summary>
  90. public bool logits_all
  91. {
  92. readonly get => Convert.ToBoolean(_logits_all);
  93. set => _logits_all = Convert.ToSByte(value);
  94. }
  95. private sbyte _logits_all;
  96. /// <summary>
  97. /// embedding mode only
  98. /// </summary>
  99. public bool embedding
  100. {
  101. readonly get => Convert.ToBoolean(_embedding);
  102. set => _embedding = Convert.ToSByte(value);
  103. }
  104. private sbyte _embedding;
  105. }
  106. }