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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using System.Text;
  2. using LLama.Abstractions;
  3. namespace LLama.Web.Common
  4. {
  5. public class ModelOptions
  6. : ILLamaParams
  7. {
  8. /// <summary>
  9. /// Model friendly name
  10. /// </summary>
  11. public string Name { get; set; }
  12. /// <summary>
  13. /// Max context insta=nces allowed per model
  14. /// </summary>
  15. public int MaxInstances { get; set; }
  16. /// <summary>
  17. /// Model context size (n_ctx)
  18. /// </summary>
  19. public uint ContextSize { get; set; } = 512;
  20. /// <summary>
  21. /// the GPU that is used for scratch and small tensors
  22. /// </summary>
  23. public int MainGpu { get; set; } = 0;
  24. /// <summary>
  25. /// if true, reduce VRAM usage at the cost of performance
  26. /// </summary>
  27. public bool LowVram { get; set; } = false;
  28. /// <summary>
  29. /// Number of layers to run in VRAM / GPU memory (n_gpu_layers)
  30. /// </summary>
  31. public int GpuLayerCount { get; set; } = 20;
  32. /// <summary>
  33. /// Seed for the random number generator (seed)
  34. /// </summary>
  35. public uint Seed { get; set; } = 1686349486;
  36. /// <summary>
  37. /// Use f16 instead of f32 for memory kv (memory_f16)
  38. /// </summary>
  39. public bool UseFp16Memory { get; set; } = true;
  40. /// <summary>
  41. /// Use mmap for faster loads (use_mmap)
  42. /// </summary>
  43. public bool UseMemorymap { get; set; } = true;
  44. /// <summary>
  45. /// Use mlock to keep model in memory (use_mlock)
  46. /// </summary>
  47. public bool UseMemoryLock { get; set; } = false;
  48. /// <summary>
  49. /// Compute perplexity over the prompt (perplexity)
  50. /// </summary>
  51. public bool Perplexity { get; set; } = false;
  52. /// <summary>
  53. /// Model path (model)
  54. /// </summary>
  55. public string ModelPath { get; set; }
  56. /// <summary>
  57. /// List of LoRAs to apply
  58. /// </summary>
  59. public AdapterCollection LoraAdapters { get; set; } = new();
  60. /// <summary>
  61. /// base model path for the lora adapter (lora_base)
  62. /// </summary>
  63. public string LoraBase { get; set; } = string.Empty;
  64. /// <summary>
  65. /// Number of threads (null = autodetect) (n_threads)
  66. /// </summary>
  67. public uint? Threads { get; set; }
  68. /// <summary>
  69. /// Number of threads to use for batch processing (null = autodetect) (n_threads)
  70. /// </summary>
  71. public uint? BatchThreads { get; set; }
  72. /// <summary>
  73. /// batch size for prompt processing (must be >=32 to use BLAS) (n_batch)
  74. /// </summary>
  75. public uint BatchSize { get; set; } = 512;
  76. /// <summary>
  77. /// Whether to convert eos to newline during the inference.
  78. /// </summary>
  79. public bool ConvertEosToNewLine { get; set; } = false;
  80. /// <summary>
  81. /// Whether to use embedding mode. (embedding) Note that if this is set to true,
  82. /// The LLamaModel won't produce text response anymore.
  83. /// </summary>
  84. public bool EmbeddingMode { get; set; } = false;
  85. /// <summary>
  86. /// how split tensors should be distributed across GPUs
  87. /// </summary>
  88. public TensorSplitsCollection TensorSplits { get; set; } = new();
  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. /// <summary>
  102. /// The encoding to use for models
  103. /// </summary>
  104. public Encoding Encoding { get; set; } = Encoding.UTF8;
  105. /// <summary>
  106. /// Load vocab only (no weights)
  107. /// </summary>
  108. public bool VocabOnly { get; set; }
  109. }
  110. }