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.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.InteropServices;
  4. using System.Text;
  5. namespace LLama.Native
  6. {
  7. public delegate void LlamaProgressCallback(float progress, IntPtr ctx);
  8. [StructLayout(LayoutKind.Sequential)]
  9. public struct LLamaContextParams
  10. {
  11. /// <summary>
  12. /// RNG seed, -1 for random
  13. /// </summary>
  14. public int seed;
  15. /// <summary>
  16. /// text context
  17. /// </summary>
  18. public int n_ctx;
  19. /// <summary>
  20. /// prompt processing batch size
  21. /// </summary>
  22. public int n_batch;
  23. /// <summary>
  24. /// grouped-query attention (TEMP - will be moved to model hparams)
  25. /// </summary>
  26. public int n_gqa;
  27. /// <summary>
  28. /// rms norm epsilon (TEMP - will be moved to model hparams)
  29. /// </summary>
  30. public float rms_norm_eps;
  31. /// <summary>
  32. /// number of layers to store in VRAM
  33. /// </summary>
  34. public int n_gpu_layers;
  35. /// <summary>
  36. /// the GPU that is used for scratch and small tensors
  37. /// </summary>
  38. public int main_gpu;
  39. /// <summary>
  40. /// how to split layers across multiple GPUs
  41. /// </summary>
  42. public float[] tensor_split;
  43. /// <summary>
  44. /// ref: https://github.com/ggerganov/llama.cpp/pull/2054
  45. /// RoPE base frequency
  46. /// </summary>
  47. public float rope_freq_base;
  48. /// <summary>
  49. /// ref: https://github.com/ggerganov/llama.cpp/pull/2054
  50. /// RoPE frequency scaling factor
  51. /// </summary>
  52. public float rope_freq_scale;
  53. /// <summary>
  54. /// called with a progress value between 0 and 1, pass NULL to disable
  55. /// </summary>
  56. public IntPtr progress_callback;
  57. /// <summary>
  58. /// context pointer passed to the progress callback
  59. /// </summary>
  60. public IntPtr progress_callback_user_data;
  61. /// <summary>
  62. /// if true, reduce VRAM usage at the cost of performance
  63. /// </summary>
  64. [MarshalAs(UnmanagedType.I1)]
  65. public bool low_vram;
  66. /// <summary>
  67. /// use fp16 for KV cache
  68. /// </summary>
  69. [MarshalAs(UnmanagedType.I1)]
  70. public bool f16_kv;
  71. /// <summary>
  72. /// the llama_eval() call computes all logits, not just the last one
  73. /// </summary>
  74. [MarshalAs(UnmanagedType.I1)]
  75. public bool logits_all;
  76. /// <summary>
  77. /// only load the vocabulary, no weights
  78. /// </summary>
  79. [MarshalAs(UnmanagedType.I1)]
  80. public bool vocab_only;
  81. /// <summary>
  82. /// use mmap if possible
  83. /// </summary>
  84. [MarshalAs(UnmanagedType.I1)]
  85. public bool use_mmap;
  86. /// <summary>
  87. /// force system to keep model in RAM
  88. /// </summary>
  89. [MarshalAs(UnmanagedType.I1)]
  90. public bool use_mlock;
  91. /// <summary>
  92. /// embedding mode only
  93. /// </summary>
  94. [MarshalAs(UnmanagedType.I1)]
  95. public bool embedding;
  96. }
  97. public struct TensorSplits
  98. {
  99. public float Item1;
  100. }
  101. }