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.

LLamaContextParams.cs 2.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.InteropServices;
  4. using System.Text;
  5. namespace LLama.Native
  6. {
  7. public delegate void LlamaProgressCallback(float progress, IntPtr ctx);
  8. [StructLayout(LayoutKind.Sequential)]
  9. public struct LLamaContextParams
  10. {
  11. /// <summary>
  12. /// text context
  13. /// </summary>
  14. public int n_ctx;
  15. /// <summary>
  16. /// -1 for default
  17. /// </summary>
  18. public int n_parts;
  19. /// <summary>
  20. /// number of layers to store in VRAM
  21. /// </summary>
  22. public int n_gpu_layers;
  23. /// <summary>
  24. /// RNG seed, -1 for random
  25. /// </summary>
  26. public int seed;
  27. /// <summary>
  28. /// use fp16 for KV cache
  29. /// </summary>
  30. [MarshalAs(UnmanagedType.I1)]
  31. public bool f16_kv;
  32. /// <summary>
  33. /// the llama_eval() call computes all logits, not just the last one
  34. /// </summary>
  35. [MarshalAs(UnmanagedType.I1)]
  36. public bool logits_all;
  37. /// <summary>
  38. /// only load the vocabulary, no weights
  39. /// </summary>
  40. [MarshalAs(UnmanagedType.I1)]
  41. public bool vocab_only;
  42. /// <summary>
  43. /// use mmap if possible
  44. /// </summary>
  45. [MarshalAs(UnmanagedType.I1)]
  46. public bool use_mmap;
  47. /// <summary>
  48. /// force system to keep model in RAM
  49. /// </summary>
  50. [MarshalAs(UnmanagedType.I1)]
  51. public bool use_mlock;
  52. /// <summary>
  53. /// embedding mode only
  54. /// </summary>
  55. [MarshalAs(UnmanagedType.I1)]
  56. public bool embedding;
  57. /// <summary>
  58. /// called with a progress value between 0 and 1, pass NULL to disable
  59. /// </summary>
  60. public IntPtr progress_callback;
  61. /// <summary>
  62. /// context pointer passed to the progress callback
  63. /// </summary>
  64. public IntPtr progress_callback_user_data;
  65. }
  66. }

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