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.

llama.common.modelparams.md 9.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. # ModelParams
  2. Namespace: LLama.Common
  3. The parameters for initializing a LLama model.
  4. ```csharp
  5. public class ModelParams : LLama.Abstractions.IModelParams, System.IEquatable`1[[LLama.Common.ModelParams, LLamaSharp, Version=0.5.0.0, Culture=neutral, PublicKeyToken=null]]
  6. ```
  7. Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ModelParams](./llama.common.modelparams.md)<br>
  8. Implements [IModelParams](./llama.abstractions.imodelparams.md), [IEquatable&lt;ModelParams&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1)
  9. ## Properties
  10. ### **ContextSize**
  11. Model context size (n_ctx)
  12. ```csharp
  13. public int ContextSize { get; set; }
  14. ```
  15. #### Property Value
  16. [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  17. ### **MainGpu**
  18. the GPU that is used for scratch and small tensors
  19. ```csharp
  20. public int MainGpu { get; set; }
  21. ```
  22. #### Property Value
  23. [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  24. ### **LowVram**
  25. if true, reduce VRAM usage at the cost of performance
  26. ```csharp
  27. public bool LowVram { get; set; }
  28. ```
  29. #### Property Value
  30. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  31. ### **GpuLayerCount**
  32. Number of layers to run in VRAM / GPU memory (n_gpu_layers)
  33. ```csharp
  34. public int GpuLayerCount { get; set; }
  35. ```
  36. #### Property Value
  37. [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  38. ### **Seed**
  39. Seed for the random number generator (seed)
  40. ```csharp
  41. public int Seed { get; set; }
  42. ```
  43. #### Property Value
  44. [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  45. ### **UseFp16Memory**
  46. Use f16 instead of f32 for memory kv (memory_f16)
  47. ```csharp
  48. public bool UseFp16Memory { get; set; }
  49. ```
  50. #### Property Value
  51. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  52. ### **UseMemorymap**
  53. Use mmap for faster loads (use_mmap)
  54. ```csharp
  55. public bool UseMemorymap { get; set; }
  56. ```
  57. #### Property Value
  58. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  59. ### **UseMemoryLock**
  60. Use mlock to keep model in memory (use_mlock)
  61. ```csharp
  62. public bool UseMemoryLock { get; set; }
  63. ```
  64. #### Property Value
  65. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  66. ### **Perplexity**
  67. Compute perplexity over the prompt (perplexity)
  68. ```csharp
  69. public bool Perplexity { get; set; }
  70. ```
  71. #### Property Value
  72. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  73. ### **ModelPath**
  74. Model path (model)
  75. ```csharp
  76. public string ModelPath { get; set; }
  77. ```
  78. #### Property Value
  79. [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  80. ### **ModelAlias**
  81. model alias
  82. ```csharp
  83. public string ModelAlias { get; set; }
  84. ```
  85. #### Property Value
  86. [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  87. ### **LoraAdapter**
  88. lora adapter path (lora_adapter)
  89. ```csharp
  90. public string LoraAdapter { get; set; }
  91. ```
  92. #### Property Value
  93. [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  94. ### **LoraBase**
  95. base model path for the lora adapter (lora_base)
  96. ```csharp
  97. public string LoraBase { get; set; }
  98. ```
  99. #### Property Value
  100. [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  101. ### **Threads**
  102. Number of threads (-1 = autodetect) (n_threads)
  103. ```csharp
  104. public int Threads { get; set; }
  105. ```
  106. #### Property Value
  107. [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  108. ### **BatchSize**
  109. batch size for prompt processing (must be &gt;=32 to use BLAS) (n_batch)
  110. ```csharp
  111. public int BatchSize { get; set; }
  112. ```
  113. #### Property Value
  114. [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  115. ### **ConvertEosToNewLine**
  116. Whether to convert eos to newline during the inference.
  117. ```csharp
  118. public bool ConvertEosToNewLine { get; set; }
  119. ```
  120. #### Property Value
  121. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  122. ### **EmbeddingMode**
  123. Whether to use embedding mode. (embedding) Note that if this is set to true,
  124. The LLamaModel won't produce text response anymore.
  125. ```csharp
  126. public bool EmbeddingMode { get; set; }
  127. ```
  128. #### Property Value
  129. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  130. ### **TensorSplits**
  131. how split tensors should be distributed across GPUs
  132. ```csharp
  133. public Single[] TensorSplits { get; set; }
  134. ```
  135. #### Property Value
  136. [Single[]](https://docs.microsoft.com/en-us/dotnet/api/system.single)<br>
  137. ### **RopeFrequencyBase**
  138. RoPE base frequency
  139. ```csharp
  140. public float RopeFrequencyBase { get; set; }
  141. ```
  142. #### Property Value
  143. [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)<br>
  144. ### **RopeFrequencyScale**
  145. RoPE frequency scaling factor
  146. ```csharp
  147. public float RopeFrequencyScale { get; set; }
  148. ```
  149. #### Property Value
  150. [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)<br>
  151. ### **MulMatQ**
  152. Use experimental mul_mat_q kernels
  153. ```csharp
  154. public bool MulMatQ { get; set; }
  155. ```
  156. #### Property Value
  157. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  158. ### **Encoding**
  159. The encoding to use to convert text for the model
  160. ```csharp
  161. public Encoding Encoding { get; set; }
  162. ```
  163. #### Property Value
  164. [Encoding](https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding)<br>
  165. ## Constructors
  166. ### **ModelParams(String)**
  167. ```csharp
  168. public ModelParams(string modelPath)
  169. ```
  170. #### Parameters
  171. `modelPath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  172. The model path.
  173. ### **ModelParams(String, Int32, Int32, Int32, Boolean, Boolean, Boolean, Boolean, String, String, Int32, Int32, Boolean, Boolean, Single, Single, Boolean, String)**
  174. #### Caution
  175. Use object initializer to set all optional parameters
  176. ---
  177. ```csharp
  178. public ModelParams(string modelPath, int contextSize, int gpuLayerCount, int seed, bool useFp16Memory, bool useMemorymap, bool useMemoryLock, bool perplexity, string loraAdapter, string loraBase, int threads, int batchSize, bool convertEosToNewLine, bool embeddingMode, float ropeFrequencyBase, float ropeFrequencyScale, bool mulMatQ, string encoding)
  179. ```
  180. #### Parameters
  181. `modelPath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  182. The model path.
  183. `contextSize` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  184. Model context size (n_ctx)
  185. `gpuLayerCount` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  186. Number of layers to run in VRAM / GPU memory (n_gpu_layers)
  187. `seed` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  188. Seed for the random number generator (seed)
  189. `useFp16Memory` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  190. Whether to use f16 instead of f32 for memory kv (memory_f16)
  191. `useMemorymap` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  192. Whether to use mmap for faster loads (use_mmap)
  193. `useMemoryLock` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  194. Whether to use mlock to keep model in memory (use_mlock)
  195. `perplexity` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  196. Thether to compute perplexity over the prompt (perplexity)
  197. `loraAdapter` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  198. Lora adapter path (lora_adapter)
  199. `loraBase` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  200. Base model path for the lora adapter (lora_base)
  201. `threads` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  202. Number of threads (-1 = autodetect) (n_threads)
  203. `batchSize` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  204. Batch size for prompt processing (must be &gt;=32 to use BLAS) (n_batch)
  205. `convertEosToNewLine` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  206. Whether to convert eos to newline during the inference.
  207. `embeddingMode` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  208. Whether to use embedding mode. (embedding) Note that if this is set to true, The LLamaModel won't produce text response anymore.
  209. `ropeFrequencyBase` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)<br>
  210. RoPE base frequency.
  211. `ropeFrequencyScale` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)<br>
  212. RoPE frequency scaling factor
  213. `mulMatQ` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  214. Use experimental mul_mat_q kernels
  215. `encoding` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  216. The encoding to use to convert text for the model
  217. ## Methods
  218. ### **ToString()**
  219. ```csharp
  220. public string ToString()
  221. ```
  222. #### Returns
  223. [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  224. ### **PrintMembers(StringBuilder)**
  225. ```csharp
  226. protected bool PrintMembers(StringBuilder builder)
  227. ```
  228. #### Parameters
  229. `builder` [StringBuilder](https://docs.microsoft.com/en-us/dotnet/api/system.text.stringbuilder)<br>
  230. #### Returns
  231. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  232. ### **GetHashCode()**
  233. ```csharp
  234. public int GetHashCode()
  235. ```
  236. #### Returns
  237. [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  238. ### **Equals(Object)**
  239. ```csharp
  240. public bool Equals(object obj)
  241. ```
  242. #### Parameters
  243. `obj` [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object)<br>
  244. #### Returns
  245. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  246. ### **Equals(ModelParams)**
  247. ```csharp
  248. public bool Equals(ModelParams other)
  249. ```
  250. #### Parameters
  251. `other` [ModelParams](./llama.common.modelparams.md)<br>
  252. #### Returns
  253. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  254. ### **&lt;Clone&gt;$()**
  255. ```csharp
  256. public ModelParams <Clone>$()
  257. ```
  258. #### Returns
  259. [ModelParams](./llama.common.modelparams.md)<br>