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

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