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 1.9 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. /// number of layers to store in VRAM
  17. /// </summary>
  18. public int n_gpu_layers;
  19. /// <summary>
  20. /// RNG seed, -1 for random
  21. /// </summary>
  22. public int seed;
  23. /// <summary>
  24. /// use fp16 for KV cache
  25. /// </summary>
  26. [MarshalAs(UnmanagedType.I1)]
  27. public bool f16_kv;
  28. /// <summary>
  29. /// the llama_eval() call computes all logits, not just the last one
  30. /// </summary>
  31. [MarshalAs(UnmanagedType.I1)]
  32. public bool logits_all;
  33. /// <summary>
  34. /// only load the vocabulary, no weights
  35. /// </summary>
  36. [MarshalAs(UnmanagedType.I1)]
  37. public bool vocab_only;
  38. /// <summary>
  39. /// use mmap if possible
  40. /// </summary>
  41. [MarshalAs(UnmanagedType.I1)]
  42. public bool use_mmap;
  43. /// <summary>
  44. /// force system to keep model in RAM
  45. /// </summary>
  46. [MarshalAs(UnmanagedType.I1)]
  47. public bool use_mlock;
  48. /// <summary>
  49. /// embedding mode only
  50. /// </summary>
  51. [MarshalAs(UnmanagedType.I1)]
  52. public bool embedding;
  53. /// <summary>
  54. /// called with a progress value between 0 and 1, pass NULL to disable
  55. /// </summary>
  56. public IntPtr progress_callback;
  57. /// <summary>
  58. /// context pointer passed to the progress callback
  59. /// </summary>
  60. public IntPtr progress_callback_user_data;
  61. }
  62. }

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