cactus-react-native 0.2.11 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (510) hide show
  1. package/Cactus.podspec +34 -0
  2. package/LICENSE +38 -0
  3. package/README.md +354 -69
  4. package/android/CMakeLists.txt +40 -0
  5. package/android/build.gradle +68 -44
  6. package/android/gradle.properties +5 -5
  7. package/android/src/main/AndroidManifest.xml +1 -3
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/cactus/CactusPackage.kt +22 -0
  10. package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusCrypto.kt +38 -0
  11. package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusDeviceInfo.kt +24 -0
  12. package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusFileSystem.kt +227 -0
  13. package/android/src/main/jniLibs/arm64-v8a/{libcactus_v8_2_dotprod.so → libcactus.a} +0 -0
  14. package/android/src/main/jniLibs/arm64-v8a/libcactus_util.so +0 -0
  15. package/cpp/HybridCactus.cpp +123 -0
  16. package/cpp/HybridCactus.hpp +35 -0
  17. package/cpp/HybridCactusUtil.cpp +45 -0
  18. package/cpp/HybridCactusUtil.hpp +26 -0
  19. package/cpp/cactus_ffi.h +55 -0
  20. package/cpp/cactus_util.h +25 -0
  21. package/ios/HybridCactusCrypto.swift +37 -0
  22. package/ios/HybridCactusDeviceInfo.swift +32 -0
  23. package/ios/HybridCactusFileSystem.swift +234 -0
  24. package/ios/cactus.xcframework/{info.plist → Info.plist} +2 -37
  25. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus.h +8 -229
  26. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_ffi.h +28 -229
  27. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/engine.h +347 -0
  28. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ffi_utils.h +286 -0
  29. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/graph.h +319 -0
  30. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel.h +254 -0
  31. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel_utils.h +343 -0
  32. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Info.plist +0 -0
  33. package/ios/cactus.xcframework/ios-arm64/cactus.framework/cactus +0 -0
  34. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus.h +11 -0
  35. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_ffi.h +55 -0
  36. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/engine.h +347 -0
  37. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/ffi_utils.h +286 -0
  38. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/graph.h +319 -0
  39. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel.h +254 -0
  40. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel_utils.h +343 -0
  41. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Info.plist +0 -0
  42. package/ios/cactus.xcframework/{tvos-arm64_x86_64-simulator → ios-arm64-simulator}/cactus.framework/_CodeSignature/CodeResources +1 -1
  43. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/cactus +0 -0
  44. package/ios/cactus_util.xcframework/Info.plist +39 -0
  45. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/cactus_util.h +25 -0
  46. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/ios_utils.h +10 -0
  47. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/logging.h +25 -0
  48. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Info.plist +0 -0
  49. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/cactus_util +0 -0
  50. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/cactus_util.h +25 -0
  51. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/ios_utils.h +10 -0
  52. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/logging.h +25 -0
  53. package/ios/{cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework → cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework}/Info.plist +0 -0
  54. package/ios/{cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework → cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework}/_CodeSignature/CodeResources +36 -2
  55. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/cactus_util +0 -0
  56. package/lib/module/api/Database.js +60 -0
  57. package/lib/module/api/Database.js.map +1 -0
  58. package/lib/module/classes/CactusLM.js +149 -0
  59. package/lib/module/classes/CactusLM.js.map +1 -0
  60. package/lib/module/config/CactusConfig.js +6 -0
  61. package/lib/module/config/CactusConfig.js.map +1 -0
  62. package/lib/module/constants/packageVersion.js +4 -0
  63. package/lib/module/constants/packageVersion.js.map +1 -0
  64. package/lib/module/hooks/useCactusLM.js +233 -0
  65. package/lib/module/hooks/useCactusLM.js.map +1 -0
  66. package/lib/module/index.js +9 -409
  67. package/lib/module/index.js.map +1 -1
  68. package/lib/module/native/Cactus.js +50 -0
  69. package/lib/module/native/Cactus.js.map +1 -0
  70. package/lib/module/native/CactusCrypto.js +10 -0
  71. package/lib/module/native/CactusCrypto.js.map +1 -0
  72. package/lib/module/native/CactusDeviceInfo.js +13 -0
  73. package/lib/module/native/CactusDeviceInfo.js.map +1 -0
  74. package/lib/module/native/CactusFileSystem.js +35 -0
  75. package/lib/module/native/CactusFileSystem.js.map +1 -0
  76. package/lib/module/native/CactusUtil.js +23 -0
  77. package/lib/module/native/CactusUtil.js.map +1 -0
  78. package/lib/module/native/index.js +8 -0
  79. package/lib/module/native/index.js.map +1 -0
  80. package/lib/module/specs/Cactus.nitro.js +4 -0
  81. package/lib/module/specs/Cactus.nitro.js.map +1 -0
  82. package/lib/module/specs/CactusCrypto.nitro.js +4 -0
  83. package/lib/module/specs/CactusCrypto.nitro.js.map +1 -0
  84. package/lib/module/specs/CactusDeviceInfo.nitro.js +4 -0
  85. package/lib/module/specs/CactusDeviceInfo.nitro.js.map +1 -0
  86. package/lib/module/specs/CactusFileSystem.nitro.js +4 -0
  87. package/lib/module/specs/CactusFileSystem.nitro.js.map +1 -0
  88. package/lib/module/specs/CactusUtil.nitro.js +4 -0
  89. package/lib/module/specs/CactusUtil.nitro.js.map +1 -0
  90. package/lib/module/telemetry/Telemetry.js +100 -0
  91. package/lib/module/telemetry/Telemetry.js.map +1 -0
  92. package/lib/module/types/CactusLM.js +2 -0
  93. package/lib/module/types/CactusLM.js.map +1 -0
  94. package/lib/module/types/CactusModel.js +2 -0
  95. package/lib/module/types/CactusModel.js.map +1 -0
  96. package/lib/module/utils/error.js +4 -0
  97. package/lib/module/utils/error.js.map +1 -0
  98. package/lib/typescript/package.json +1 -0
  99. package/lib/typescript/src/api/Database.d.ts +11 -0
  100. package/lib/typescript/src/api/Database.d.ts.map +1 -0
  101. package/lib/typescript/src/classes/CactusLM.d.ts +25 -0
  102. package/lib/typescript/src/classes/CactusLM.d.ts.map +1 -0
  103. package/lib/typescript/src/config/CactusConfig.d.ts +5 -0
  104. package/lib/typescript/src/config/CactusConfig.d.ts.map +1 -0
  105. package/lib/typescript/src/constants/packageVersion.d.ts +2 -0
  106. package/lib/typescript/src/constants/packageVersion.d.ts.map +1 -0
  107. package/lib/typescript/src/hooks/useCactusLM.d.ts +20 -0
  108. package/lib/typescript/src/hooks/useCactusLM.d.ts.map +1 -0
  109. package/lib/typescript/src/index.d.ts +6 -0
  110. package/lib/typescript/src/index.d.ts.map +1 -0
  111. package/lib/typescript/src/native/Cactus.d.ts +11 -0
  112. package/lib/typescript/src/native/Cactus.d.ts.map +1 -0
  113. package/lib/typescript/src/native/CactusCrypto.d.ts +5 -0
  114. package/lib/typescript/src/native/CactusCrypto.d.ts.map +1 -0
  115. package/lib/typescript/src/native/CactusDeviceInfo.d.ts +7 -0
  116. package/lib/typescript/src/native/CactusDeviceInfo.d.ts.map +1 -0
  117. package/lib/typescript/src/native/CactusFileSystem.d.ts +13 -0
  118. package/lib/typescript/src/native/CactusFileSystem.d.ts.map +1 -0
  119. package/lib/typescript/src/native/CactusUtil.d.ts +6 -0
  120. package/lib/typescript/src/native/CactusUtil.d.ts.map +1 -0
  121. package/lib/typescript/src/native/index.d.ts +6 -0
  122. package/lib/typescript/src/native/index.d.ts.map +1 -0
  123. package/lib/typescript/src/specs/Cactus.nitro.d.ts +13 -0
  124. package/lib/typescript/src/specs/Cactus.nitro.d.ts.map +1 -0
  125. package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts +8 -0
  126. package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts.map +1 -0
  127. package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts +16 -0
  128. package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts.map +1 -0
  129. package/lib/typescript/src/specs/CactusFileSystem.nitro.d.ts +16 -0
  130. package/lib/typescript/src/specs/CactusFileSystem.nitro.d.ts.map +1 -0
  131. package/lib/typescript/src/specs/CactusUtil.nitro.d.ts +10 -0
  132. package/lib/typescript/src/specs/CactusUtil.nitro.d.ts.map +1 -0
  133. package/lib/typescript/src/telemetry/Telemetry.d.ts +30 -0
  134. package/lib/typescript/src/telemetry/Telemetry.d.ts.map +1 -0
  135. package/lib/typescript/src/types/CactusLM.d.ts +65 -0
  136. package/lib/typescript/src/types/CactusLM.d.ts.map +1 -0
  137. package/lib/typescript/src/types/CactusModel.d.ts +12 -0
  138. package/lib/typescript/src/types/CactusModel.d.ts.map +1 -0
  139. package/lib/typescript/src/utils/error.d.ts +2 -0
  140. package/lib/typescript/src/utils/error.d.ts.map +1 -0
  141. package/nitro.json +31 -0
  142. package/nitrogen/generated/android/c++/JDeviceInfo.hpp +74 -0
  143. package/nitrogen/generated/android/c++/JFunc_void_double.hpp +74 -0
  144. package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.cpp +65 -0
  145. package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.hpp +65 -0
  146. package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.cpp +85 -0
  147. package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.hpp +66 -0
  148. package/nitrogen/generated/android/c++/JHybridCactusFileSystemSpec.cpp +192 -0
  149. package/nitrogen/generated/android/c++/JHybridCactusFileSystemSpec.hpp +73 -0
  150. package/nitrogen/generated/android/cactus+autolinking.cmake +87 -0
  151. package/nitrogen/generated/android/cactus+autolinking.gradle +27 -0
  152. package/nitrogen/generated/android/cactusOnLoad.cpp +86 -0
  153. package/nitrogen/generated/android/cactusOnLoad.hpp +25 -0
  154. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/DeviceInfo.kt +50 -0
  155. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/Func_void_double.kt +80 -0
  156. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusCryptoSpec.kt +58 -0
  157. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusDeviceInfoSpec.kt +62 -0
  158. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusFileSystemSpec.kt +95 -0
  159. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/cactusOnLoad.kt +35 -0
  160. package/nitrogen/generated/ios/Cactus+autolinking.rb +60 -0
  161. package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.cpp +122 -0
  162. package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.hpp +373 -0
  163. package/nitrogen/generated/ios/Cactus-Swift-Cxx-Umbrella.hpp +60 -0
  164. package/nitrogen/generated/ios/CactusAutolinking.mm +69 -0
  165. package/nitrogen/generated/ios/CactusAutolinking.swift +55 -0
  166. package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.cpp +11 -0
  167. package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.hpp +77 -0
  168. package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.cpp +11 -0
  169. package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.hpp +88 -0
  170. package/nitrogen/generated/ios/c++/HybridCactusFileSystemSpecSwift.cpp +11 -0
  171. package/nitrogen/generated/ios/c++/HybridCactusFileSystemSpecSwift.hpp +143 -0
  172. package/nitrogen/generated/ios/swift/DeviceInfo.swift +98 -0
  173. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  174. package/nitrogen/generated/ios/swift/Func_void_DeviceInfo.swift +47 -0
  175. package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
  176. package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
  177. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  178. package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +54 -0
  179. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
  180. package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec.swift +57 -0
  181. package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec_cxx.swift +139 -0
  182. package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec.swift +58 -0
  183. package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec_cxx.swift +164 -0
  184. package/nitrogen/generated/ios/swift/HybridCactusFileSystemSpec.swift +65 -0
  185. package/nitrogen/generated/ios/swift/HybridCactusFileSystemSpec_cxx.swift +303 -0
  186. package/nitrogen/generated/shared/c++/DeviceInfo.hpp +92 -0
  187. package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.cpp +21 -0
  188. package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.hpp +63 -0
  189. package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.cpp +22 -0
  190. package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.hpp +67 -0
  191. package/nitrogen/generated/shared/c++/HybridCactusFileSystemSpec.cpp +29 -0
  192. package/nitrogen/generated/shared/c++/HybridCactusFileSystemSpec.hpp +73 -0
  193. package/nitrogen/generated/shared/c++/HybridCactusSpec.cpp +26 -0
  194. package/nitrogen/generated/shared/c++/HybridCactusSpec.hpp +71 -0
  195. package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.cpp +23 -0
  196. package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.hpp +66 -0
  197. package/package.json +84 -143
  198. package/src/api/Database.ts +83 -0
  199. package/src/classes/CactusLM.ts +203 -0
  200. package/src/config/CactusConfig.ts +4 -0
  201. package/src/constants/packageVersion.ts +1 -0
  202. package/src/hooks/useCactusLM.ts +282 -0
  203. package/src/index.tsx +23 -0
  204. package/src/native/Cactus.ts +79 -0
  205. package/src/native/CactusCrypto.ts +11 -0
  206. package/src/native/CactusDeviceInfo.ts +18 -0
  207. package/src/native/CactusFileSystem.ts +47 -0
  208. package/src/native/CactusUtil.ts +27 -0
  209. package/src/native/index.ts +5 -0
  210. package/src/specs/Cactus.nitro.ts +16 -0
  211. package/src/specs/CactusCrypto.nitro.ts +6 -0
  212. package/src/specs/CactusDeviceInfo.nitro.ts +15 -0
  213. package/src/specs/CactusFileSystem.nitro.ts +21 -0
  214. package/src/specs/CactusUtil.nitro.ts +8 -0
  215. package/src/telemetry/Telemetry.ts +159 -0
  216. package/src/types/CactusLM.ts +71 -0
  217. package/src/types/CactusModel.ts +14 -0
  218. package/src/utils/error.ts +2 -0
  219. package/LICENSE.txt +0 -20
  220. package/android/src/main/CMakeLists.txt +0 -140
  221. package/android/src/main/java/com/cactus/Cactus.java +0 -1190
  222. package/android/src/main/java/com/cactus/CactusPackage.java +0 -48
  223. package/android/src/main/java/com/cactus/LlamaContext.java +0 -748
  224. package/android/src/main/jni-utils.h +0 -100
  225. package/android/src/main/jni.cpp +0 -1605
  226. package/android/src/main/jniLibs/arm64-v8a/libcactus.so +0 -0
  227. package/android/src/main/jniLibs/arm64-v8a/libcactus_v8.so +0 -0
  228. package/android/src/main/jniLibs/arm64-v8a/libcactus_v8_2.so +0 -0
  229. package/android/src/main/jniLibs/arm64-v8a/libcactus_v8_2_dotprod_i8mm.so +0 -0
  230. package/android/src/main/jniLibs/arm64-v8a/libcactus_v8_2_i8mm.so +0 -0
  231. package/android/src/newarch/java/com/cactus/CactusModule.java +0 -204
  232. package/android/src/oldarch/java/com/cactus/CactusModule.java +0 -205
  233. package/cactus-react-native.podspec +0 -42
  234. package/ios/CMakeLists.txt +0 -131
  235. package/ios/Cactus.h +0 -6
  236. package/ios/Cactus.mm +0 -681
  237. package/ios/CactusContext.h +0 -81
  238. package/ios/CactusContext.mm +0 -1032
  239. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/chat.h +0 -145
  240. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/common.h +0 -674
  241. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-alloc.h +0 -76
  242. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-backend-impl.h +0 -255
  243. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-backend.h +0 -354
  244. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-common.h +0 -1857
  245. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-cpp.h +0 -39
  246. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-cpu.h +0 -143
  247. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-impl.h +0 -601
  248. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-metal-impl.h +0 -622
  249. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-metal.h +0 -66
  250. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-opt.h +0 -237
  251. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-quants.h +0 -100
  252. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-threading.h +0 -14
  253. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml.h +0 -2202
  254. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/gguf.h +0 -202
  255. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/json-schema-to-grammar.h +0 -21
  256. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/json.hpp +0 -24766
  257. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-adapter.h +0 -76
  258. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-arch.h +0 -437
  259. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-batch.h +0 -89
  260. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-chat.h +0 -58
  261. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-context.h +0 -276
  262. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-cparams.h +0 -39
  263. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-cpp.h +0 -30
  264. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-grammar.h +0 -173
  265. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-graph.h +0 -640
  266. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-hparams.h +0 -190
  267. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-impl.h +0 -61
  268. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-io.h +0 -35
  269. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-kv-cache.h +0 -515
  270. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-memory.h +0 -32
  271. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-mmap.h +0 -68
  272. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-model-loader.h +0 -169
  273. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-model-saver.h +0 -37
  274. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-model.h +0 -425
  275. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-sampling.h +0 -32
  276. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-vocab.h +0 -131
  277. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama.h +0 -1376
  278. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/log.h +0 -103
  279. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/minja/chat-template.hpp +0 -542
  280. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/minja/minja.hpp +0 -2974
  281. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/sampling.h +0 -107
  282. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/unicode-data.h +0 -20
  283. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/unicode.h +0 -66
  284. package/ios/cactus.xcframework/ios-arm64/cactus.framework/ggml-llama.metallib +0 -0
  285. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/cactus.h +0 -232
  286. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/cactus_ffi.h +0 -256
  287. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/chat.h +0 -145
  288. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/common.h +0 -674
  289. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-alloc.h +0 -76
  290. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-backend-impl.h +0 -255
  291. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-backend.h +0 -354
  292. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-common.h +0 -1857
  293. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-cpp.h +0 -39
  294. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-cpu.h +0 -143
  295. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-impl.h +0 -601
  296. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-metal-impl.h +0 -622
  297. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-metal.h +0 -66
  298. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-opt.h +0 -237
  299. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-quants.h +0 -100
  300. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-threading.h +0 -14
  301. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml.h +0 -2202
  302. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/gguf.h +0 -202
  303. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/json-schema-to-grammar.h +0 -21
  304. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/json.hpp +0 -24766
  305. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-adapter.h +0 -76
  306. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-arch.h +0 -437
  307. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-batch.h +0 -89
  308. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-chat.h +0 -58
  309. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-context.h +0 -276
  310. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-cparams.h +0 -39
  311. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-cpp.h +0 -30
  312. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-grammar.h +0 -173
  313. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-graph.h +0 -640
  314. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-hparams.h +0 -190
  315. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-impl.h +0 -61
  316. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-io.h +0 -35
  317. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-kv-cache.h +0 -515
  318. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-memory.h +0 -32
  319. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-mmap.h +0 -68
  320. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-model-loader.h +0 -169
  321. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-model-saver.h +0 -37
  322. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-model.h +0 -425
  323. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-sampling.h +0 -32
  324. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-vocab.h +0 -131
  325. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama.h +0 -1376
  326. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/log.h +0 -103
  327. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/minja/chat-template.hpp +0 -542
  328. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/minja/minja.hpp +0 -2974
  329. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/sampling.h +0 -107
  330. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/unicode-data.h +0 -20
  331. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/unicode.h +0 -66
  332. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/cactus +0 -0
  333. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/ggml-llama-sim.metallib +0 -0
  334. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/cactus.h +0 -232
  335. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/cactus_ffi.h +0 -256
  336. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/chat.h +0 -145
  337. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/common.h +0 -674
  338. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-alloc.h +0 -76
  339. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-backend-impl.h +0 -255
  340. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-backend.h +0 -354
  341. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-common.h +0 -1857
  342. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-cpp.h +0 -39
  343. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-cpu.h +0 -143
  344. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-impl.h +0 -601
  345. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-metal-impl.h +0 -622
  346. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-metal.h +0 -66
  347. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-opt.h +0 -237
  348. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-quants.h +0 -100
  349. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-threading.h +0 -14
  350. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml.h +0 -2202
  351. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/gguf.h +0 -202
  352. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/json-schema-to-grammar.h +0 -21
  353. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/json.hpp +0 -24766
  354. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-adapter.h +0 -76
  355. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-arch.h +0 -437
  356. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-batch.h +0 -89
  357. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-chat.h +0 -58
  358. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-context.h +0 -276
  359. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-cparams.h +0 -39
  360. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-cpp.h +0 -30
  361. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-grammar.h +0 -173
  362. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-graph.h +0 -640
  363. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-hparams.h +0 -190
  364. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-impl.h +0 -61
  365. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-io.h +0 -35
  366. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-kv-cache.h +0 -515
  367. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-memory.h +0 -32
  368. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-mmap.h +0 -68
  369. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-model-loader.h +0 -169
  370. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-model-saver.h +0 -37
  371. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-model.h +0 -425
  372. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-sampling.h +0 -32
  373. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-vocab.h +0 -131
  374. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama.h +0 -1376
  375. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/log.h +0 -103
  376. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/minja/chat-template.hpp +0 -542
  377. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/minja/minja.hpp +0 -2974
  378. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/sampling.h +0 -107
  379. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/unicode-data.h +0 -20
  380. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/unicode.h +0 -66
  381. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Info.plist +0 -0
  382. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/cactus +0 -0
  383. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/ggml-llama.metallib +0 -0
  384. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/cactus.h +0 -232
  385. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/cactus_ffi.h +0 -256
  386. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/chat.h +0 -145
  387. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/common.h +0 -674
  388. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-alloc.h +0 -76
  389. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-backend-impl.h +0 -255
  390. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-backend.h +0 -354
  391. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-common.h +0 -1857
  392. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-cpp.h +0 -39
  393. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-cpu.h +0 -143
  394. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-impl.h +0 -601
  395. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-metal-impl.h +0 -622
  396. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-metal.h +0 -66
  397. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-opt.h +0 -237
  398. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-quants.h +0 -100
  399. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-threading.h +0 -14
  400. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml.h +0 -2202
  401. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/gguf.h +0 -202
  402. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/json-schema-to-grammar.h +0 -21
  403. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/json.hpp +0 -24766
  404. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-adapter.h +0 -76
  405. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-arch.h +0 -437
  406. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-batch.h +0 -89
  407. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-chat.h +0 -58
  408. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-context.h +0 -276
  409. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-cparams.h +0 -39
  410. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-cpp.h +0 -30
  411. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-grammar.h +0 -173
  412. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-graph.h +0 -640
  413. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-hparams.h +0 -190
  414. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-impl.h +0 -61
  415. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-io.h +0 -35
  416. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-kv-cache.h +0 -515
  417. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-memory.h +0 -32
  418. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-mmap.h +0 -68
  419. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-model-loader.h +0 -169
  420. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-model-saver.h +0 -37
  421. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-model.h +0 -425
  422. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-sampling.h +0 -32
  423. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-vocab.h +0 -131
  424. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama.h +0 -1376
  425. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/log.h +0 -103
  426. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/minja/chat-template.hpp +0 -542
  427. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/minja/minja.hpp +0 -2974
  428. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/sampling.h +0 -107
  429. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/unicode-data.h +0 -20
  430. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/unicode.h +0 -66
  431. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Info.plist +0 -0
  432. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/cactus +0 -0
  433. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/ggml-llama-sim.metallib +0 -0
  434. package/lib/commonjs/NativeCactus.js +0 -9
  435. package/lib/commonjs/NativeCactus.js.map +0 -1
  436. package/lib/commonjs/agent.js +0 -73
  437. package/lib/commonjs/agent.js.map +0 -1
  438. package/lib/commonjs/chat.js +0 -73
  439. package/lib/commonjs/chat.js.map +0 -1
  440. package/lib/commonjs/index.js +0 -523
  441. package/lib/commonjs/index.js.map +0 -1
  442. package/lib/commonjs/lm.js +0 -272
  443. package/lib/commonjs/lm.js.map +0 -1
  444. package/lib/commonjs/package.json +0 -1
  445. package/lib/commonjs/projectId.js +0 -9
  446. package/lib/commonjs/projectId.js.map +0 -1
  447. package/lib/commonjs/remote.js +0 -100
  448. package/lib/commonjs/remote.js.map +0 -1
  449. package/lib/commonjs/telemetry.js +0 -102
  450. package/lib/commonjs/telemetry.js.map +0 -1
  451. package/lib/commonjs/tools.js +0 -72
  452. package/lib/commonjs/tools.js.map +0 -1
  453. package/lib/commonjs/tts.js +0 -141
  454. package/lib/commonjs/tts.js.map +0 -1
  455. package/lib/commonjs/vlm.js +0 -221
  456. package/lib/commonjs/vlm.js.map +0 -1
  457. package/lib/module/NativeCactus.js +0 -5
  458. package/lib/module/NativeCactus.js.map +0 -1
  459. package/lib/module/agent.js +0 -68
  460. package/lib/module/agent.js.map +0 -1
  461. package/lib/module/chat.js +0 -67
  462. package/lib/module/chat.js.map +0 -1
  463. package/lib/module/lm.js +0 -267
  464. package/lib/module/lm.js.map +0 -1
  465. package/lib/module/projectId.js +0 -5
  466. package/lib/module/projectId.js.map +0 -1
  467. package/lib/module/remote.js +0 -91
  468. package/lib/module/remote.js.map +0 -1
  469. package/lib/module/telemetry.js +0 -97
  470. package/lib/module/telemetry.js.map +0 -1
  471. package/lib/module/tools.js +0 -66
  472. package/lib/module/tools.js.map +0 -1
  473. package/lib/module/tts.js +0 -135
  474. package/lib/module/tts.js.map +0 -1
  475. package/lib/module/vlm.js +0 -216
  476. package/lib/module/vlm.js.map +0 -1
  477. package/lib/typescript/NativeCactus.d.ts +0 -252
  478. package/lib/typescript/NativeCactus.d.ts.map +0 -1
  479. package/lib/typescript/agent.d.ts +0 -31
  480. package/lib/typescript/agent.d.ts.map +0 -1
  481. package/lib/typescript/chat.d.ts +0 -23
  482. package/lib/typescript/chat.d.ts.map +0 -1
  483. package/lib/typescript/index.d.ts +0 -114
  484. package/lib/typescript/index.d.ts.map +0 -1
  485. package/lib/typescript/lm.d.ts +0 -36
  486. package/lib/typescript/lm.d.ts.map +0 -1
  487. package/lib/typescript/projectId.d.ts +0 -2
  488. package/lib/typescript/projectId.d.ts.map +0 -1
  489. package/lib/typescript/remote.d.ts +0 -8
  490. package/lib/typescript/remote.d.ts.map +0 -1
  491. package/lib/typescript/telemetry.d.ts +0 -25
  492. package/lib/typescript/telemetry.d.ts.map +0 -1
  493. package/lib/typescript/tools.d.ts +0 -36
  494. package/lib/typescript/tools.d.ts.map +0 -1
  495. package/lib/typescript/tts.d.ts +0 -54
  496. package/lib/typescript/tts.d.ts.map +0 -1
  497. package/lib/typescript/vlm.d.ts +0 -33
  498. package/lib/typescript/vlm.d.ts.map +0 -1
  499. package/scripts/postInstall.js +0 -33
  500. package/src/NativeCactus.ts +0 -317
  501. package/src/agent.ts +0 -112
  502. package/src/chat.ts +0 -91
  503. package/src/index.ts +0 -663
  504. package/src/lm.ts +0 -324
  505. package/src/projectId.ts +0 -1
  506. package/src/remote.ts +0 -113
  507. package/src/telemetry.ts +0 -137
  508. package/src/tools.ts +0 -94
  509. package/src/tts.ts +0 -236
  510. package/src/vlm.ts +0 -276
