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.

ModelOptions.cs 3.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using LLama.Abstractions;
  2. namespace LLama.Web.Common
  3. {
  4. public class ModelOptions : IModelParams
  5. {
  6. public string Name { get; set; }
  7. public int MaxInstances { get; set; }
  8. /// <summary>
  9. /// Model context size (n_ctx)
  10. /// </summary>
  11. public int ContextSize { get; set; } = 512;
  12. /// <summary>
  13. /// the GPU that is used for scratch and small tensors
  14. /// </summary>
  15. public int MainGpu { get; set; } = 0;
  16. /// <summary>
  17. /// if true, reduce VRAM usage at the cost of performance
  18. /// </summary>
  19. public bool LowVram { get; set; } = false;
  20. /// <summary>
  21. /// Number of layers to run in VRAM / GPU memory (n_gpu_layers)
  22. /// </summary>
  23. public int GpuLayerCount { get; set; } = 20;
  24. /// <summary>
  25. /// Seed for the random number generator (seed)
  26. /// </summary>
  27. public int Seed { get; set; } = 1686349486;
  28. /// <summary>
  29. /// Use f16 instead of f32 for memory kv (memory_f16)
  30. /// </summary>
  31. public bool UseFp16Memory { get; set; } = true;
  32. /// <summary>
  33. /// Use mmap for faster loads (use_mmap)
  34. /// </summary>
  35. public bool UseMemorymap { get; set; } = true;
  36. /// <summary>
  37. /// Use mlock to keep model in memory (use_mlock)
  38. /// </summary>
  39. public bool UseMemoryLock { get; set; } = false;
  40. /// <summary>
  41. /// Compute perplexity over the prompt (perplexity)
  42. /// </summary>
  43. public bool Perplexity { get; set; } = false;
  44. /// <summary>
  45. /// Model path (model)
  46. /// </summary>
  47. public string ModelPath { get; set; }
  48. /// <summary>
  49. /// model alias
  50. /// </summary>
  51. public string ModelAlias { get; set; } = "unknown";
  52. /// <summary>
  53. /// lora adapter path (lora_adapter)
  54. /// </summary>
  55. public string LoraAdapter { get; set; } = string.Empty;
  56. /// <summary>
  57. /// base model path for the lora adapter (lora_base)
  58. /// </summary>
  59. public string LoraBase { get; set; } = string.Empty;
  60. /// <summary>
  61. /// Number of threads (-1 = autodetect) (n_threads)
  62. /// </summary>
  63. public int Threads { get; set; } = Math.Max(Environment.ProcessorCount / 2, 1);
  64. /// <summary>
  65. /// batch size for prompt processing (must be >=32 to use BLAS) (n_batch)
  66. /// </summary>
  67. public int BatchSize { get; set; } = 512;
  68. /// <summary>
  69. /// Whether to convert eos to newline during the inference.
  70. /// </summary>
  71. public bool ConvertEosToNewLine { get; set; } = false;
  72. /// <summary>
  73. /// Whether to use embedding mode. (embedding) Note that if this is set to true,
  74. /// The LLamaModel won't produce text response anymore.
  75. /// </summary>
  76. public bool EmbeddingMode { get; set; } = false;
  77. /// <summary>
  78. /// how split tensors should be distributed across GPUs
  79. /// </summary>
  80. public nint TensorSplits { get; set; }
  81. /// <summary>
  82. /// Grouped-Query Attention
  83. /// </summary>
  84. public int GroupedQueryAttention { get; set; } = 1;
  85. /// <summary>
  86. /// RMS Norm Epsilon
  87. /// </summary>
  88. public float RmsNormEpsilon { get; set; } = 5e-6f;
  89. /// <summary>
  90. /// RoPE base frequency
  91. /// </summary>
  92. public float RopeFrequencyBase { get; set; } = 10000.0f;
  93. /// <summary>
  94. /// RoPE frequency scaling factor
  95. /// </summary>
  96. public float RopeFrequencyScale { get; set; } = 1.0f;
  97. /// <summary>
  98. /// Use experimental mul_mat_q kernels
  99. /// </summary>
  100. public bool MulMatQ { get; set; }
  101. }
  102. }