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.oldversion.llamamodel.md 12 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. # LLamaModel
  2. Namespace: LLama.OldVersion
  3. #### Caution
  4. The entire LLama.OldVersion namespace will be removed
  5. ---
  6. ```csharp
  7. public class LLamaModel : IChatModel, System.IDisposable
  8. ```
  9. Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [LLamaModel](./llama.oldversion.llamamodel.md)<br>
  10. Implements [IChatModel](./llama.oldversion.ichatmodel.md), [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
  11. ## Properties
  12. ### **Name**
  13. ```csharp
  14. public string Name { get; set; }
  15. ```
  16. #### Property Value
  17. [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  18. ### **Verbose**
  19. ```csharp
  20. public bool Verbose { get; set; }
  21. ```
  22. #### Property Value
  23. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  24. ### **NativeHandle**
  25. ```csharp
  26. public SafeLLamaContextHandle NativeHandle { get; }
  27. ```
  28. #### Property Value
  29. [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)<br>
  30. ## Constructors
  31. ### **LLamaModel(String, String, Boolean, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Dictionary&lt;Int32, Single&gt;, Int32, Single, Single, Single, Single, Single, Int32, Single, Single, Int32, Single, Single, String, String, String, String, List&lt;String&gt;, String, String, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, String)**
  32. Please refer `LLamaParams` to find the meanings of each arg. Be sure to have set the `n_gpu_layers`, otherwise it will
  33. load 20 layers to gpu by default.
  34. ```csharp
  35. public LLamaModel(string model_path, string model_name, bool verbose, int seed, int n_threads, int n_predict, int n_ctx, int n_batch, int n_keep, int n_gpu_layers, Dictionary<int, float> logit_bias, int top_k, float top_p, float tfs_z, float typical_p, float temp, float repeat_penalty, int repeat_last_n, float frequency_penalty, float presence_penalty, int mirostat, float mirostat_tau, float mirostat_eta, string prompt, string path_session, string input_prefix, string input_suffix, List<string> antiprompt, string lora_adapter, string lora_base, bool memory_f16, bool random_prompt, bool use_color, bool interactive, bool embedding, bool interactive_first, bool prompt_cache_all, bool instruct, bool penalize_nl, bool perplexity, bool use_mmap, bool use_mlock, bool mem_test, bool verbose_prompt, string encoding)
  36. ```
  37. #### Parameters
  38. `model_path` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  39. The model file path.
  40. `model_name` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  41. The model name.
  42. `verbose` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  43. Whether to print details when running the model.
  44. `seed` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  45. `n_threads` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  46. `n_predict` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  47. `n_ctx` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  48. `n_batch` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  49. `n_keep` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  50. `n_gpu_layers` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  51. `logit_bias` [Dictionary&lt;Int32, Single&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2)<br>
  52. `top_k` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  53. `top_p` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)<br>
  54. `tfs_z` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)<br>
  55. `typical_p` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)<br>
  56. `temp` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)<br>
  57. `repeat_penalty` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)<br>
  58. `repeat_last_n` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  59. `frequency_penalty` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)<br>
  60. `presence_penalty` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)<br>
  61. `mirostat` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  62. `mirostat_tau` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)<br>
  63. `mirostat_eta` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)<br>
  64. `prompt` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  65. `path_session` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  66. `input_prefix` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  67. `input_suffix` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  68. `antiprompt` [List&lt;String&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)<br>
  69. `lora_adapter` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  70. `lora_base` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  71. `memory_f16` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  72. `random_prompt` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  73. `use_color` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  74. `interactive` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  75. `embedding` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  76. `interactive_first` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  77. `prompt_cache_all` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  78. `instruct` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  79. `penalize_nl` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  80. `perplexity` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  81. `use_mmap` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  82. `use_mlock` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  83. `mem_test` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  84. `verbose_prompt` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  85. `encoding` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  86. ### **LLamaModel(LLamaParams, String, Boolean, String)**
  87. Please refer `LLamaParams` to find the meanings of each arg. Be sure to have set the `n_gpu_layers`, otherwise it will
  88. load 20 layers to gpu by default.
  89. ```csharp
  90. public LLamaModel(LLamaParams params, string name, bool verbose, string encoding)
  91. ```
  92. #### Parameters
  93. `params` [LLamaParams](./llama.oldversion.llamaparams.md)<br>
  94. The LLamaModel params
  95. `name` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  96. Model name
  97. `verbose` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  98. Whether to output the detailed info.
  99. `encoding` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  100. #### Exceptions
  101. [RuntimeError](./llama.exceptions.runtimeerror.md)<br>
  102. ## Methods
  103. ### **WithPrompt(String, String)**
  104. Apply a prompt to the model.
  105. ```csharp
  106. public LLamaModel WithPrompt(string prompt, string encoding)
  107. ```
  108. #### Parameters
  109. `prompt` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  110. `encoding` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  111. #### Returns
  112. [LLamaModel](./llama.oldversion.llamamodel.md)<br>
  113. #### Exceptions
  114. [ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception)<br>
  115. ### **WithPromptFile(String)**
  116. Apply the prompt file to the model.
  117. ```csharp
  118. public LLamaModel WithPromptFile(string promptFileName)
  119. ```
  120. #### Parameters
  121. `promptFileName` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  122. #### Returns
  123. [LLamaModel](./llama.oldversion.llamamodel.md)<br>
  124. ### **InitChatPrompt(String, String)**
  125. ```csharp
  126. public void InitChatPrompt(string prompt, string encoding)
  127. ```
  128. #### Parameters
  129. `prompt` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  130. `encoding` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  131. ### **InitChatAntiprompt(String[])**
  132. ```csharp
  133. public void InitChatAntiprompt(String[] antiprompt)
  134. ```
  135. #### Parameters
  136. `antiprompt` [String[]](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  137. ### **Chat(String, String, String)**
  138. Chat with the LLaMa model under interactive mode.
  139. ```csharp
  140. public IEnumerable<string> Chat(string text, string prompt, string encoding)
  141. ```
  142. #### Parameters
  143. `text` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  144. `prompt` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  145. `encoding` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  146. #### Returns
  147. [IEnumerable&lt;String&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)<br>
  148. #### Exceptions
  149. [ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception)<br>
  150. ### **SaveState(String)**
  151. Save the state to specified path.
  152. ```csharp
  153. public void SaveState(string filename)
  154. ```
  155. #### Parameters
  156. `filename` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  157. ### **LoadState(String, Boolean)**
  158. Load the state from specified path.
  159. ```csharp
  160. public void LoadState(string filename, bool clearPreviousEmbed)
  161. ```
  162. #### Parameters
  163. `filename` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  164. `clearPreviousEmbed` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  165. Whether to clear previous footprints of this model.
  166. #### Exceptions
  167. [RuntimeError](./llama.exceptions.runtimeerror.md)<br>
  168. ### **Tokenize(String, String)**
  169. Tokenize a string.
  170. ```csharp
  171. public List<int> Tokenize(string text, string encoding)
  172. ```
  173. #### Parameters
  174. `text` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  175. The utf-8 encoded string to tokenize.
  176. `encoding` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  177. #### Returns
  178. [List&lt;Int32&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)<br>
  179. A list of tokens.
  180. #### Exceptions
  181. [RuntimeError](./llama.exceptions.runtimeerror.md)<br>
  182. If the tokenization failed.
  183. ### **DeTokenize(IEnumerable&lt;Int32&gt;)**
  184. Detokenize a list of tokens.
  185. ```csharp
  186. public string DeTokenize(IEnumerable<int> tokens)
  187. ```
  188. #### Parameters
  189. `tokens` [IEnumerable&lt;Int32&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)<br>
  190. The list of tokens to detokenize.
  191. #### Returns
  192. [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  193. The detokenized string.
  194. ### **Call(String, String)**
  195. Call the model to run inference.
  196. ```csharp
  197. public IEnumerable<string> Call(string text, string encoding)
  198. ```
  199. #### Parameters
  200. `text` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  201. `encoding` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  202. #### Returns
  203. [IEnumerable&lt;String&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)<br>
  204. #### Exceptions
  205. [RuntimeError](./llama.exceptions.runtimeerror.md)<br>
  206. ### **Dispose()**
  207. ```csharp
  208. public void Dispose()
  209. ```