@@ -1,1376 +0,0 @@
1
- #ifndef LLAMA_H
2
- #define LLAMA_H
3
-
4
- #include "ggml.h"
5
- #include "ggml-cpu.h"
6
- #include "ggml-backend.h"
7
- #include "ggml-opt.h"
8
-
9
- #include <stddef.h>
10
- #include <stdint.h>
11
- #include <stdio.h>
12
- #include <stdbool.h>
13
-
14
- #ifdef LLAMA_SHARED
15
- # if defined(_WIN32) && !defined(__MINGW32__)
16
- # ifdef LLAMA_BUILD
17
- # define LLAMA_API __declspec(dllexport)
18
- # else
19
- # define LLAMA_API __declspec(dllimport)
20
- # endif
21
- # else
22
- # define LLAMA_API __attribute__ ((visibility ("default")))
23
- # endif
24
- #else
25
- # define LLAMA_API
26
- #endif
27
-
28
- #ifdef __GNUC__
29
- # define DEPRECATED(func, hint) func __attribute__((deprecated(hint)))
30
- #elif defined(_MSC_VER)
31
- # define DEPRECATED(func, hint) __declspec(deprecated(hint)) func
32
- #else
33
- # define DEPRECATED(func, hint) func
34
- #endif
35
-
36
- #define LLAMA_DEFAULT_SEED 0xFFFFFFFF
37
-
38
- #define LLAMA_TOKEN_NULL -1
39
-
40
- #define LLAMA_FILE_MAGIC_GGLA 0x67676c61u // 'ggla'
41
- #define LLAMA_FILE_MAGIC_GGSN 0x6767736eu // 'ggsn'
42
- #define LLAMA_FILE_MAGIC_GGSQ 0x67677371u // 'ggsq'
43
-
44
- #define LLAMA_SESSION_MAGIC LLAMA_FILE_MAGIC_GGSN
45
- #define LLAMA_SESSION_VERSION 9
46
-
47
- #define LLAMA_STATE_SEQ_MAGIC LLAMA_FILE_MAGIC_GGSQ
48
- #define LLAMA_STATE_SEQ_VERSION 2
49
-
50
- #ifdef __cplusplus
51
- extern "C" {
52
- #endif
53
-
54
- //
55
- // C interface
56
- //
57
- // TODO: show sample usage
58
- //
59
-
60
- struct llama_vocab;
61
- struct llama_model;
62
- struct llama_context;
63
- struct llama_sampler;
64
- struct llama_kv_cache;
65
-
66
- typedef int32_t llama_pos;
67
- typedef int32_t llama_token;
68
- typedef int32_t llama_seq_id;
69
-
70
- enum llama_vocab_type {
71
- LLAMA_VOCAB_TYPE_NONE = 0, // For models without vocab
72
- LLAMA_VOCAB_TYPE_SPM = 1, // LLaMA tokenizer based on byte-level BPE with byte fallback
73
- LLAMA_VOCAB_TYPE_BPE = 2, // GPT-2 tokenizer based on byte-level BPE
74
- LLAMA_VOCAB_TYPE_WPM = 3, // BERT tokenizer based on WordPiece
75
- LLAMA_VOCAB_TYPE_UGM = 4, // T5 tokenizer based on Unigram
76
- LLAMA_VOCAB_TYPE_RWKV = 5, // RWKV tokenizer based on greedy tokenization
77
- };
78
-
79
- // pre-tokenization types
80
- enum llama_vocab_pre_type {
81
- LLAMA_VOCAB_PRE_TYPE_DEFAULT = 0,
82
- LLAMA_VOCAB_PRE_TYPE_LLAMA3 = 1,
83
- LLAMA_VOCAB_PRE_TYPE_DEEPSEEK_LLM = 2,
84
- LLAMA_VOCAB_PRE_TYPE_DEEPSEEK_CODER = 3,
85
- LLAMA_VOCAB_PRE_TYPE_FALCON = 4,
86
- LLAMA_VOCAB_PRE_TYPE_MPT = 5,
87
- LLAMA_VOCAB_PRE_TYPE_STARCODER = 6,
88
- LLAMA_VOCAB_PRE_TYPE_GPT2 = 7,
89
- LLAMA_VOCAB_PRE_TYPE_REFACT = 8,
90
- LLAMA_VOCAB_PRE_TYPE_COMMAND_R = 9,
91
- LLAMA_VOCAB_PRE_TYPE_STABLELM2 = 10,
92
- LLAMA_VOCAB_PRE_TYPE_QWEN2 = 11,
93
- LLAMA_VOCAB_PRE_TYPE_OLMO = 12,
94
- LLAMA_VOCAB_PRE_TYPE_DBRX = 13,
95
- LLAMA_VOCAB_PRE_TYPE_SMAUG = 14,
96
- LLAMA_VOCAB_PRE_TYPE_PORO = 15,
97
- LLAMA_VOCAB_PRE_TYPE_CHATGLM3 = 16,
98
- LLAMA_VOCAB_PRE_TYPE_CHATGLM4 = 17,
99
- LLAMA_VOCAB_PRE_TYPE_VIKING = 18,
100
- LLAMA_VOCAB_PRE_TYPE_JAIS = 19,
101
- LLAMA_VOCAB_PRE_TYPE_TEKKEN = 20,
102
- LLAMA_VOCAB_PRE_TYPE_SMOLLM = 21,
103
- LLAMA_VOCAB_PRE_TYPE_CODESHELL = 22,
104
- LLAMA_VOCAB_PRE_TYPE_BLOOM = 23,
105
- LLAMA_VOCAB_PRE_TYPE_GPT3_FINNISH = 24,
106
- LLAMA_VOCAB_PRE_TYPE_EXAONE = 25,
107
- LLAMA_VOCAB_PRE_TYPE_CHAMELEON = 26,
108
- LLAMA_VOCAB_PRE_TYPE_MINERVA = 27,
109
- LLAMA_VOCAB_PRE_TYPE_DEEPSEEK3_LLM = 28,
110
- LLAMA_VOCAB_PRE_TYPE_GPT4O = 29,
111
- LLAMA_VOCAB_PRE_TYPE_SUPERBPE = 30,
112
- LLAMA_VOCAB_PRE_TYPE_TRILLION = 31,
113
- LLAMA_VOCAB_PRE_TYPE_BAILINGMOE = 32,
114
- LLAMA_VOCAB_PRE_TYPE_LLAMA4 = 33,
115
- LLAMA_VOCAB_PRE_TYPE_PIXTRAL = 34,
116
- LLAMA_VOCAB_PRE_TYPE_SEED_CODER = 35,
117
- };
118
-
119
- enum llama_rope_type {
120
- LLAMA_ROPE_TYPE_NONE = -1,
121
- LLAMA_ROPE_TYPE_NORM = 0,
122
- LLAMA_ROPE_TYPE_NEOX = LM_GGML_ROPE_TYPE_NEOX,
123
- LLAMA_ROPE_TYPE_MROPE = LM_GGML_ROPE_TYPE_MROPE,
124
- LLAMA_ROPE_TYPE_VISION = LM_GGML_ROPE_TYPE_VISION,
125
- };
126
-
127
- enum llama_token_type { //TODO: remove, required until per token attributes are available from GGUF file
128
- LLAMA_TOKEN_TYPE_UNDEFINED = 0,
129
- LLAMA_TOKEN_TYPE_NORMAL = 1,
130
- LLAMA_TOKEN_TYPE_UNKNOWN = 2,
131
- LLAMA_TOKEN_TYPE_CONTROL = 3,
132
- LLAMA_TOKEN_TYPE_USER_DEFINED = 4,
133
- LLAMA_TOKEN_TYPE_UNUSED = 5,
134
- LLAMA_TOKEN_TYPE_BYTE = 6,
135
- };
136
-
137
- enum llama_token_attr {
138
- LLAMA_TOKEN_ATTR_UNDEFINED = 0,
139
- LLAMA_TOKEN_ATTR_UNKNOWN = 1 << 0,
140
- LLAMA_TOKEN_ATTR_UNUSED = 1 << 1,
141
- LLAMA_TOKEN_ATTR_NORMAL = 1 << 2,
142
- LLAMA_TOKEN_ATTR_CONTROL = 1 << 3, // SPECIAL?
143
- LLAMA_TOKEN_ATTR_USER_DEFINED = 1 << 4,
144
- LLAMA_TOKEN_ATTR_BYTE = 1 << 5,
145
- LLAMA_TOKEN_ATTR_NORMALIZED = 1 << 6,
146
- LLAMA_TOKEN_ATTR_LSTRIP = 1 << 7,
147
- LLAMA_TOKEN_ATTR_RSTRIP = 1 << 8,
148
- LLAMA_TOKEN_ATTR_SINGLE_WORD = 1 << 9,
149
- };
150
-
151
- // model file types
152
- enum llama_ftype {
153
- LLAMA_FTYPE_ALL_F32 = 0,
154
- LLAMA_FTYPE_MOSTLY_F16 = 1, // except 1d tensors
155
- LLAMA_FTYPE_MOSTLY_Q4_0 = 2, // except 1d tensors
156
- LLAMA_FTYPE_MOSTLY_Q4_1 = 3, // except 1d tensors
157
- // LLAMA_FTYPE_MOSTLY_Q4_1_SOME_F16 = 4, // tok_embeddings.weight and output.weight are F16
158
- // LLAMA_FTYPE_MOSTLY_Q4_2 = 5, // support has been removed
159
- // LLAMA_FTYPE_MOSTLY_Q4_3 = 6, // support has been removed
160
- LLAMA_FTYPE_MOSTLY_Q8_0 = 7, // except 1d tensors
161
- LLAMA_FTYPE_MOSTLY_Q5_0 = 8, // except 1d tensors
162
- LLAMA_FTYPE_MOSTLY_Q5_1 = 9, // except 1d tensors
163
- LLAMA_FTYPE_MOSTLY_Q2_K = 10, // except 1d tensors
164
- LLAMA_FTYPE_MOSTLY_Q3_K_S = 11, // except 1d tensors
165
- LLAMA_FTYPE_MOSTLY_Q3_K_M = 12, // except 1d tensors
166
- LLAMA_FTYPE_MOSTLY_Q3_K_L = 13, // except 1d tensors
167
- LLAMA_FTYPE_MOSTLY_Q4_K_S = 14, // except 1d tensors
168
- LLAMA_FTYPE_MOSTLY_Q4_K_M = 15, // except 1d tensors
169
- LLAMA_FTYPE_MOSTLY_Q5_K_S = 16, // except 1d tensors
170
- LLAMA_FTYPE_MOSTLY_Q5_K_M = 17, // except 1d tensors
171
- LLAMA_FTYPE_MOSTLY_Q6_K = 18, // except 1d tensors
172
- LLAMA_FTYPE_MOSTLY_IQ2_XXS = 19, // except 1d tensors
173
- LLAMA_FTYPE_MOSTLY_IQ2_XS = 20, // except 1d tensors
174
- LLAMA_FTYPE_MOSTLY_Q2_K_S = 21, // except 1d tensors
175
- LLAMA_FTYPE_MOSTLY_IQ3_XS = 22, // except 1d tensors
176
- LLAMA_FTYPE_MOSTLY_IQ3_XXS = 23, // except 1d tensors
177
- LLAMA_FTYPE_MOSTLY_IQ1_S = 24, // except 1d tensors
178
- LLAMA_FTYPE_MOSTLY_IQ4_NL = 25, // except 1d tensors
179
- LLAMA_FTYPE_MOSTLY_IQ3_S = 26, // except 1d tensors
180
- LLAMA_FTYPE_MOSTLY_IQ3_M = 27, // except 1d tensors
181
- LLAMA_FTYPE_MOSTLY_IQ2_S = 28, // except 1d tensors
182
- LLAMA_FTYPE_MOSTLY_IQ2_M = 29, // except 1d tensors
183
- LLAMA_FTYPE_MOSTLY_IQ4_XS = 30, // except 1d tensors
184
- LLAMA_FTYPE_MOSTLY_IQ1_M = 31, // except 1d tensors
185
- LLAMA_FTYPE_MOSTLY_BF16 = 32, // except 1d tensors
186
- //LLAMA_FTYPE_MOSTLY_Q4_0_4_4 = 33, // removed from gguf files, use Q4_0 and runtime repack
187
- //LLAMA_FTYPE_MOSTLY_Q4_0_4_8 = 34, // removed from gguf files, use Q4_0 and runtime repack
188
- //LLAMA_FTYPE_MOSTLY_Q4_0_8_8 = 35, // removed from gguf files, use Q4_0 and runtime repack
189
- LLAMA_FTYPE_MOSTLY_TQ1_0 = 36, // except 1d tensors
190
- LLAMA_FTYPE_MOSTLY_TQ2_0 = 37, // except 1d tensors
191
-
192
- LLAMA_FTYPE_GUESSED = 1024, // not specified in the model file
193
- };
194
-
195
- enum llama_rope_scaling_type {
196
- LLAMA_ROPE_SCALING_TYPE_UNSPECIFIED = -1,
197
- LLAMA_ROPE_SCALING_TYPE_NONE = 0,
198
- LLAMA_ROPE_SCALING_TYPE_LINEAR = 1,
199
- LLAMA_ROPE_SCALING_TYPE_YARN = 2,
200
- LLAMA_ROPE_SCALING_TYPE_LONGROPE = 3,
201
- LLAMA_ROPE_SCALING_TYPE_MAX_VALUE = LLAMA_ROPE_SCALING_TYPE_LONGROPE,
202
- };
203
-
204
- enum llama_pooling_type {
205
- LLAMA_POOLING_TYPE_UNSPECIFIED = -1,
206
- LLAMA_POOLING_TYPE_NONE = 0,
207
- LLAMA_POOLING_TYPE_MEAN = 1,
208
- LLAMA_POOLING_TYPE_CLS = 2,
209
- LLAMA_POOLING_TYPE_LAST = 3,
210
- LLAMA_POOLING_TYPE_RANK = 4, // used by reranking models to attach the classification head to the graph
211
- };
212
-
213
- enum llama_attention_type {
214
- LLAMA_ATTENTION_TYPE_UNSPECIFIED = -1,
215
- LLAMA_ATTENTION_TYPE_CAUSAL = 0,
216
- LLAMA_ATTENTION_TYPE_NON_CAUSAL = 1,
217
- };
218
-
219
- enum llama_split_mode {
220
- LLAMA_SPLIT_MODE_NONE = 0, // single GPU
221
- LLAMA_SPLIT_MODE_LAYER = 1, // split layers and KV across GPUs
222
- LLAMA_SPLIT_MODE_ROW = 2, // split layers and KV across GPUs, use tensor parallelism if supported
223
- };
224
-
225
- // TODO: simplify (https://github.com/ggml-org/llama.cpp/pull/9294#pullrequestreview-2286561979)
226
- typedef struct llama_token_data {
227
- llama_token id; // token id
228
- float logit; // log-odds of the token
229
- float p; // probability of the token
230
- } llama_token_data;
231
-
232
- typedef struct llama_token_data_array {
233
- // TODO: consider SoA
234
- // NOTE: this pointer can be modified by the samplers
235
- llama_token_data * data;
236
- size_t size;
237
- int64_t selected; // this is the index in the data array (i.e. not the token id)
238
- bool sorted;
239
- } llama_token_data_array;
240
-
241
- typedef bool (*llama_progress_callback)(float progress, void * user_data);
242
-
243
- // Input data for llama_decode
244
- // A llama_batch object can contain input about one or many sequences
245
- // The provided arrays (i.e. token, embd, pos, etc.) must have size of n_tokens
246
- //
247
- // - token : the token ids of the input (used when embd is NULL)
248
- // - embd : token embeddings (i.e. float vector of size n_embd) (used when token is NULL)
249
- // - pos : the positions of the respective token in the sequence
250
- // (if set to NULL, the token position will be tracked automatically by llama_decode)
251
- // - seq_id : the sequence to which the respective token belongs
252
- // (if set to NULL, the sequence ID will be assumed to be 0)
253
- // - logits : if zero, the logits (and/or the embeddings) for the respective token will not be output
254
- // (if set to NULL, only the logits for last token will be returned)
255
- //
256
- typedef struct llama_batch {
257
- int32_t n_tokens;
258
-
259
- llama_token * token;
260
- float * embd;
261
- llama_pos * pos;
262
- int32_t * n_seq_id;
263
- llama_seq_id ** seq_id;
264
- int8_t * logits; // TODO: rename this to "output"
265
- } llama_batch;
266
-
267
- enum llama_model_kv_override_type {
268
- LLAMA_KV_OVERRIDE_TYPE_INT,
269
- LLAMA_KV_OVERRIDE_TYPE_FLOAT,
270
- LLAMA_KV_OVERRIDE_TYPE_BOOL,
271
- LLAMA_KV_OVERRIDE_TYPE_STR,
272
- };
273
-
274
- struct llama_model_kv_override {
275
- enum llama_model_kv_override_type tag;
276
-
277
- char key[128];
278
-
279
- union {
280
- int64_t val_i64;
281
- double val_f64;
282
- bool val_bool;
283
- char val_str[128];
284
- };
285
- };
286
-
287
- struct llama_model_tensor_buft_override {
288
- const char * pattern;
289
- lm_ggml_backend_buffer_type_t buft;
290
- };
291
-
292
- struct llama_model_params {
293
- // NULL-terminated list of devices to use for offloading (if NULL, all available devices are used)
294
- lm_ggml_backend_dev_t * devices;
295
-
296
- // NULL-terminated list of buffer types to use for tensors that match a pattern
297
- const struct llama_model_tensor_buft_override * tensor_buft_overrides;
298
-
299
- int32_t n_gpu_layers; // number of layers to store in VRAM
300
- enum llama_split_mode split_mode; // how to split the model across multiple GPUs
301
-
302
- // the GPU that is used for the entire model when split_mode is LLAMA_SPLIT_MODE_NONE
303
- int32_t main_gpu;
304
-
305
- // proportion of the model (layers or rows) to offload to each GPU, size: llama_max_devices()
306
- const float * tensor_split;
307
-
308
- // Called with a progress value between 0.0 and 1.0. Pass NULL to disable.
309
- // If the provided progress_callback returns true, model loading continues.
310
- // If it returns false, model loading is immediately aborted.
311
- llama_progress_callback progress_callback;
312
-
313
- // context pointer passed to the progress callback
314
- void * progress_callback_user_data;
315
-
316
- // override key-value pairs of the model meta data
317
- const struct llama_model_kv_override * kv_overrides;
318
-
319
- // Keep the booleans together to avoid misalignment during copy-by-value.
320
- bool vocab_only; // only load the vocabulary, no weights
321
- bool use_mmap; // use mmap if possible
322
- bool use_mlock; // force system to keep model in RAM
323
- bool check_tensors; // validate model tensor data
324
- };
325
-
326
- // NOTE: changing the default values of parameters marked as [EXPERIMENTAL] may cause crashes or incorrect results in certain configurations
327
- // https://github.com/ggml-org/llama.cpp/pull/7544
328
- struct llama_context_params {
329
- uint32_t n_ctx; // text context, 0 = from model
330
- uint32_t n_batch; // logical maximum batch size that can be submitted to llama_decode
331
- uint32_t n_ubatch; // physical maximum batch size
332
- uint32_t n_seq_max; // max number of sequences (i.e. distinct states for recurrent models)
333
- int32_t n_threads; // number of threads to use for generation
334
- int32_t n_threads_batch; // number of threads to use for batch processing
335
-
336
- enum llama_rope_scaling_type rope_scaling_type; // RoPE scaling type, from `enum llama_rope_scaling_type`
337
- enum llama_pooling_type pooling_type; // whether to pool (sum) embedding results by sequence id
338
- enum llama_attention_type attention_type; // attention type to use for embeddings
339
-
340
- // ref: https://github.com/ggml-org/llama.cpp/pull/2054
341
- float rope_freq_base; // RoPE base frequency, 0 = from model
342
- float rope_freq_scale; // RoPE frequency scaling factor, 0 = from model
343
- float yarn_ext_factor; // YaRN extrapolation mix factor, negative = from model
344
- float yarn_attn_factor; // YaRN magnitude scaling factor
345
- float yarn_beta_fast; // YaRN low correction dim
346
- float yarn_beta_slow; // YaRN high correction dim
347
- uint32_t yarn_orig_ctx; // YaRN original context size
348
- float defrag_thold; // defragment the KV cache if holes/size > thold, <= 0 disabled (default)
349
-
350
- lm_ggml_backend_sched_eval_callback cb_eval;
351
- void * cb_eval_user_data;
352
-
353
- enum lm_ggml_type type_k; // data type for K cache [EXPERIMENTAL]
354
- enum lm_ggml_type type_v; // data type for V cache [EXPERIMENTAL]
355
-
356
- // Abort callback
357
- // if it returns true, execution of llama_decode() will be aborted
358
- // currently works only with CPU execution
359
- lm_ggml_abort_callback abort_callback;
360
- void * abort_callback_data;
361
-
362
- // Keep the booleans together and at the end of the struct to avoid misalignment during copy-by-value.
363
- bool embeddings; // if true, extract embeddings (together with logits)
364
- bool offload_kqv; // offload the KQV ops (including the KV cache) to GPU
365
- bool flash_attn; // use flash attention [EXPERIMENTAL]
366
- bool no_perf; // measure performance timings
367
- bool op_offload; // offload host tensor operations to device
368
- bool swa_full; // use full-size SWA cache (https://github.com/ggml-org/llama.cpp/pull/13194#issuecomment-2868343055)
369
- };
370
-
371
- // model quantization parameters
372
- typedef struct llama_model_quantize_params {
373
- int32_t nthread; // number of threads to use for quantizing, if <=0 will use std::thread::hardware_concurrency()
374
- enum llama_ftype ftype; // quantize to this llama_ftype
375
- enum lm_ggml_type output_tensor_type; // output tensor type
376
- enum lm_ggml_type token_embedding_type; // token embeddings tensor type
377
- bool allow_requantize; // allow quantizing non-f32/f16 tensors
378
- bool quantize_output_tensor; // quantize output.weight
379
- bool only_copy; // only copy tensors - ftype, allow_requantize and quantize_output_tensor are ignored
380
- bool pure; // quantize all tensors to the default type
381
- bool keep_split; // quantize to the same number of shards
382
- void * imatrix; // pointer to importance matrix data
383
- void * kv_overrides; // pointer to vector containing overrides
384
- void * tensor_types; // pointer to vector containing tensor types
385
- } llama_model_quantize_params;
386
-
387
- typedef struct llama_logit_bias {
388
- llama_token token;
389
- float bias;
390
- } llama_logit_bias;
391
-
392
- typedef struct llama_sampler_chain_params {
393
- bool no_perf; // whether to measure performance timings
394
- } llama_sampler_chain_params;
395
-
396
- // used in chat template
397
- typedef struct llama_chat_message {
398
- const char * role;
399
- const char * content;
400
- } llama_chat_message;
401
-
402
- // lora adapter
403
- struct llama_adapter_lora;
404
-
405
- // Helpers for getting default parameters
406
- // TODO: update API to start accepting pointers to params structs (https://github.com/ggml-org/llama.cpp/discussions/9172)
407
- LLAMA_API struct llama_model_params llama_model_default_params(void);
408
- LLAMA_API struct llama_context_params llama_context_default_params(void);
409
- LLAMA_API struct llama_sampler_chain_params llama_sampler_chain_default_params(void);
410
- LLAMA_API struct llama_model_quantize_params llama_model_quantize_default_params(void);
411
-
412
- // Initialize the llama + ggml backend
413
- // If numa is true, use NUMA optimizations
414
- // Call once at the start of the program
415
- LLAMA_API void llama_backend_init(void);
416
-
417
- // Call once at the end of the program - currently only used for MPI
418
- LLAMA_API void llama_backend_free(void);
419
-
420
- //optional:
421
- LLAMA_API void llama_numa_init(enum lm_ggml_numa_strategy numa);
422
-
423
- // Optional: an auto threadpool gets created in ggml if not passed explicitly
424
- LLAMA_API void llama_attach_threadpool(
425
- struct llama_context * ctx,
426
- lm_ggml_threadpool_t threadpool,
427
- lm_ggml_threadpool_t threadpool_batch);
428
-
429
- LLAMA_API void llama_detach_threadpool(struct llama_context * ctx);
430
-
431
- DEPRECATED(LLAMA_API struct llama_model * llama_load_model_from_file(
432
- const char * path_model,
433
- struct llama_model_params params),
434
- "use llama_model_load_from_file instead");
435
-
436
- // Load the model from a file
437
- // If the file is split into multiple parts, the file name must follow this pattern: <name>-%05d-of-%05d.gguf
438
- // If the split file name does not follow this pattern, use llama_model_load_from_splits
439
- LLAMA_API struct llama_model * llama_model_load_from_file(
440
- const char * path_model,
441
- struct llama_model_params params);
442
-
443
- // Load the model from multiple splits (support custom naming scheme)
444
- // The paths must be in the correct order
445
- LLAMA_API struct llama_model * llama_model_load_from_splits(
446
- const char ** paths,
447
- size_t n_paths,
448
- struct llama_model_params params);
449
-
450
- LLAMA_API void llama_model_save_to_file(
451
- const struct llama_model * model,
452
- const char * path_model);
453
-
454
- DEPRECATED(LLAMA_API void llama_free_model(struct llama_model * model),
455
- "use llama_model_free instead");
456
-
457
- LLAMA_API void llama_model_free(struct llama_model * model);
458
-
459
- LLAMA_API struct llama_context * llama_init_from_model(
460
- struct llama_model * model,
461
- struct llama_context_params params);
462
-
463
- DEPRECATED(LLAMA_API struct llama_context * llama_new_context_with_model(
464
- struct llama_model * model,
465
- struct llama_context_params params),
466
- "use llama_init_from_model instead");
467
-
468
- // Frees all allocated memory
469
- LLAMA_API void llama_free(struct llama_context * ctx);
470
-
471
- LLAMA_API int64_t llama_time_us(void);
472
-
473
- LLAMA_API size_t llama_max_devices(void);
474
-
475
- LLAMA_API bool llama_supports_mmap (void);
476
- LLAMA_API bool llama_supports_mlock (void);
477
- LLAMA_API bool llama_supports_gpu_offload(void);
478
- LLAMA_API bool llama_supports_rpc (void);
479
-
480
- LLAMA_API uint32_t llama_n_ctx (const struct llama_context * ctx);
481
- LLAMA_API uint32_t llama_n_batch (const struct llama_context * ctx);
482
- LLAMA_API uint32_t llama_n_ubatch (const struct llama_context * ctx);
483
- LLAMA_API uint32_t llama_n_seq_max (const struct llama_context * ctx);
484
-
485
- DEPRECATED(LLAMA_API int32_t llama_n_ctx_train(const struct llama_model * model), "use llama_model_n_ctx_train instead");
486
- DEPRECATED(LLAMA_API int32_t llama_n_embd (const struct llama_model * model), "use llama_model_n_embd instead");
487
- DEPRECATED(LLAMA_API int32_t llama_n_layer (const struct llama_model * model), "use llama_model_n_layer instead");
488
- DEPRECATED(LLAMA_API int32_t llama_n_head (const struct llama_model * model), "use llama_model_n_head instead");
489
-
490
- DEPRECATED(LLAMA_API int32_t llama_n_vocab (const struct llama_vocab * vocab), "use llama_vocab_n_tokens instead");
491
-
492
- LLAMA_API const struct llama_model * llama_get_model (const struct llama_context * ctx);
493
- LLAMA_API struct llama_kv_cache * llama_get_kv_self ( struct llama_context * ctx);
494
- LLAMA_API enum llama_pooling_type llama_pooling_type(const struct llama_context * ctx); // TODO: rename to llama_get_pooling_type
495
-
496
- LLAMA_API const struct llama_vocab * llama_model_get_vocab(const struct llama_model * model);
497
- LLAMA_API enum llama_rope_type llama_model_rope_type(const struct llama_model * model);
498
-
499
- LLAMA_API int32_t llama_model_n_ctx_train(const struct llama_model * model);
500
- LLAMA_API int32_t llama_model_n_embd (const struct llama_model * model);
501
- LLAMA_API int32_t llama_model_n_layer (const struct llama_model * model);
502
- LLAMA_API int32_t llama_model_n_head (const struct llama_model * model);
503
- LLAMA_API int32_t llama_model_n_head_kv (const struct llama_model * model);
504
-
505
- // Get the model's RoPE frequency scaling factor
506
- LLAMA_API float llama_model_rope_freq_scale_train(const struct llama_model * model);
507
-
508
- LLAMA_API enum llama_vocab_type llama_vocab_type(const struct llama_vocab * vocab);
509
-
510
- LLAMA_API int32_t llama_vocab_n_tokens(const struct llama_vocab * vocab);
511
-
512
- // Functions to access the model's GGUF metadata scalar values
513
- // - The functions return the length of the string on success, or -1 on failure
514
- // - The output string is always null-terminated and cleared on failure
515
- // - When retrieving a string, an extra byte must be allocated to account for the null terminator
516
- // - GGUF array values are not supported by these functions
517
-
518
- // Get metadata value as a string by key name
519
- LLAMA_API int32_t llama_model_meta_val_str(const struct llama_model * model, const char * key, char * buf, size_t buf_size);
520
-
521
- // Get the number of metadata key/value pairs
522
- LLAMA_API int32_t llama_model_meta_count(const struct llama_model * model);
523
-
524
- // Get metadata key name by index
525
- LLAMA_API int32_t llama_model_meta_key_by_index(const struct llama_model * model, int32_t i, char * buf, size_t buf_size);
526
-
527
- // Get metadata value as a string by index
528
- LLAMA_API int32_t llama_model_meta_val_str_by_index(const struct llama_model * model, int32_t i, char * buf, size_t buf_size);
529
-
530
- // Get a string describing the model type
531
- LLAMA_API int32_t llama_model_desc(const struct llama_model * model, char * buf, size_t buf_size);
532
-
533
- // Returns the total size of all the tensors in the model in bytes
534
- LLAMA_API uint64_t llama_model_size(const struct llama_model * model);
535
-
536
- // Get the default chat template. Returns nullptr if not available
537
- // If name is NULL, returns the default chat template
538
- LLAMA_API const char * llama_model_chat_template(const struct llama_model * model, const char * name);
539
-
540
- // Returns the total number of parameters in the model
541
- LLAMA_API uint64_t llama_model_n_params(const struct llama_model * model);
542
-
543
- // Returns true if the model contains an encoder that requires llama_encode() call
544
- LLAMA_API bool llama_model_has_encoder(const struct llama_model * model);
545
-
546
- // Returns true if the model contains a decoder that requires llama_decode() call
547
- LLAMA_API bool llama_model_has_decoder(const struct llama_model * model);
548
-
549
- // For encoder-decoder models, this function returns id of the token that must be provided
550
- // to the decoder to start generating output sequence. For other models, it returns -1.
551
- LLAMA_API llama_token llama_model_decoder_start_token(const struct llama_model * model);
552
-
553
- // Returns true if the model is recurrent (like Mamba, RWKV, etc.)
554
- LLAMA_API bool llama_model_is_recurrent(const struct llama_model * model);
555
-
556
- // Returns 0 on success
557
- LLAMA_API uint32_t llama_model_quantize(
558
- const char * fname_inp,
559
- const char * fname_out,
560
- const llama_model_quantize_params * params);
561
-
562
- //
563
- // Adapters
564
- //
565
-
566
- // Load a LoRA adapter from file
567
- LLAMA_API struct llama_adapter_lora * llama_adapter_lora_init(
568
- struct llama_model * model,
569
- const char * path_lora);
570
-
571
- // Manually free a LoRA adapter
572
- // Note: loaded adapters will be free when the associated model is deleted
573
- LLAMA_API void llama_adapter_lora_free(struct llama_adapter_lora * adapter);
574
-
575
- // The following functions operate on a llama_context, hence the naming: llama_verb_...
576
-
577
- // Add a loaded LoRA adapter to given context
578
- // This will not modify model's weight
579
- LLAMA_API int32_t llama_set_adapter_lora(
580
- struct llama_context * ctx,
581
- struct llama_adapter_lora * adapter,
582
- float scale);
583
-
584
- // Remove a specific LoRA adapter from given context
585
- // Return -1 if the adapter is not present in the context
586
- LLAMA_API int32_t llama_rm_adapter_lora(
587
- struct llama_context * ctx,
588
- struct llama_adapter_lora * adapter);
589
-
590
- // Remove all LoRA adapters from given context
591
- LLAMA_API void llama_clear_adapter_lora(struct llama_context * ctx);
592
-
593
- // Apply a loaded control vector to a llama_context, or if data is NULL, clear
594
- // the currently loaded vector.
595
- // n_embd should be the size of a single layer's control, and data should point
596
- // to an n_embd x n_layers buffer starting from layer 1.
597
- // il_start and il_end are the layer range the vector should apply to (both inclusive)
598
- // See llama_control_vector_load in common to load a control vector.
599
- LLAMA_API int32_t llama_apply_adapter_cvec(
600
- struct llama_context * ctx,
601
- const float * data,
602
- size_t len,
603
- int32_t n_embd,
604
- int32_t il_start,
605
- int32_t il_end);
606
-
607
- //
608
- // KV cache
609
- //
610
-
611
- // Returns the number of tokens in the KV cache (slow, use only for debug)
612
- // If a KV cell has multiple sequences assigned to it, it will be counted multiple times
613
- DEPRECATED(LLAMA_API int32_t llama_kv_self_n_tokens(const struct llama_context * ctx),
614
- "Use llama_kv_self_seq_pos_max() instead");
615
-
616
- // Returns the number of used KV cells (i.e. have at least one sequence assigned to them)
617
- DEPRECATED(LLAMA_API int32_t llama_kv_self_used_cells(const struct llama_context * ctx),
618
- "Use llama_kv_self_seq_pos_max() instead");
619
-
620
- // Clear the KV cache - both cell info is erased and KV data is zeroed
621
- LLAMA_API void llama_kv_self_clear(
622
- struct llama_context * ctx);
623
-
624
- // Removes all tokens that belong to the specified sequence and have positions in [p0, p1)
625
- // Returns false if a partial sequence cannot be removed. Removing a whole sequence never fails
626
- // seq_id < 0 : match any sequence
627
- // p0 < 0 : [0, p1]
628
- // p1 < 0 : [p0, inf)
629
- LLAMA_API bool llama_kv_self_seq_rm(
630
- struct llama_context * ctx,
631
- llama_seq_id seq_id,
632
- llama_pos p0,
633
- llama_pos p1);
634
-
635
- // Copy all tokens that belong to the specified sequence to another sequence
636
- // Note that this does not allocate extra KV cache memory - it simply assigns the tokens to the new sequence
637
- // p0 < 0 : [0, p1]
638
- // p1 < 0 : [p0, inf)
639
- LLAMA_API void llama_kv_self_seq_cp(
640
- struct llama_context * ctx,
641
- llama_seq_id seq_id_src,
642
- llama_seq_id seq_id_dst,
643
- llama_pos p0,
644
- llama_pos p1);
645
-
646
- // Removes all tokens that do not belong to the specified sequence
647
- LLAMA_API void llama_kv_self_seq_keep(
648
- struct llama_context * ctx,
649
- llama_seq_id seq_id);
650
-
651
- // Adds relative position "delta" to all tokens that belong to the specified sequence and have positions in [p0, p1)
652
- // If the KV cache is RoPEd, the KV data is updated accordingly:
653
- // - lazily on next llama_decode()
654
- // - explicitly with llama_kv_self_update()
655
- // p0 < 0 : [0, p1]
656
- // p1 < 0 : [p0, inf)
657
- LLAMA_API void llama_kv_self_seq_add(
658
- struct llama_context * ctx,
659
- llama_seq_id seq_id,
660
- llama_pos p0,
661
- llama_pos p1,
662
- llama_pos delta);
663
-
664
- // Integer division of the positions by factor of `d > 1`
665
- // If the KV cache is RoPEd, the KV data is updated accordingly:
666
- // - lazily on next llama_decode()
667
- // - explicitly with llama_kv_self_update()
668
- // p0 < 0 : [0, p1]
669
- // p1 < 0 : [p0, inf)
670
- LLAMA_API void llama_kv_self_seq_div(
671
- struct llama_context * ctx,
672
- llama_seq_id seq_id,
673
- llama_pos p0,
674
- llama_pos p1,
675
- int d);
676
-
677
- // Returns the smallest position present in the KV cache for the specified sequence
678
- // This is typically non-zero only for SWA caches
679
- // Return -1 if the sequence is empty
680
- LLAMA_API llama_pos llama_kv_self_seq_pos_min(
681
- struct llama_context * ctx,
682
- llama_seq_id seq_id);
683
-
684
- // Returns the largest position present in the KV cache for the specified sequence
685
- // Return -1 if the sequence is empty
686
- LLAMA_API llama_pos llama_kv_self_seq_pos_max(
687
- struct llama_context * ctx,
688
- llama_seq_id seq_id);
689
-
690
- // Defragment the KV cache
691
- // This will be applied:
692
- // - lazily on next llama_decode()
693
- // - explicitly with llama_kv_self_update()
694
- LLAMA_API void llama_kv_self_defrag(struct llama_context * ctx);
695
-
696
- // Check if the context supports KV cache shifting
697
- LLAMA_API bool llama_kv_self_can_shift(const struct llama_context * ctx);
698
-
699
- // Apply the KV cache updates (such as K-shifts, defragmentation, etc.)
700
- LLAMA_API void llama_kv_self_update(struct llama_context * ctx);
701
-
702
- //
703
- // State / sessions
704
- //
705
-
706
- // Returns the *actual* size in bytes of the state
707
- // (logits, embedding and kv_cache)
708
- // Only use when saving the state, not when restoring it, otherwise the size may be too small.
709
- LLAMA_API size_t llama_state_get_size(struct llama_context * ctx);
710
- LLAMA_API DEPRECATED(size_t llama_get_state_size(struct llama_context * ctx),
711
- "use llama_state_get_size instead");
712
-
713
- // Copies the state to the specified destination address.
714
- // Destination needs to have allocated enough memory.
715
- // Returns the number of bytes copied
716
- LLAMA_API size_t llama_state_get_data(
717
- struct llama_context * ctx,
718
- uint8_t * dst,
719
- size_t size);
720
- LLAMA_API DEPRECATED(size_t llama_copy_state_data(
721
- struct llama_context * ctx,
722
- uint8_t * dst),
723
- "use llama_state_get_data instead");
724
-
725
- // Set the state reading from the specified address
726
- // Returns the number of bytes read
727
- LLAMA_API size_t llama_state_set_data(
728
- struct llama_context * ctx,
729
- const uint8_t * src,
730
- size_t size);
731
- LLAMA_API DEPRECATED(size_t llama_set_state_data(
732
- struct llama_context * ctx,
733
- const uint8_t * src),
734
- "use llama_state_set_data instead");
735
-
736
- // Save/load session file
737
- LLAMA_API bool llama_state_load_file(
738
- struct llama_context * ctx,
739
- const char * path_session,
740
- llama_token * tokens_out,
741
- size_t n_token_capacity,
742
- size_t * n_token_count_out);
743
- LLAMA_API DEPRECATED(bool llama_load_session_file(
744
- struct llama_context * ctx,
745
- const char * path_session,
746
- llama_token * tokens_out,
747
- size_t n_token_capacity,
748
- size_t * n_token_count_out),
749
- "use llama_state_load_file instead");
750
-
751
- LLAMA_API bool llama_state_save_file(
752
- struct llama_context * ctx,
753
- const char * path_session,
754
- const llama_token * tokens,
755
- size_t n_token_count);
756
- LLAMA_API DEPRECATED(bool llama_save_session_file(
757
- struct llama_context * ctx,
758
- const char * path_session,
759
- const llama_token * tokens,
760
- size_t n_token_count),
761
- "use llama_state_save_file instead");
762
-
763
- // Get the exact size needed to copy the KV cache of a single sequence
764
- LLAMA_API size_t llama_state_seq_get_size(
765
- struct llama_context * ctx,
766
- llama_seq_id seq_id);
767
-
768
- // Copy the KV cache of a single sequence into the specified buffer
769
- LLAMA_API size_t llama_state_seq_get_data(
770
- struct llama_context * ctx,
771
- uint8_t * dst,
772
- size_t size,
773
- llama_seq_id seq_id);
774
-
775
- // Copy the sequence data (originally copied with `llama_state_seq_get_data`) into the specified sequence
776
- // Returns:
777
- // - Positive: Ok
778
- // - Zero: Failed to load
779
- LLAMA_API size_t llama_state_seq_set_data(
780
- struct llama_context * ctx,
781
- const uint8_t * src,
782
- size_t size,
783
- llama_seq_id dest_seq_id);
784
-
785
- LLAMA_API size_t llama_state_seq_save_file(
786
- struct llama_context * ctx,
787
- const char * filepath,
788
- llama_seq_id seq_id,
789
- const llama_token * tokens,
790
- size_t n_token_count);
791
-
792
- LLAMA_API size_t llama_state_seq_load_file(
793
- struct llama_context * ctx,
794
- const char * filepath,
795
- llama_seq_id dest_seq_id,
796
- llama_token * tokens_out,
797
- size_t n_token_capacity,
798
- size_t * n_token_count_out);
799
-
800
- //
801
- // Decoding
802
- //
803
-
804
- // Return batch for single sequence of tokens
805
- // The sequence ID will be fixed to 0
806
- // The position of the tokens will be tracked automatically by llama_decode
807
- //
808
- // NOTE: this is a helper function to facilitate transition to the new batch API - avoid using it
809
- //
810
- LLAMA_API struct llama_batch llama_batch_get_one(
811
- llama_token * tokens,
812
- int32_t n_tokens);
813
-
814
- // Allocates a batch of tokens on the heap that can hold a maximum of n_tokens
815
- // Each token can be assigned up to n_seq_max sequence ids
816
- // The batch has to be freed with llama_batch_free()
817
- // If embd != 0, llama_batch.embd will be allocated with size of n_tokens * embd * sizeof(float)
818
- // Otherwise, llama_batch.token will be allocated to store n_tokens llama_token
819
- // The rest of the llama_batch members are allocated with size n_tokens
820
- // All members are left uninitialized
821
- LLAMA_API struct llama_batch llama_batch_init(
822
- int32_t n_tokens,
823
- int32_t embd,
824
- int32_t n_seq_max);
825
-
826
- // Frees a batch of tokens allocated with llama_batch_init()
827
- LLAMA_API void llama_batch_free(struct llama_batch batch);
828
-
829
- // Process a batch of tokens.
830
- // In contrast to llama_decode() - this call does not use KV cache.
831
- // For encode-decoder contexts, processes the batch using the encoder.
832
- // Can store the encoder output internally for later use by the decoder's cross-attention layers.
833
- // 0 - success
834
- // < 0 - error. the KV cache state is restored to the state before this call
835
- LLAMA_API int32_t llama_encode(
836
- struct llama_context * ctx,
837
- struct llama_batch batch);
838
-
839
- // Process a batch of tokens.
840
- // Requires KV cache.
841
- // For encode-decoder contexts, processes the batch using the decoder.
842
- // Positive return values does not mean a fatal error, but rather a warning.
843
- // Upon non-zero return values, the KV cache state is restored to the state before this call
844
- // 0 - success
845
- // 1 - could not find a KV slot for the batch (try reducing the size of the batch or increase the context)
846
- // 2 - aborted
847
- // -1 - invalid input batch
848
- // < -1 - error
849
- LLAMA_API int32_t llama_decode(
850
- struct llama_context * ctx,
851
- struct llama_batch batch);
852
-
853
- // Set the number of threads used for decoding
854
- // n_threads is the number of threads used for generation (single token)
855
- // n_threads_batch is the number of threads used for prompt and batch processing (multiple tokens)
856
- LLAMA_API void llama_set_n_threads(struct llama_context * ctx, int32_t n_threads, int32_t n_threads_batch);
857
-
858
- // Get the number of threads used for generation of a single token.
859
- LLAMA_API int32_t llama_n_threads(struct llama_context * ctx);
860
-
861
- // Get the number of threads used for prompt and batch processing (multiple token).
862
- LLAMA_API int32_t llama_n_threads_batch(struct llama_context * ctx);
863
-
864
- // Set whether the model is in embeddings mode or not
865
- // If true, embeddings will be returned but logits will not
866
- LLAMA_API void llama_set_embeddings(struct llama_context * ctx, bool embeddings);
867
-
868
- // Set whether to use causal attention or not
869
- // If set to true, the model will only attend to the past tokens
870
- LLAMA_API void llama_set_causal_attn(struct llama_context * ctx, bool causal_attn);
871
-
872
- // Set whether the model is in warmup mode or not
873
- // If true, all model tensors are activated during llama_decode() to load and cache their weights.
874
- LLAMA_API void llama_set_warmup(struct llama_context * ctx, bool warmup);
875
-
876
- // Set abort callback
877
- LLAMA_API void llama_set_abort_callback(struct llama_context * ctx, lm_ggml_abort_callback abort_callback, void * abort_callback_data);
878
-
879
- // Wait until all computations are finished
880
- // This is automatically done when using one of the functions below to obtain the computation results
881
- // and is not necessary to call it explicitly in most cases
882
- LLAMA_API void llama_synchronize(struct llama_context * ctx);
883
-
884
- // Token logits obtained from the last call to llama_decode()
885
- // The logits for which llama_batch.logits[i] != 0 are stored contiguously
886
- // in the order they have appeared in the batch.
887
- // Rows: number of tokens for which llama_batch.logits[i] != 0
888
- // Cols: n_vocab
889
- LLAMA_API float * llama_get_logits(struct llama_context * ctx);
890
-
891
- // Logits for the ith token. For positive indices, Equivalent to:
892
- // llama_get_logits(ctx) + ctx->output_ids[i]*n_vocab
893
- // Negative indicies can be used to access logits in reverse order, -1 is the last logit.
894
- // returns NULL for invalid ids.
895
- LLAMA_API float * llama_get_logits_ith(struct llama_context * ctx, int32_t i);
896
-
897
- // Get all output token embeddings.
898
- // when pooling_type == LLAMA_POOLING_TYPE_NONE or when using a generative model,
899
- // the embeddings for which llama_batch.logits[i] != 0 are stored contiguously
900
- // in the order they have appeared in the batch.
901
- // shape: [n_outputs*n_embd]
902
- // Otherwise, returns NULL.
903
- LLAMA_API float * llama_get_embeddings(struct llama_context * ctx);
904
-
905
- // Get the embeddings for the ith token. For positive indices, Equivalent to:
906
- // llama_get_embeddings(ctx) + ctx->output_ids[i]*n_embd
907
- // Negative indicies can be used to access embeddings in reverse order, -1 is the last embedding.
908
- // shape: [n_embd] (1-dimensional)
909
- // returns NULL for invalid ids.
910
- LLAMA_API float * llama_get_embeddings_ith(struct llama_context * ctx, int32_t i);
911
-
912
- // Get the embeddings for a sequence id
913
- // Returns NULL if pooling_type is LLAMA_POOLING_TYPE_NONE
914
- // when pooling_type == LLAMA_POOLING_TYPE_RANK, returns float[1] with the rank of the sequence
915
- // otherwise: float[n_embd] (1-dimensional)
916
- LLAMA_API float * llama_get_embeddings_seq(struct llama_context * ctx, llama_seq_id seq_id);
917
-
918
- //
919
- // Vocab
920
- //
921
-
922
- LLAMA_API const char * llama_vocab_get_text(const struct llama_vocab * vocab, llama_token token);
923
-
924
- LLAMA_API float llama_vocab_get_score(const struct llama_vocab * vocab, llama_token token);
925
-
926
- LLAMA_API enum llama_token_attr llama_vocab_get_attr(const struct llama_vocab * vocab, llama_token token);
927
-
928
- // Check if the token is supposed to end generation (end-of-generation, eg. EOS, EOT, etc.)
929
- LLAMA_API bool llama_vocab_is_eog(const struct llama_vocab * vocab, llama_token token);
930
-
931
- // Identify if Token Id is a control token or a render-able token
932
- LLAMA_API bool llama_vocab_is_control(const struct llama_vocab * vocab, llama_token token);
933
-
934
- // Special tokens
935
- LLAMA_API llama_token llama_vocab_bos(const struct llama_vocab * vocab); // beginning-of-sentence
936
- LLAMA_API llama_token llama_vocab_eos(const struct llama_vocab * vocab); // end-of-sentence
937
- LLAMA_API llama_token llama_vocab_eot(const struct llama_vocab * vocab); // end-of-turn
938
- LLAMA_API llama_token llama_vocab_sep(const struct llama_vocab * vocab); // sentence separator
939
- LLAMA_API llama_token llama_vocab_nl (const struct llama_vocab * vocab); // next-line
940
- LLAMA_API llama_token llama_vocab_pad(const struct llama_vocab * vocab); // padding
941
-
942
- LLAMA_API bool llama_vocab_get_add_bos(const struct llama_vocab * vocab);
943
- LLAMA_API bool llama_vocab_get_add_eos(const struct llama_vocab * vocab);
944
-
945
- LLAMA_API llama_token llama_vocab_fim_pre(const struct llama_vocab * vocab);
946
- LLAMA_API llama_token llama_vocab_fim_suf(const struct llama_vocab * vocab);
947
- LLAMA_API llama_token llama_vocab_fim_mid(const struct llama_vocab * vocab);
948
- LLAMA_API llama_token llama_vocab_fim_pad(const struct llama_vocab * vocab);
949
- LLAMA_API llama_token llama_vocab_fim_rep(const struct llama_vocab * vocab);
950
- LLAMA_API llama_token llama_vocab_fim_sep(const struct llama_vocab * vocab);
951
-
952
- DEPRECATED(LLAMA_API const char * llama_token_get_text(const struct llama_vocab * vocab, llama_token token), "use llama_vocab_get_text instead");
953
- DEPRECATED(LLAMA_API float llama_token_get_score(const struct llama_vocab * vocab, llama_token token), "use llama_vocab_get_score instead");
954
- DEPRECATED(LLAMA_API enum llama_token_attr llama_token_get_attr(const struct llama_vocab * vocab, llama_token token), "use llama_vocab_get_attr instead");
955
- DEPRECATED(LLAMA_API bool llama_token_is_eog(const struct llama_vocab * vocab, llama_token token), "use llama_vocab_is_eog instead");
956
- DEPRECATED(LLAMA_API bool llama_token_is_control(const struct llama_vocab * vocab, llama_token token), "use llama_vocab_is_control instead");
957
- DEPRECATED(LLAMA_API llama_token llama_token_bos(const struct llama_vocab * vocab), "use llama_vocab_bos instead");
958
- DEPRECATED(LLAMA_API llama_token llama_token_eos(const struct llama_vocab * vocab), "use llama_vocab_eos instead");
959
- DEPRECATED(LLAMA_API llama_token llama_token_eot(const struct llama_vocab * vocab), "use llama_vocab_eot instead");
960
- DEPRECATED(LLAMA_API llama_token llama_token_cls(const struct llama_vocab * vocab), "use llama_vocab_cls instead");
961
- DEPRECATED(LLAMA_API llama_token llama_token_sep(const struct llama_vocab * vocab), "use llama_vocab_sep instead");
962
- DEPRECATED(LLAMA_API llama_token llama_token_nl (const struct llama_vocab * vocab), "use llama_vocab_nl instead");
963
- DEPRECATED(LLAMA_API llama_token llama_token_pad(const struct llama_vocab * vocab), "use llama_vocab_pad instead");
964
- DEPRECATED(LLAMA_API bool llama_add_bos_token(const struct llama_vocab * vocab), "use llama_vocab_get_add_bos instead");
965
- DEPRECATED(LLAMA_API bool llama_add_eos_token(const struct llama_vocab * vocab), "use llama_vocab_get_add_eos instead");
966
- DEPRECATED(LLAMA_API llama_token llama_token_fim_pre(const struct llama_vocab * vocab), "use llama_vocab_fim_pre instead");
967
- DEPRECATED(LLAMA_API llama_token llama_token_fim_suf(const struct llama_vocab * vocab), "use llama_vocab_fim_suf instead");
968
- DEPRECATED(LLAMA_API llama_token llama_token_fim_mid(const struct llama_vocab * vocab), "use llama_vocab_fim_mid instead");
969
- DEPRECATED(LLAMA_API llama_token llama_token_fim_pad(const struct llama_vocab * vocab), "use llama_vocab_fim_pad instead");
970
- DEPRECATED(LLAMA_API llama_token llama_token_fim_rep(const struct llama_vocab * vocab), "use llama_vocab_fim_rep instead");
971
- DEPRECATED(LLAMA_API llama_token llama_token_fim_sep(const struct llama_vocab * vocab), "use llama_vocab_fim_sep instead");
972
-
973
- // CLS is equivalent to BOS
974
- DEPRECATED(LLAMA_API llama_token llama_vocab_cls(const struct llama_vocab * vocab), // classification
975
- "use llama_vocab_bos instead");
976
-
977
- //
978
- // Tokenization
979
- //
980
- // The API is thread-safe.
981
- //
982
-
983
- /// @details Convert the provided text into tokens.
984
- /// @param tokens The tokens pointer must be large enough to hold the resulting tokens.
985
- /// @return Returns the number of tokens on success, no more than n_tokens_max
986
- /// @return Returns a negative number on failure - the number of tokens that would have been returned
987
- /// @param add_special Allow to add BOS and EOS tokens if model is configured to do so.
988
- /// @param parse_special Allow tokenizing special and/or control tokens which otherwise are not exposed and treated
989
- /// as plaintext. Does not insert a leading space.
990
- LLAMA_API int32_t llama_tokenize(
991
- const struct llama_vocab * vocab,
992
- const char * text,
993
- int32_t text_len,
994
- llama_token * tokens,
995
- int32_t n_tokens_max,
996
- bool add_special,
997
- bool parse_special);
998
-
999
- // Token Id -> Piece.
1000
- // Uses the vocabulary in the provided context.
1001
- // Does not write null terminator to the buffer.
1002
- // User can skip up to 'lstrip' leading spaces before copying (useful when encoding/decoding multiple tokens with 'add_space_prefix')
1003
- // @param special If true, special tokens are rendered in the output.
1004
- LLAMA_API int32_t llama_token_to_piece(
1005
- const struct llama_vocab * vocab,
1006
- llama_token token,
1007
- char * buf,
1008
- int32_t length,
1009
- int32_t lstrip,
1010
- bool special);
1011
-
1012
- /// @details Convert the provided tokens into text (inverse of llama_tokenize()).
1013
- /// @param text The char pointer must be large enough to hold the resulting text.
1014
- /// @return Returns the number of chars/bytes on success, no more than text_len_max.
1015
- /// @return Returns a negative number on failure - the number of chars/bytes that would have been returned.
1016
- /// @param remove_special Allow to remove BOS and EOS tokens if model is configured to do so.
1017
- /// @param unparse_special If true, special tokens are rendered in the output.
1018
- LLAMA_API int32_t llama_detokenize(
1019
- const struct llama_vocab * vocab,
1020
- const llama_token * tokens,
1021
- int32_t n_tokens,
1022
- char * text,
1023
- int32_t text_len_max,
1024
- bool remove_special,
1025
- bool unparse_special);
1026
-
1027
- //
1028
- // Chat templates
1029
- //
1030
-
1031
- /// Apply chat template. Inspired by hf apply_chat_template() on python.
1032
- /// Both "model" and "custom_template" are optional, but at least one is required. "custom_template" has higher precedence than "model"
1033
- /// NOTE: This function does not use a jinja parser. It only support a pre-defined list of template. See more: https://github.com/ggml-org/llama.cpp/wiki/Templates-supported-by-llama_chat_apply_template
1034
- /// @param tmpl A Jinja template to use for this chat. If this is nullptr, the model’s default chat template will be used instead.
1035
- /// @param chat Pointer to a list of multiple llama_chat_message
1036
- /// @param n_msg Number of llama_chat_message in this chat
1037
- /// @param add_ass Whether to end the prompt with the token(s) that indicate the start of an assistant message.
1038
- /// @param buf A buffer to hold the output formatted prompt. The recommended alloc size is 2 * (total number of characters of all messages)
1039
- /// @param length The size of the allocated buffer
1040
- /// @return The total number of bytes of the formatted prompt. If is it larger than the size of buffer, you may need to re-alloc it and then re-apply the template.
1041
- LLAMA_API int32_t llama_chat_apply_template(
1042
- const char * tmpl,
1043
- const struct llama_chat_message * chat,
1044
- size_t n_msg,
1045
- bool add_ass,
1046
- char * buf,
1047
- int32_t length);
1048
-
1049
- // Get list of built-in chat templates
1050
- LLAMA_API int32_t llama_chat_builtin_templates(const char ** output, size_t len);
1051
-
1052
- //
1053
- // Sampling API
1054
- //
1055
- // Sample usage:
1056
- //
1057
- // // prepare the sampling chain at the start
1058
- // auto sparams = llama_sampler_chain_default_params();
1059
- //
1060
- // llama_sampler * smpl = llama_sampler_chain_init(sparams);
1061
- //
1062
- // llama_sampler_chain_add(smpl, llama_sampler_init_top_k(50));
1063
- // llama_sampler_chain_add(smpl, llama_sampler_init_top_p(0.9, 1));
1064
- // llama_sampler_chain_add(smpl, llama_sampler_init_temp (0.8));
1065
- //
1066
- // // typically, the chain should end with a sampler such as "greedy", "dist" or "mirostat"
1067
- // // this sampler will be responsible to select the actual token
1068
- // llama_sampler_chain_add(smpl, llama_sampler_init_dist(seed));
1069
- //
1070
- // ...
1071
- //
1072
- // // decoding loop:
1073
- // while (...) {
1074
- // ...
1075
- //
1076
- // llama_decode(ctx, batch);
1077
- //
1078
- // // sample from the logits of the last token in the batch
1079
- // const llama_token id = llama_sampler_sample(smpl, ctx, -1);
1080
- //
1081
- // // accepting the token updates the internal state of certain samplers (e.g. grammar, repetition, etc.)
1082
- // llama_sampler_accept(smpl, id);
1083
- // ...
1084
- // }
1085
- //
1086
- // llama_sampler_free(smpl);
1087
- //
1088
- // TODO: In the future, llama_sampler will be utilized to offload the sampling to the backends (e.g. GPU).
1089
- //
1090
-
1091
- typedef void * llama_sampler_context_t;
1092
-
1093
- // user code can implement the interface below in order to create custom llama_sampler
1094
- struct llama_sampler_i {
1095
- const char * (*name) (const struct llama_sampler * smpl); // can be NULL
1096
- void (*accept)( struct llama_sampler * smpl, llama_token token); // can be NULL
1097
- void (*apply) ( struct llama_sampler * smpl, llama_token_data_array * cur_p); // required
1098
- void (*reset) ( struct llama_sampler * smpl); // can be NULL
1099
- struct llama_sampler * (*clone) (const struct llama_sampler * smpl); // can be NULL if ctx is NULL
1100
- void (*free) ( struct llama_sampler * smpl); // can be NULL if ctx is NULL
1101
-
1102
- // TODO: API for internal libllama usage for appending the sampling to an existing lm_ggml_cgraph
1103
- //void (*apply_ggml) (struct llama_sampler * smpl, ...);
1104
- };
1105
-
1106
- struct llama_sampler {
1107
- const struct llama_sampler_i * iface;
1108
- llama_sampler_context_t ctx;
1109
- };
1110
-
1111
- // mirror of llama_sampler_i:
1112
- LLAMA_API struct llama_sampler * llama_sampler_init (const struct llama_sampler_i * iface, llama_sampler_context_t ctx);
1113
- LLAMA_API const char * llama_sampler_name (const struct llama_sampler * smpl);
1114
- LLAMA_API void llama_sampler_accept( struct llama_sampler * smpl, llama_token token);
1115
- LLAMA_API void llama_sampler_apply ( struct llama_sampler * smpl, llama_token_data_array * cur_p);
1116
- LLAMA_API void llama_sampler_reset ( struct llama_sampler * smpl);
1117
- LLAMA_API struct llama_sampler * llama_sampler_clone (const struct llama_sampler * smpl);
1118
- // important: do not free if the sampler has been added to a llama_sampler_chain (via llama_sampler_chain_add)
1119
- LLAMA_API void llama_sampler_free ( struct llama_sampler * smpl);
1120
-
1121
- // llama_sampler_chain
1122
- // a type of llama_sampler that can chain multiple samplers one after another
1123
-
1124
- LLAMA_API struct llama_sampler * llama_sampler_chain_init(struct llama_sampler_chain_params params);
1125
-
1126
- // important: takes ownership of the sampler object and will free it when llama_sampler_free is called
1127
- LLAMA_API void llama_sampler_chain_add( struct llama_sampler * chain, struct llama_sampler * smpl);
1128
- LLAMA_API struct llama_sampler * llama_sampler_chain_get(const struct llama_sampler * chain, int32_t i);
1129
- LLAMA_API int llama_sampler_chain_n (const struct llama_sampler * chain);
1130
-
1131
- // after removing a sampler, the chain will no longer own it, and it will not be freed when the chain is freed
1132
- LLAMA_API struct llama_sampler * llama_sampler_chain_remove( struct llama_sampler * chain, int32_t i);
1133
-
1134
- // available samplers:
1135
-
1136
- LLAMA_API struct llama_sampler * llama_sampler_init_greedy(void);
1137
- LLAMA_API struct llama_sampler * llama_sampler_init_dist (uint32_t seed);
1138
-
1139
- /// @details Sorts candidate tokens by their logits in descending order and calculate probabilities based on logits.
1140
- /// NOTE: Avoid using on the full vocabulary as the sorting can become slow. For example, apply top-k or top-p sampling first.
1141
- DEPRECATED(LLAMA_API struct llama_sampler * llama_sampler_init_softmax (void),
1142
- "will be removed in the future (see https://github.com/ggml-org/llama.cpp/pull/9896#discussion_r1800920915)");
1143
-
1144
- /// @details Top-K sampling described in academic paper "The Curious Case of Neural Text Degeneration" https://arxiv.org/abs/1904.09751
1145
- /// Setting k <= 0 makes this a noop
1146
- LLAMA_API struct llama_sampler * llama_sampler_init_top_k (int32_t k);
1147
-
1148
- /// @details Nucleus sampling described in academic paper "The Curious Case of Neural Text Degeneration" https://arxiv.org/abs/1904.09751
1149
- LLAMA_API struct llama_sampler * llama_sampler_init_top_p (float p, size_t min_keep);
1150
-
1151
- /// @details Minimum P sampling as described in https://github.com/ggml-org/llama.cpp/pull/3841
1152
- LLAMA_API struct llama_sampler * llama_sampler_init_min_p (float p, size_t min_keep);
1153
-
1154
- /// @details Locally Typical Sampling implementation described in the paper https://arxiv.org/abs/2202.00666.
1155
- LLAMA_API struct llama_sampler * llama_sampler_init_typical (float p, size_t min_keep);
1156
-
1157
- /// #details Updates the logits l_i` = l_i/t. When t <= 0.0f, the maximum logit is kept at it's original value, the rest are set to -inf
1158
- LLAMA_API struct llama_sampler * llama_sampler_init_temp (float t);
1159
-
1160
- /// @details Dynamic temperature implementation (a.k.a. entropy) described in the paper https://arxiv.org/abs/2309.02772.
1161
- LLAMA_API struct llama_sampler * llama_sampler_init_temp_ext (float t, float delta, float exponent);
1162
-
1163
- /// @details XTC sampler as described in https://github.com/oobabooga/text-generation-webui/pull/6335
1164
- LLAMA_API struct llama_sampler * llama_sampler_init_xtc (float p, float t, size_t min_keep, uint32_t seed);
1165
-
1166
- /// @details Top n sigma sampling as described in academic paper "Top-nσ: Not All Logits Are You Need" https://arxiv.org/pdf/2411.07641
1167
- LLAMA_API struct llama_sampler * llama_sampler_init_top_n_sigma(float n);
1168
-
1169
- /// @details Mirostat 1.0 algorithm described in the paper https://arxiv.org/abs/2007.14966. Uses tokens instead of words.
1170
- /// @param candidates A vector of `llama_token_data` containing the candidate tokens, their probabilities (p), and log-odds (logit) for the current position in the generated text.
1171
- /// @param tau The target cross-entropy (or surprise) value you want to achieve for the generated text. A higher value corresponds to more surprising or less predictable text, while a lower value corresponds to less surprising or more predictable text.
1172
- /// @param eta The learning rate used to update `mu` based on the error between the target and observed surprisal of the sampled word. A larger learning rate will cause `mu` to be updated more quickly, while a smaller learning rate will result in slower updates.
1173
- /// @param m The number of tokens considered in the estimation of `s_hat`. This is an arbitrary value that is used to calculate `s_hat`, which in turn helps to calculate the value of `k`. In the paper, they use `m = 100`, but you can experiment with different values to see how it affects the performance of the algorithm.
1174
- /// @param mu Maximum cross-entropy. This value is initialized to be twice the target cross-entropy (`2 * tau`) and is updated in the algorithm based on the error between the target and observed surprisal.
1175
- LLAMA_API struct llama_sampler * llama_sampler_init_mirostat(
1176
- int32_t n_vocab,
1177
- uint32_t seed,
1178
- float tau,
1179
- float eta,
1180
- int32_t m);
1181
-
1182
- /// @details Mirostat 2.0 algorithm described in the paper https://arxiv.org/abs/2007.14966. Uses tokens instead of words.
1183
- /// @param candidates A vector of `llama_token_data` containing the candidate tokens, their probabilities (p), and log-odds (logit) for the current position in the generated text.
1184
- /// @param tau The target cross-entropy (or surprise) value you want to achieve for the generated text. A higher value corresponds to more surprising or less predictable text, while a lower value corresponds to less surprising or more predictable text.
1185
- /// @param eta The learning rate used to update `mu` based on the error between the target and observed surprisal of the sampled word. A larger learning rate will cause `mu` to be updated more quickly, while a smaller learning rate will result in slower updates.
1186
- /// @param mu Maximum cross-entropy. This value is initialized to be twice the target cross-entropy (`2 * tau`) and is updated in the algorithm based on the error between the target and observed surprisal.
1187
- LLAMA_API struct llama_sampler * llama_sampler_init_mirostat_v2(
1188
- uint32_t seed,
1189
- float tau,
1190
- float eta);
1191
-
1192
- /// @details Intializes a GBNF grammar, see grammars/README.md for details.
1193
- /// @param vocab The vocabulary that this grammar will be used with.
1194
- /// @param grammar_str The production rules for the grammar, encoded as a string. Returns an empty grammar if empty. Returns NULL if parsing of grammar_str fails.
1195
- /// @param grammar_root The name of the start symbol for the grammar.
1196
- LLAMA_API struct llama_sampler * llama_sampler_init_grammar(
1197
- const struct llama_vocab * vocab,
1198
- const char * grammar_str,
1199
- const char * grammar_root);
1200
-
1201
- DEPRECATED(LLAMA_API struct llama_sampler * llama_sampler_init_grammar_lazy(
1202
- const struct llama_vocab * vocab,
1203
- const char * grammar_str,
1204
- const char * grammar_root,
1205
- const char ** trigger_words,
1206
- size_t num_trigger_words,
1207
- const llama_token * trigger_tokens,
1208
- size_t num_trigger_tokens),
1209
- "use llama_sampler_init_grammar_lazy_patterns instead");
1210
-
1211
-
1212
- /// @details Lazy grammar sampler, introduced in https://github.com/ggml-org/llama.cpp/pull/9639
1213
- /// @param trigger_patterns A list of patterns that will trigger the grammar sampler. Pattern will be matched from the start of the generation output, and grammar sampler will be fed content starting from its first match group.
1214
- /// @param trigger_tokens A list of tokens that will trigger the grammar sampler. Grammar sampler will be fed content starting from the trigger token included.
1215
- LLAMA_API struct llama_sampler * llama_sampler_init_grammar_lazy_patterns(
1216
- const struct llama_vocab * vocab,
1217
- const char * grammar_str,
1218
- const char * grammar_root,
1219
- const char ** trigger_patterns,
1220
- size_t num_trigger_patterns,
1221
- const llama_token * trigger_tokens,
1222
- size_t num_trigger_tokens);
1223
-
1224
-
1225
- /// NOTE: Avoid using on the full vocabulary as searching for repeated tokens can become slow. For example, apply top-k or top-p sampling first.
1226
- LLAMA_API struct llama_sampler * llama_sampler_init_penalties(
1227
- int32_t penalty_last_n, // last n tokens to penalize (0 = disable penalty, -1 = context size)
1228
- float penalty_repeat, // 1.0 = disabled
1229
- float penalty_freq, // 0.0 = disabled
1230
- float penalty_present); // 0.0 = disabled
1231
-
1232
- /// @details DRY sampler, designed by p-e-w, as described in: https://github.com/oobabooga/text-generation-webui/pull/5677, porting Koboldcpp implementation authored by pi6am: https://github.com/LostRuins/koboldcpp/pull/982
1233
- LLAMA_API struct llama_sampler * llama_sampler_init_dry(
1234
- const struct llama_vocab * vocab,
1235
- int32_t n_ctx_train,
1236
- float dry_multiplier,
1237
- float dry_base,
1238
- int32_t dry_allowed_length,
1239
- int32_t dry_penalty_last_n,
1240
- const char ** seq_breakers,
1241
- size_t num_breakers);
1242
-
1243
- LLAMA_API struct llama_sampler * llama_sampler_init_logit_bias(
1244
- int32_t n_vocab,
1245
- int32_t n_logit_bias,
1246
- const llama_logit_bias * logit_bias);
1247
-
1248
- // this sampler is meant to be used for fill-in-the-middle infilling
1249
- // it's supposed to be used after top_k + top_p sampling
1250
- //
1251
- // 1. if the sum of the EOG probs times the number of candidates is higher than the sum of the other probs -> pick EOG
1252
- // 2. combine probs of tokens that have the same prefix
1253
- //
1254
- // example:
1255
- //
1256
- // - before:
1257
- // "hel": 0.5
1258
- // "hell": 0.2
1259
- // "hello": 0.1
1260
- // "dummy": 0.1
1261
- //
1262
- // - after:
1263
- // "hel": 0.8
1264
- // "dummy": 0.1
1265
- //
1266
- // 3. discard non-EOG tokens with low prob
1267
- // 4. if no tokens are left -> pick EOT
1268
- //
1269
- LLAMA_API struct llama_sampler * llama_sampler_init_infill(const struct llama_vocab * vocab);
1270
-
1271
- // Returns the seed used by the sampler if applicable, LLAMA_DEFAULT_SEED otherwise
1272
- LLAMA_API uint32_t llama_sampler_get_seed(const struct llama_sampler * smpl);
1273
-
1274
- /// @details Sample and accept a token from the idx-th output of the last evaluation
1275
- //
1276
- // Shorthand for:
1277
- // const auto * logits = llama_get_logits_ith(ctx, idx);
1278
- // llama_token_data_array cur_p = { ... init from logits ... };
1279
- // llama_sampler_apply(smpl, &cur_p);
1280
- // auto token = cur_p.data[cur_p.selected].id;
1281
- // llama_sampler_accept(smpl, token);
1282
- // return token;
1283
- // Returns the sampled token
1284
- LLAMA_API llama_token llama_sampler_sample(struct llama_sampler * smpl, struct llama_context * ctx, int32_t idx);
1285
-
1286
- // TODO: extend in the future
1287
- //LLAMA_API void llama_decode_with_sampler(struct llama_context * ctx, struct llama_sampler * smpl, struct llama_batch batch, ...);
1288
-
1289
- //
1290
- // Model split
1291
- //
1292
-
1293
- /// @details Build a split GGUF final path for this chunk.
1294
- /// llama_split_path(split_path, sizeof(split_path), "/models/ggml-model-q4_0", 2, 4) => split_path = "/models/ggml-model-q4_0-00002-of-00004.gguf"
1295
- // Returns the split_path length.
1296
- LLAMA_API int llama_split_path(char * split_path, size_t maxlen, const char * path_prefix, int split_no, int split_count);
1297
-
1298
- /// @details Extract the path prefix from the split_path if and only if the split_no and split_count match.
1299
- /// llama_split_prefix(split_prefix, 64, "/models/ggml-model-q4_0-00002-of-00004.gguf", 2, 4) => split_prefix = "/models/ggml-model-q4_0"
1300
- // Returns the split_prefix length.
1301
- LLAMA_API int llama_split_prefix(char * split_prefix, size_t maxlen, const char * split_path, int split_no, int split_count);
1302
-
1303
- // Print system information
1304
- LLAMA_API const char * llama_print_system_info(void);
1305
-
1306
- // Set callback for all future logging events.
1307
- // If this is not called, or NULL is supplied, everything is output on stderr.
1308
- LLAMA_API void llama_log_set(lm_ggml_log_callback log_callback, void * user_data);
1309
-
1310
- //
1311
- // Performance utils
1312
- //
1313
- // NOTE: Used by llama.cpp examples, avoid using in third-party apps. Instead, do your own performance measurements.
1314
- //
1315
-
1316
- struct llama_perf_context_data {
1317
- double t_start_ms;
1318
- double t_load_ms;
1319
- double t_p_eval_ms;
1320
- double t_eval_ms;
1321
-
1322
- int32_t n_p_eval;
1323
- int32_t n_eval;
1324
- };
1325
-
1326
- struct llama_perf_sampler_data {
1327
- double t_sample_ms;
1328
-
1329
- int32_t n_sample;
1330
- };
1331
-
1332
- LLAMA_API struct llama_perf_context_data llama_perf_context (const struct llama_context * ctx);
1333
- LLAMA_API void llama_perf_context_print(const struct llama_context * ctx);
1334
- LLAMA_API void llama_perf_context_reset( struct llama_context * ctx);
1335
-
1336
- // NOTE: the following work only with samplers constructed via llama_sampler_chain_init
1337
- LLAMA_API struct llama_perf_sampler_data llama_perf_sampler (const struct llama_sampler * chain);
1338
- LLAMA_API void llama_perf_sampler_print(const struct llama_sampler * chain);
1339
- LLAMA_API void llama_perf_sampler_reset( struct llama_sampler * chain);
1340
-
1341
- //
1342
- // training
1343
- //
1344
-
1345
- // function that returns whether or not a given tensor contains trainable parameters
1346
- typedef bool (*llama_opt_param_filter)(const struct lm_ggml_tensor * tensor, void * userdata);
1347
-
1348
- // always returns true
1349
- LLAMA_API bool llama_opt_param_filter_all(const struct lm_ggml_tensor * tensor, void * userdata);
1350
-
1351
- struct llama_opt_params {
1352
- uint32_t n_ctx_train; // assumed context size post training, use context size specified in llama_context if 0
1353
-
1354
- llama_opt_param_filter param_filter; // callback for determining which tensors contain trainable parameters
1355
- void * param_filter_ud; // userdata for determining which tensors contain trainable parameters
1356
-
1357
- lm_ggml_opt_get_optimizer_params get_opt_pars; // callback for calculating optimizer parameters
1358
- void * get_opt_pars_ud; // userdata for calculating optimizer parameters
1359
- };
1360
-
1361
- LLAMA_API void llama_opt_init(struct llama_context * lctx, struct llama_model * model, struct llama_opt_params lopt_params);
1362
-
1363
- LLAMA_API void llama_opt_epoch(
1364
- struct llama_context * lctx,
1365
- lm_ggml_opt_dataset_t dataset,
1366
- lm_ggml_opt_result_t result_train,
1367
- lm_ggml_opt_result_t result_eval,
1368
- int64_t idata_split,
1369
- lm_ggml_opt_epoch_callback callback_train,
1370
- lm_ggml_opt_epoch_callback callback_eval);
1371
-
1372
- #ifdef __cplusplus
1373
- }
1374
- #endif
1375
-
1376
- #endif // LLAMA_H