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.

parameters.md 4.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. # LLamaModel Parameters
  2. When initializing a `LLamaModel` object, there're three parameters, `ModelParams Params, string encoding = "UTF-8", ILLamaLogger? logger = null`.
  3. The usage of `logger` will be further introduced in [logger doc](../More/log.md). The `encoding` is the encoding you want to use when dealing with text via this model.
  4. The most improtant of all, is the `ModelParams`, which is defined as below. We'll explain the parameters step by step in this document.
  5. ```cs
  6. public class ModelParams
  7. {
  8. public int ContextSize { get; set; } = 512;
  9. public int GpuLayerCount { get; set; } = 20;
  10. public int Seed { get; set; } = 1686349486;
  11. public bool UseFp16Memory { get; set; } = true;
  12. public bool UseMemorymap { get; set; } = true;
  13. public bool UseMemoryLock { get; set; } = false;
  14. public bool Perplexity { get; set; } = false;
  15. public string ModelPath { get; set; }
  16. public string LoraAdapter { get; set; } = string.Empty;
  17. public string LoraBase { get; set; } = string.Empty;
  18. public int Threads { get; set; } = Math.Max(Environment.ProcessorCount / 2, 1);
  19. public int BatchSize { get; set; } = 512;
  20. public bool ConvertEosToNewLine { get; set; } = false;
  21. }
  22. ```
  23. # ModelParams
  24. Namespace: LLama.Common
  25. ```csharp
  26. public class ModelParams
  27. ```
  28. Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ModelParams]()
  29. ## Properties
  30. ### **ContextSize**
  31. Model context size (n_ctx)
  32. ```csharp
  33. public int ContextSize { get; set; }
  34. ```
  35. #### Property Value
  36. [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  37. ### **GpuLayerCount**
  38. Number of layers to run in VRAM / GPU memory (n_gpu_layers)
  39. ```csharp
  40. public int GpuLayerCount { get; set; }
  41. ```
  42. #### Property Value
  43. [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  44. ### **Seed**
  45. Seed for the random number generator (seed)
  46. ```csharp
  47. public int Seed { get; set; }
  48. ```
  49. #### Property Value
  50. [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  51. ### **UseFp16Memory**
  52. Use f16 instead of f32 for memory kv (memory_f16)
  53. ```csharp
  54. public bool UseFp16Memory { get; set; }
  55. ```
  56. #### Property Value
  57. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  58. ### **UseMemorymap**
  59. Use mmap for faster loads (use_mmap)
  60. ```csharp
  61. public bool UseMemorymap { get; set; }
  62. ```
  63. #### Property Value
  64. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  65. ### **UseMemoryLock**
  66. Use mlock to keep model in memory (use_mlock)
  67. ```csharp
  68. public bool UseMemoryLock { get; set; }
  69. ```
  70. #### Property Value
  71. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  72. ### **Perplexity**
  73. Compute perplexity over the prompt (perplexity)
  74. ```csharp
  75. public bool Perplexity { get; set; }
  76. ```
  77. #### Property Value
  78. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  79. ### **ModelPath**
  80. Model path (model)
  81. ```csharp
  82. public string ModelPath { get; set; }
  83. ```
  84. #### Property Value
  85. [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  86. ### **LoraAdapter**
  87. lora adapter path (lora_adapter)
  88. ```csharp
  89. public string LoraAdapter { get; set; }
  90. ```
  91. #### Property Value
  92. [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  93. ### **LoraBase**
  94. base model path for the lora adapter (lora_base)
  95. ```csharp
  96. public string LoraBase { get; set; }
  97. ```
  98. #### Property Value
  99. [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  100. ### **Threads**
  101. Number of threads (-1 = autodetect) (n_threads)
  102. ```csharp
  103. public int Threads { get; set; }
  104. ```
  105. #### Property Value
  106. [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  107. ### **BatchSize**
  108. batch size for prompt processing (must be &gt;=32 to use BLAS) (n_batch)
  109. ```csharp
  110. public int BatchSize { get; set; }
  111. ```
  112. #### Property Value
  113. [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  114. ### **ConvertEosToNewLine**
  115. Whether to convert eos to newline during the inference.
  116. ```csharp
  117. public bool ConvertEosToNewLine { get; set; }
  118. ```
  119. #### Property Value
  120. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  121. ### **EmbeddingMode**
  122. Whether to use embedding mode. (embedding) Note that if this is set to true,
  123. The LLamaModel won't produce text response anymore.
  124. ```csharp
  125. public bool EmbeddingMode { get; set; }
  126. ```
  127. #### Property Value
  128. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>

C#/.NET上易用的LLM高性能推理框架,支持LLaMA和LLaVA系列模型。