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.

ParameterOptions.cs 3.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using LLama.Common;
  2. using LLama.Abstractions;
  3. using LLama.Native;
  4. namespace LLama.Web.Common
  5. {
  6. public class ParameterOptions : IInferenceParams
  7. {
  8. public string Name { get; set; }
  9. /// <summary>
  10. /// number of tokens to keep from initial prompt
  11. /// </summary>
  12. public int TokensKeep { get; set; } = 0;
  13. /// <summary>
  14. /// how many new tokens to predict (n_predict), set to -1 to inifinitely generate response
  15. /// until it complete.
  16. /// </summary>
  17. public int MaxTokens { get; set; } = -1;
  18. /// <summary>
  19. /// logit bias for specific tokens
  20. /// </summary>
  21. public Dictionary<int, float>? LogitBias { get; set; } = null;
  22. /// <summary>
  23. /// Sequences where the model will stop generating further tokens.
  24. /// </summary>
  25. public IEnumerable<string> AntiPrompts { get; set; } = Array.Empty<string>();
  26. /// <summary>
  27. /// path to file for saving/loading model eval state
  28. /// </summary>
  29. public string PathSession { get; set; } = string.Empty;
  30. /// <summary>
  31. /// string to suffix user inputs with
  32. /// </summary>
  33. public string InputSuffix { get; set; } = string.Empty;
  34. /// <summary>
  35. /// string to prefix user inputs with
  36. /// </summary>
  37. public string InputPrefix { get; set; } = string.Empty;
  38. /// <summary>
  39. /// 0 or lower to use vocab size
  40. /// </summary>
  41. public int TopK { get; set; } = 40;
  42. /// <summary>
  43. /// 1.0 = disabled
  44. /// </summary>
  45. public float TopP { get; set; } = 0.95f;
  46. /// <summary>
  47. /// 1.0 = disabled
  48. /// </summary>
  49. public float TfsZ { get; set; } = 1.0f;
  50. /// <summary>
  51. /// 1.0 = disabled
  52. /// </summary>
  53. public float TypicalP { get; set; } = 1.0f;
  54. /// <summary>
  55. /// 1.0 = disabled
  56. /// </summary>
  57. public float Temperature { get; set; } = 0.8f;
  58. /// <summary>
  59. /// 1.0 = disabled
  60. /// </summary>
  61. public float RepeatPenalty { get; set; } = 1.1f;
  62. /// <summary>
  63. /// last n tokens to penalize (0 = disable penalty, -1 = context size) (repeat_last_n)
  64. /// </summary>
  65. public int RepeatLastTokensCount { get; set; } = 64;
  66. /// <summary>
  67. /// frequency penalty coefficient
  68. /// 0.0 = disabled
  69. /// </summary>
  70. public float FrequencyPenalty { get; set; } = .0f;
  71. /// <summary>
  72. /// presence penalty coefficient
  73. /// 0.0 = disabled
  74. /// </summary>
  75. public float PresencePenalty { get; set; } = .0f;
  76. /// <summary>
  77. /// Mirostat uses tokens instead of words.
  78. /// algorithm described in the paper https://arxiv.org/abs/2007.14966.
  79. /// 0 = disabled, 1 = mirostat, 2 = mirostat 2.0
  80. /// </summary>
  81. public MirostatType Mirostat { get; set; } = MirostatType.Disable;
  82. /// <summary>
  83. /// target entropy
  84. /// </summary>
  85. public float MirostatTau { get; set; } = 5.0f;
  86. /// <summary>
  87. /// learning rate
  88. /// </summary>
  89. public float MirostatEta { get; set; } = 0.1f;
  90. /// <summary>
  91. /// consider newlines as a repeatable token (penalize_nl)
  92. /// </summary>
  93. public bool PenalizeNL { get; set; } = true;
  94. /// <summary>
  95. /// A grammar to constrain possible tokens
  96. /// </summary>
  97. public SafeLLamaGrammarHandle Grammar { get; set; } = null;
  98. }
  99. }