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

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