options.go 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // MIT License
  2. // Copyright (c) 2023 go-skynet authors
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy
  4. // of this software and associated documentation files (the "Software"), to deal
  5. // in the Software without restriction, including without limitation the rights
  6. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. // copies of the Software, and to permit persons to whom the Software is
  8. // furnished to do so, subject to the following conditions:
  9. // The above copyright notice and this permission notice shall be included in all
  10. // copies or substantial portions of the Software.
  11. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. // SOFTWARE.
  18. package llama
  19. type ModelOptions struct {
  20. ContextSize int
  21. Seed int
  22. NBatch int
  23. F16Memory bool
  24. MLock bool
  25. MMap bool
  26. VocabOnly bool
  27. LowVRAM bool
  28. Embeddings bool
  29. NUMA bool
  30. NGPULayers int
  31. MainGPU string
  32. TensorSplit string
  33. }
  34. type PredictOptions struct {
  35. Seed, Threads, Tokens, TopK, Repeat, Batch, NKeep int
  36. TopP, Temperature, Penalty float64
  37. F16KV bool
  38. DebugMode bool
  39. StopPrompts []string
  40. IgnoreEOS bool
  41. TailFreeSamplingZ float64
  42. TypicalP float64
  43. FrequencyPenalty float64
  44. PresencePenalty float64
  45. Mirostat int
  46. MirostatETA float64
  47. MirostatTAU float64
  48. PenalizeNL bool
  49. LogitBias string
  50. TokenCallback func(string) bool
  51. MLock, MMap bool
  52. MainGPU string
  53. TensorSplit string
  54. }
  55. type PredictOption func(p *PredictOptions)
  56. type ModelOption func(p *ModelOptions)
  57. var DefaultModelOptions ModelOptions = ModelOptions{
  58. ContextSize: 512,
  59. Seed: 0,
  60. F16Memory: false,
  61. MLock: false,
  62. Embeddings: false,
  63. MMap: true,
  64. LowVRAM: false,
  65. }
  66. var DefaultOptions PredictOptions = PredictOptions{
  67. Seed: -1,
  68. Threads: 4,
  69. Tokens: 128,
  70. Penalty: 1.1,
  71. Repeat: 64,
  72. Batch: 512,
  73. NKeep: 64,
  74. TopK: 40,
  75. TopP: 0.95,
  76. TailFreeSamplingZ: 1.0,
  77. TypicalP: 1.0,
  78. Temperature: 0.8,
  79. FrequencyPenalty: 0.0,
  80. PresencePenalty: 0.0,
  81. Mirostat: 0,
  82. MirostatTAU: 5.0,
  83. MirostatETA: 0.1,
  84. MMap: true,
  85. }