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.

ModelOptions.cs 2.8 kB

April 2024 Binary Update (#662) * Updated binaries, using [this build](https://github.com/SciSharp/LLamaSharp/actions/runs/8654672719/job/23733195669) for llama.cpp commit `f7001ccc5aa359fcf41bba19d1c99c3d25c9bcc7`. - Added all new functions. - Moved some functions (e.g. `SafeLlamaModelHandle` specific functions) into `SafeLlamaModelHandle.cs` - Exposed tokens on `SafeLlamaModelHandle` and `LLamaWeights` through a `Tokens` property. As new special tokens are added in the future they can be added here. - Changed all token properties to return nullable tokens, to handle some models not having some tokens. - Fixed `DefaultSamplingPipeline` to handle no newline token in some models. * Moved native methods to more specific locations. - Context specific things have been moved into `SafeLLamaContextHandle.cs` and made private - they're exposed through C# properties and methods already. - Checking that GPU layer count is zero if GPU offload is not supported. - Moved methods for creating default structs (`llama_model_quantize_default_params` and `llama_context_default_params`) into relevant structs. * Removed exception if `GpuLayerCount > 0` when GPU is not supported. * - Added low level wrapper methods for new per-sequence state load/save in `SafeLLamaContextHandle` - Added high level wrapper methods (save/load with `State` object or memory mapped file) in `LLamaContext` - Moved native methods for per-sequence state load/save into `SafeLLamaContextHandle` * Added update and defrag methods for KV cache in `SafeLLamaContextHandle` * Updated submodule to `f7001ccc5aa359fcf41bba19d1c99c3d25c9bcc7` * Passing the sequence ID when saving a single sequence state
1 year ago
April 2024 Binary Update (#662) * Updated binaries, using [this build](https://github.com/SciSharp/LLamaSharp/actions/runs/8654672719/job/23733195669) for llama.cpp commit `f7001ccc5aa359fcf41bba19d1c99c3d25c9bcc7`. - Added all new functions. - Moved some functions (e.g. `SafeLlamaModelHandle` specific functions) into `SafeLlamaModelHandle.cs` - Exposed tokens on `SafeLlamaModelHandle` and `LLamaWeights` through a `Tokens` property. As new special tokens are added in the future they can be added here. - Changed all token properties to return nullable tokens, to handle some models not having some tokens. - Fixed `DefaultSamplingPipeline` to handle no newline token in some models. * Moved native methods to more specific locations. - Context specific things have been moved into `SafeLLamaContextHandle.cs` and made private - they're exposed through C# properties and methods already. - Checking that GPU layer count is zero if GPU offload is not supported. - Moved methods for creating default structs (`llama_model_quantize_default_params` and `llama_context_default_params`) into relevant structs. * Removed exception if `GpuLayerCount > 0` when GPU is not supported. * - Added low level wrapper methods for new per-sequence state load/save in `SafeLLamaContextHandle` - Added high level wrapper methods (save/load with `State` object or memory mapped file) in `LLamaContext` - Moved native methods for per-sequence state load/save into `SafeLLamaContextHandle` * Added update and defrag methods for KV cache in `SafeLLamaContextHandle` * Updated submodule to `f7001ccc5aa359fcf41bba19d1c99c3d25c9bcc7` * Passing the sequence ID when saving a single sequence state
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System.Text;
  2. using LLama.Abstractions;
  3. using LLama.Native;
  4. namespace LLama.Web.Common;
  5. public class ModelOptions
  6. : ILLamaParams
  7. {
  8. /// <summary>
  9. /// Model friendly name
  10. /// </summary>
  11. public string Name { get; set; }
  12. /// <summary>
  13. /// Max context instances allowed per model
  14. /// </summary>
  15. public int MaxInstances { get; set; }
  16. /// <inheritdoc />
  17. public uint? ContextSize { get; set; }
  18. /// <inheritdoc />
  19. public int MainGpu { get; set; } = 0;
  20. /// <inheritdoc />
  21. public GPUSplitMode SplitMode { get; set; } = GPUSplitMode.None;
  22. /// <inheritdoc />
  23. public int GpuLayerCount { get; set; } = 20;
  24. public uint SeqMax { get; }
  25. /// <inheritdoc />
  26. public uint Seed { get; set; } = 1686349486;
  27. public bool Embeddings { get; }
  28. /// <inheritdoc />
  29. public bool UseMemorymap { get; set; } = true;
  30. /// <inheritdoc />
  31. public bool UseMemoryLock { get; set; } = false;
  32. /// <inheritdoc />
  33. public string ModelPath { get; set; }
  34. /// <inheritdoc />
  35. public AdapterCollection LoraAdapters { get; set; } = new();
  36. /// <inheritdoc />
  37. public string LoraBase { get; set; } = string.Empty;
  38. /// <inheritdoc />
  39. public uint? Threads { get; set; }
  40. /// <inheritdoc />
  41. public uint? BatchThreads { get; set; }
  42. /// <inheritdoc />
  43. public uint BatchSize { get; set; } = 512;
  44. /// <inheritdoc />
  45. public uint UBatchSize { get; set; } = 512;
  46. /// <inheritdoc />
  47. public TensorSplitsCollection TensorSplits { get; set; } = new();
  48. /// <inheritdoc />
  49. public List<MetadataOverride> MetadataOverrides { get; } = new();
  50. /// <inheritdoc />
  51. public float? RopeFrequencyBase { get; set; }
  52. /// <inheritdoc />
  53. public float? RopeFrequencyScale { get; set; }
  54. /// <inheritdoc />
  55. public float? YarnExtrapolationFactor { get; set; }
  56. /// <inheritdoc />
  57. public float? YarnAttentionFactor { get; set; }
  58. /// <inheritdoc />
  59. public float? YarnBetaFast { get; set; }
  60. /// <inheritdoc />
  61. public float? YarnBetaSlow { get; set; }
  62. /// <inheritdoc />
  63. public uint? YarnOriginalContext { get; set; }
  64. /// <inheritdoc />
  65. public RopeScalingType? YarnScalingType { get; set; }
  66. /// <inheritdoc />
  67. public GGMLType? TypeK { get; set; }
  68. /// <inheritdoc />
  69. public GGMLType? TypeV { get; set; }
  70. /// <inheritdoc />
  71. public bool NoKqvOffload { get; set; }
  72. /// <inheritdoc />
  73. public Encoding Encoding { get; set; } = Encoding.UTF8;
  74. /// <inheritdoc />
  75. public bool VocabOnly { get; set; }
  76. /// <inheritdoc />
  77. public float DefragThreshold { get; set; }
  78. /// <inheritdoc />
  79. public LLamaPoolingType PoolingType { get; set; }
  80. }