react-native-executorch 0.7.0-nightly-b4770df-20260205 → 0.7.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 (341) hide show
  1. package/common/rnexecutorch/ErrorCodes.h +15 -30
  2. package/common/rnexecutorch/TokenizerModule.cpp +3 -2
  3. package/common/rnexecutorch/TokenizerModule.h +1 -1
  4. package/common/rnexecutorch/host_objects/ModelHostObject.h +5 -0
  5. package/common/rnexecutorch/models/llm/LLM.cpp +7 -0
  6. package/common/rnexecutorch/models/llm/LLM.h +1 -0
  7. package/lib/module/constants/llmDefaults.js +31 -0
  8. package/lib/module/constants/llmDefaults.js.map +1 -1
  9. package/lib/module/constants/modelUrls.js +220 -0
  10. package/lib/module/constants/modelUrls.js.map +1 -1
  11. package/lib/module/constants/ocr/models.js +255 -73
  12. package/lib/module/constants/ocr/models.js.map +1 -1
  13. package/lib/module/constants/ocr/symbols.js +4 -0
  14. package/lib/module/constants/ocr/symbols.js.map +1 -1
  15. package/lib/module/constants/tts/models.js +6 -2
  16. package/lib/module/constants/tts/models.js.map +1 -1
  17. package/lib/module/constants/tts/voices.js +27 -3
  18. package/lib/module/constants/tts/voices.js.map +1 -1
  19. package/lib/module/constants/versions.js +2 -2
  20. package/lib/module/controllers/LLMController.js +9 -0
  21. package/lib/module/controllers/LLMController.js.map +1 -1
  22. package/lib/module/errors/ErrorCodes.js +54 -0
  23. package/lib/module/errors/ErrorCodes.js.map +1 -1
  24. package/lib/module/errors/errorUtils.js +30 -6
  25. package/lib/module/errors/errorUtils.js.map +1 -1
  26. package/lib/module/hooks/computer_vision/useClassification.js +7 -0
  27. package/lib/module/hooks/computer_vision/useClassification.js.map +1 -1
  28. package/lib/module/hooks/computer_vision/useImageEmbeddings.js +8 -0
  29. package/lib/module/hooks/computer_vision/useImageEmbeddings.js.map +1 -1
  30. package/lib/module/hooks/computer_vision/useImageSegmentation.js +7 -0
  31. package/lib/module/hooks/computer_vision/useImageSegmentation.js.map +1 -1
  32. package/lib/module/hooks/computer_vision/useOCR.js +7 -0
  33. package/lib/module/hooks/computer_vision/useOCR.js.map +1 -1
  34. package/lib/module/hooks/computer_vision/useObjectDetection.js +7 -0
  35. package/lib/module/hooks/computer_vision/useObjectDetection.js.map +1 -1
  36. package/lib/module/hooks/computer_vision/useStyleTransfer.js +7 -0
  37. package/lib/module/hooks/computer_vision/useStyleTransfer.js.map +1 -1
  38. package/lib/module/hooks/computer_vision/useTextToImage.js +7 -0
  39. package/lib/module/hooks/computer_vision/useTextToImage.js.map +1 -1
  40. package/lib/module/hooks/computer_vision/useVerticalOCR.js +7 -0
  41. package/lib/module/hooks/computer_vision/useVerticalOCR.js.map +1 -1
  42. package/lib/module/hooks/general/useExecutorchModule.js +8 -0
  43. package/lib/module/hooks/general/useExecutorchModule.js.map +1 -1
  44. package/lib/module/hooks/natural_language_processing/useLLM.js +11 -3
  45. package/lib/module/hooks/natural_language_processing/useLLM.js.map +1 -1
  46. package/lib/module/hooks/natural_language_processing/useSpeechToText.js +8 -0
  47. package/lib/module/hooks/natural_language_processing/useSpeechToText.js.map +1 -1
  48. package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js +7 -0
  49. package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js.map +1 -1
  50. package/lib/module/hooks/natural_language_processing/useTextToSpeech.js +8 -0
  51. package/lib/module/hooks/natural_language_processing/useTextToSpeech.js.map +1 -1
  52. package/lib/module/hooks/natural_language_processing/useTokenizer.js +7 -0
  53. package/lib/module/hooks/natural_language_processing/useTokenizer.js.map +1 -1
  54. package/lib/module/hooks/natural_language_processing/useVAD.js +7 -0
  55. package/lib/module/hooks/natural_language_processing/useVAD.js.map +1 -1
  56. package/lib/module/hooks/useModule.js +12 -0
  57. package/lib/module/hooks/useModule.js.map +1 -1
  58. package/lib/module/index.js +10 -1
  59. package/lib/module/index.js.map +1 -1
  60. package/lib/module/modules/BaseModule.js +22 -0
  61. package/lib/module/modules/BaseModule.js.map +1 -1
  62. package/lib/module/modules/computer_vision/ClassificationModule.js +20 -0
  63. package/lib/module/modules/computer_vision/ClassificationModule.js.map +1 -1
  64. package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js +19 -0
  65. package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js.map +1 -1
  66. package/lib/module/modules/computer_vision/ImageSegmentationModule.js +22 -0
  67. package/lib/module/modules/computer_vision/ImageSegmentationModule.js.map +1 -1
  68. package/lib/module/modules/computer_vision/OCRModule.js +26 -0
  69. package/lib/module/modules/computer_vision/OCRModule.js.map +1 -1
  70. package/lib/module/modules/computer_vision/ObjectDetectionModule.js +22 -0
  71. package/lib/module/modules/computer_vision/ObjectDetectionModule.js.map +1 -1
  72. package/lib/module/modules/computer_vision/StyleTransferModule.js +20 -0
  73. package/lib/module/modules/computer_vision/StyleTransferModule.js.map +1 -1
  74. package/lib/module/modules/computer_vision/TextToImageModule.js +33 -0
  75. package/lib/module/modules/computer_vision/TextToImageModule.js.map +1 -1
  76. package/lib/module/modules/computer_vision/VerticalOCRModule.js +27 -0
  77. package/lib/module/modules/computer_vision/VerticalOCRModule.js.map +1 -1
  78. package/lib/module/modules/general/ExecutorchModule.js +21 -0
  79. package/lib/module/modules/general/ExecutorchModule.js.map +1 -1
  80. package/lib/module/modules/natural_language_processing/LLMModule.js +104 -0
  81. package/lib/module/modules/natural_language_processing/LLMModule.js.map +1 -1
  82. package/lib/module/modules/natural_language_processing/SpeechToTextModule.js +67 -21
  83. package/lib/module/modules/natural_language_processing/SpeechToTextModule.js.map +1 -1
  84. package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js +21 -0
  85. package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js.map +1 -1
  86. package/lib/module/modules/natural_language_processing/TextToSpeechModule.js +40 -0
  87. package/lib/module/modules/natural_language_processing/TextToSpeechModule.js.map +1 -1
  88. package/lib/module/modules/natural_language_processing/TokenizerModule.js +54 -2
  89. package/lib/module/modules/natural_language_processing/TokenizerModule.js.map +1 -1
  90. package/lib/module/modules/natural_language_processing/VADModule.js +20 -0
  91. package/lib/module/modules/natural_language_processing/VADModule.js.map +1 -1
  92. package/lib/module/types/classification.js +4 -0
  93. package/lib/module/types/classification.js.map +1 -0
  94. package/lib/module/types/common.js +96 -0
  95. package/lib/module/types/common.js.map +1 -1
  96. package/lib/module/types/executorchModule.js +4 -0
  97. package/lib/module/types/executorchModule.js.map +1 -0
  98. package/lib/module/types/imageEmbeddings.js +4 -0
  99. package/lib/module/types/imageEmbeddings.js.map +1 -0
  100. package/lib/module/types/imageSegmentation.js +22 -1
  101. package/lib/module/types/imageSegmentation.js.map +1 -1
  102. package/lib/module/types/llm.js +80 -2
  103. package/lib/module/types/llm.js.map +1 -1
  104. package/lib/module/types/objectDetection.js +42 -2
  105. package/lib/module/types/objectDetection.js.map +1 -1
  106. package/lib/module/types/styleTransfer.js +4 -0
  107. package/lib/module/types/styleTransfer.js.map +1 -0
  108. package/lib/module/types/textEmbeddings.js +4 -0
  109. package/lib/module/types/textEmbeddings.js.map +1 -0
  110. package/lib/module/types/tokenizer.js +4 -0
  111. package/lib/module/types/tokenizer.js.map +1 -0
  112. package/lib/module/types/tti.js +4 -0
  113. package/lib/module/types/tti.js.map +1 -0
  114. package/lib/module/types/vad.js +2 -0
  115. package/lib/module/utils/ResourceFetcher.js +63 -0
  116. package/lib/module/utils/ResourceFetcher.js.map +1 -1
  117. package/lib/module/utils/llm.js +24 -1
  118. package/lib/module/utils/llm.js.map +1 -1
  119. package/lib/typescript/constants/llmDefaults.d.ts +27 -0
  120. package/lib/typescript/constants/llmDefaults.d.ts.map +1 -1
  121. package/lib/typescript/constants/modelUrls.d.ts +165 -0
  122. package/lib/typescript/constants/modelUrls.d.ts.map +1 -1
  123. package/lib/typescript/constants/ocr/models.d.ts +189 -315
  124. package/lib/typescript/constants/ocr/models.d.ts.map +1 -1
  125. package/lib/typescript/constants/ocr/symbols.d.ts +3 -0
  126. package/lib/typescript/constants/ocr/symbols.d.ts.map +1 -1
  127. package/lib/typescript/constants/tts/models.d.ts +4 -0
  128. package/lib/typescript/constants/tts/models.d.ts.map +1 -1
  129. package/lib/typescript/constants/tts/voices.d.ts +24 -0
  130. package/lib/typescript/constants/tts/voices.d.ts.map +1 -1
  131. package/lib/typescript/constants/versions.d.ts +2 -2
  132. package/lib/typescript/controllers/LLMController.d.ts +2 -0
  133. package/lib/typescript/controllers/LLMController.d.ts.map +1 -1
  134. package/lib/typescript/errors/ErrorCodes.d.ts +54 -0
  135. package/lib/typescript/errors/ErrorCodes.d.ts.map +1 -1
  136. package/lib/typescript/errors/errorUtils.d.ts +9 -0
  137. package/lib/typescript/errors/errorUtils.d.ts.map +1 -1
  138. package/lib/typescript/hooks/computer_vision/useClassification.d.ts +9 -15
  139. package/lib/typescript/hooks/computer_vision/useClassification.d.ts.map +1 -1
  140. package/lib/typescript/hooks/computer_vision/useImageEmbeddings.d.ts +9 -15
  141. package/lib/typescript/hooks/computer_vision/useImageEmbeddings.d.ts.map +1 -1
  142. package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts +9 -38
  143. package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts.map +1 -1
  144. package/lib/typescript/hooks/computer_vision/useOCR.d.ts +9 -19
  145. package/lib/typescript/hooks/computer_vision/useOCR.d.ts.map +1 -1
  146. package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts +9 -15
  147. package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts.map +1 -1
  148. package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts +9 -15
  149. package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts.map +1 -1
  150. package/lib/typescript/hooks/computer_vision/useTextToImage.d.ts +9 -22
  151. package/lib/typescript/hooks/computer_vision/useTextToImage.d.ts.map +1 -1
  152. package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts +9 -20
  153. package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts.map +1 -1
  154. package/lib/typescript/hooks/general/useExecutorchModule.d.ts +9 -13
  155. package/lib/typescript/hooks/general/useExecutorchModule.d.ts.map +1 -1
  156. package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts +9 -10
  157. package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts.map +1 -1
  158. package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts +9 -19
  159. package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts.map +1 -1
  160. package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts +9 -16
  161. package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts.map +1 -1
  162. package/lib/typescript/hooks/natural_language_processing/useTextToSpeech.d.ts +9 -15
  163. package/lib/typescript/hooks/natural_language_processing/useTextToSpeech.d.ts.map +1 -1
  164. package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts +9 -18
  165. package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts.map +1 -1
  166. package/lib/typescript/hooks/natural_language_processing/useVAD.d.ts +9 -15
  167. package/lib/typescript/hooks/natural_language_processing/useVAD.d.ts.map +1 -1
  168. package/lib/typescript/hooks/useModule.d.ts +12 -0
  169. package/lib/typescript/hooks/useModule.d.ts.map +1 -1
  170. package/lib/typescript/index.d.ts +10 -1
  171. package/lib/typescript/index.d.ts.map +1 -1
  172. package/lib/typescript/modules/BaseModule.d.ts +20 -0
  173. package/lib/typescript/modules/BaseModule.d.ts.map +1 -1
  174. package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts +21 -1
  175. package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts.map +1 -1
  176. package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts +17 -0
  177. package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts.map +1 -1
  178. package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts +21 -3
  179. package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts.map +1 -1
  180. package/lib/typescript/modules/computer_vision/OCRModule.d.ts +25 -2
  181. package/lib/typescript/modules/computer_vision/OCRModule.d.ts.map +1 -1
  182. package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts +20 -0
  183. package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts.map +1 -1
  184. package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts +18 -0
  185. package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts.map +1 -1
  186. package/lib/typescript/modules/computer_vision/TextToImageModule.d.ts +29 -0
  187. package/lib/typescript/modules/computer_vision/TextToImageModule.d.ts.map +1 -1
  188. package/lib/typescript/modules/computer_vision/VerticalOCRModule.d.ts +26 -2
  189. package/lib/typescript/modules/computer_vision/VerticalOCRModule.d.ts.map +1 -1
  190. package/lib/typescript/modules/general/ExecutorchModule.d.ts +19 -0
  191. package/lib/typescript/modules/general/ExecutorchModule.d.ts.map +1 -1
  192. package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts +97 -7
  193. package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts.map +1 -1
  194. package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts +62 -4
  195. package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts.map +1 -1
  196. package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts +19 -0
  197. package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts.map +1 -1
  198. package/lib/typescript/modules/natural_language_processing/TextToSpeechModule.d.ts +37 -2
  199. package/lib/typescript/modules/natural_language_processing/TextToSpeechModule.d.ts.map +1 -1
  200. package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts +47 -2
  201. package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts.map +1 -1
  202. package/lib/typescript/modules/natural_language_processing/VADModule.d.ts +18 -0
  203. package/lib/typescript/modules/natural_language_processing/VADModule.d.ts.map +1 -1
  204. package/lib/typescript/types/classification.d.ts +50 -0
  205. package/lib/typescript/types/classification.d.ts.map +1 -0
  206. package/lib/typescript/types/common.d.ts +92 -0
  207. package/lib/typescript/types/common.d.ts.map +1 -1
  208. package/lib/typescript/types/executorchModule.d.ts +45 -0
  209. package/lib/typescript/types/executorchModule.d.ts.map +1 -0
  210. package/lib/typescript/types/imageEmbeddings.d.ts +48 -0
  211. package/lib/typescript/types/imageEmbeddings.d.ts.map +1 -0
  212. package/lib/typescript/types/imageSegmentation.d.ts +55 -0
  213. package/lib/typescript/types/imageSegmentation.d.ts.map +1 -1
  214. package/lib/typescript/types/llm.d.ts +193 -5
  215. package/lib/typescript/types/llm.d.ts.map +1 -1
  216. package/lib/typescript/types/objectDetection.d.ts +71 -2
  217. package/lib/typescript/types/objectDetection.d.ts.map +1 -1
  218. package/lib/typescript/types/ocr.d.ts +97 -2
  219. package/lib/typescript/types/ocr.d.ts.map +1 -1
  220. package/lib/typescript/types/stt.d.ts +114 -0
  221. package/lib/typescript/types/stt.d.ts.map +1 -1
  222. package/lib/typescript/types/styleTransfer.d.ts +48 -0
  223. package/lib/typescript/types/styleTransfer.d.ts.map +1 -0
  224. package/lib/typescript/types/textEmbeddings.d.ts +53 -0
  225. package/lib/typescript/types/textEmbeddings.d.ts.map +1 -0
  226. package/lib/typescript/types/tokenizer.d.ts +75 -0
  227. package/lib/typescript/types/tokenizer.d.ts.map +1 -0
  228. package/lib/typescript/types/tti.d.ts +74 -0
  229. package/lib/typescript/types/tti.d.ts.map +1 -0
  230. package/lib/typescript/types/tts.d.ts +77 -0
  231. package/lib/typescript/types/tts.d.ts.map +1 -1
  232. package/lib/typescript/types/vad.d.ts +53 -0
  233. package/lib/typescript/types/vad.d.ts.map +1 -1
  234. package/lib/typescript/utils/ResourceFetcher.d.ts +55 -0
  235. package/lib/typescript/utils/ResourceFetcher.d.ts.map +1 -1
  236. package/lib/typescript/utils/llm.d.ts +22 -0
  237. package/lib/typescript/utils/llm.d.ts.map +1 -1
  238. package/package.json +2 -1
  239. package/src/constants/llmDefaults.ts +27 -0
  240. package/src/constants/modelUrls.ts +166 -0
  241. package/src/constants/ocr/models.ts +192 -266
  242. package/src/constants/ocr/symbols.ts +3 -0
  243. package/src/constants/tts/models.ts +6 -2
  244. package/src/constants/tts/voices.ts +27 -3
  245. package/src/constants/versions.ts +2 -2
  246. package/src/controllers/LLMController.ts +15 -0
  247. package/src/errors/ErrorCodes.ts +54 -0
  248. package/src/errors/errorUtils.ts +37 -17
  249. package/src/hooks/computer_vision/useClassification.ts +15 -7
  250. package/src/hooks/computer_vision/useImageEmbeddings.ts +15 -7
  251. package/src/hooks/computer_vision/useImageSegmentation.ts +15 -7
  252. package/src/hooks/computer_vision/useOCR.ts +9 -21
  253. package/src/hooks/computer_vision/useObjectDetection.ts +15 -7
  254. package/src/hooks/computer_vision/useStyleTransfer.ts +15 -7
  255. package/src/hooks/computer_vision/useTextToImage.ts +9 -26
  256. package/src/hooks/computer_vision/useVerticalOCR.ts +9 -19
  257. package/src/hooks/general/useExecutorchModule.ts +12 -7
  258. package/src/hooks/natural_language_processing/useLLM.ts +24 -28
  259. package/src/hooks/natural_language_processing/useSpeechToText.ts +13 -5
  260. package/src/hooks/natural_language_processing/useTextEmbeddings.ts +15 -10
  261. package/src/hooks/natural_language_processing/useTextToSpeech.ts +10 -6
  262. package/src/hooks/natural_language_processing/useTokenizer.ts +10 -6
  263. package/src/hooks/natural_language_processing/useVAD.ts +9 -7
  264. package/src/hooks/useModule.ts +15 -0
  265. package/src/index.ts +10 -5
  266. package/src/modules/BaseModule.ts +20 -0
  267. package/src/modules/computer_vision/ClassificationModule.ts +19 -1
  268. package/src/modules/computer_vision/ImageEmbeddingsModule.ts +17 -0
  269. package/src/modules/computer_vision/ImageSegmentationModule.ts +21 -1
  270. package/src/modules/computer_vision/OCRModule.ts +25 -2
  271. package/src/modules/computer_vision/ObjectDetectionModule.ts +20 -0
  272. package/src/modules/computer_vision/StyleTransferModule.ts +18 -0
  273. package/src/modules/computer_vision/TextToImageModule.ts +29 -0
  274. package/src/modules/computer_vision/VerticalOCRModule.ts +26 -2
  275. package/src/modules/general/ExecutorchModule.ts +19 -0
  276. package/src/modules/natural_language_processing/LLMModule.ts +104 -18
  277. package/src/modules/natural_language_processing/SpeechToTextModule.ts +63 -39
  278. package/src/modules/natural_language_processing/TextEmbeddingsModule.ts +19 -0
  279. package/src/modules/natural_language_processing/TextToSpeechModule.ts +43 -2
  280. package/src/modules/natural_language_processing/TokenizerModule.ts +51 -3
  281. package/src/modules/natural_language_processing/VADModule.ts +18 -0
  282. package/src/types/classification.ts +51 -0
  283. package/src/types/common.ts +93 -0
  284. package/src/types/executorchModule.ts +50 -0
  285. package/src/types/imageEmbeddings.ts +51 -0
  286. package/src/types/imageSegmentation.ts +64 -1
  287. package/src/types/llm.ts +208 -11
  288. package/src/types/objectDetection.ts +79 -1
  289. package/src/types/ocr.ts +107 -2
  290. package/src/types/stt.ts +136 -1
  291. package/src/types/styleTransfer.ts +51 -0
  292. package/src/types/textEmbeddings.ts +58 -0
  293. package/src/types/tokenizer.ts +86 -0
  294. package/src/types/tti.ts +87 -0
  295. package/src/types/tts.ts +85 -2
  296. package/src/types/vad.ts +58 -0
  297. package/src/utils/ResourceFetcher.ts +55 -0
  298. package/src/utils/llm.ts +22 -1
  299. package/third-party/android/libs/executorch/arm64-v8a/libexecutorch.so +0 -0
  300. package/third-party/android/libs/executorch/x86_64/libexecutorch.so +0 -0
  301. package/third-party/include/executorch/extension/llm/tokenizers/include/pytorch/tokenizers/bpe_model.h +84 -0
  302. package/third-party/include/executorch/extension/llm/tokenizers/include/pytorch/tokenizers/bpe_tokenizer_base.h +6 -87
  303. package/third-party/include/executorch/extension/llm/tokenizers/include/pytorch/tokenizers/hf_tokenizer.h +28 -176
  304. package/third-party/include/executorch/extension/llm/tokenizers/include/pytorch/tokenizers/map_utils.h +174 -0
  305. package/third-party/include/executorch/extension/llm/tokenizers/include/pytorch/tokenizers/model.h +151 -0
  306. package/third-party/include/executorch/extension/llm/tokenizers/include/pytorch/tokenizers/normalizer.h +55 -1
  307. package/third-party/include/executorch/extension/llm/tokenizers/include/pytorch/tokenizers/padding.h +112 -0
  308. package/third-party/include/executorch/extension/llm/tokenizers/include/pytorch/tokenizers/post_processor.h +101 -42
  309. package/third-party/include/executorch/extension/llm/tokenizers/include/pytorch/tokenizers/pre_tokenizer.h +25 -9
  310. package/third-party/include/executorch/extension/llm/tokenizers/include/pytorch/tokenizers/token_decoder.h +33 -6
  311. package/third-party/include/executorch/extension/llm/tokenizers/include/pytorch/tokenizers/tokenizer.h +2 -2
  312. package/third-party/include/executorch/extension/llm/tokenizers/include/pytorch/tokenizers/truncation.h +92 -0
  313. package/third-party/include/executorch/extension/llm/tokenizers/include/pytorch/tokenizers/wordpiece_model.h +74 -0
  314. package/third-party/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/ExecutorchLib +0 -0
  315. package/third-party/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/ExecutorchLib +0 -0
  316. package/common/rnexecutorch/tests/CMakeLists.txt +0 -253
  317. package/common/rnexecutorch/tests/README.md +0 -73
  318. package/common/rnexecutorch/tests/integration/BaseModelTest.cpp +0 -207
  319. package/common/rnexecutorch/tests/integration/BaseModelTests.h +0 -120
  320. package/common/rnexecutorch/tests/integration/ClassificationTest.cpp +0 -117
  321. package/common/rnexecutorch/tests/integration/ImageEmbeddingsTest.cpp +0 -122
  322. package/common/rnexecutorch/tests/integration/ImageSegmentationTest.cpp +0 -152
  323. package/common/rnexecutorch/tests/integration/LLMTest.cpp +0 -155
  324. package/common/rnexecutorch/tests/integration/OCRTest.cpp +0 -128
  325. package/common/rnexecutorch/tests/integration/ObjectDetectionTest.cpp +0 -135
  326. package/common/rnexecutorch/tests/integration/SpeechToTextTest.cpp +0 -97
  327. package/common/rnexecutorch/tests/integration/StyleTransferTest.cpp +0 -112
  328. package/common/rnexecutorch/tests/integration/TextEmbeddingsTest.cpp +0 -164
  329. package/common/rnexecutorch/tests/integration/TextToImageTest.cpp +0 -149
  330. package/common/rnexecutorch/tests/integration/TokenizerModuleTest.cpp +0 -98
  331. package/common/rnexecutorch/tests/integration/VerticalOCRTest.cpp +0 -238
  332. package/common/rnexecutorch/tests/integration/VoiceActivityDetectionTest.cpp +0 -99
  333. package/common/rnexecutorch/tests/integration/assets/test_audio_float.raw +0 -0
  334. package/common/rnexecutorch/tests/integration/assets/we_are_software_mansion.jpg +0 -0
  335. package/common/rnexecutorch/tests/integration/libs/libfbjni.so +0 -0
  336. package/common/rnexecutorch/tests/integration/stubs/jsi_stubs.cpp +0 -45
  337. package/common/rnexecutorch/tests/integration/utils/TestUtils.h +0 -36
  338. package/common/rnexecutorch/tests/run_tests.sh +0 -333
  339. package/common/rnexecutorch/tests/unit/FileUtilsTest.cpp +0 -32
  340. package/common/rnexecutorch/tests/unit/LogTest.cpp +0 -529
  341. package/common/rnexecutorch/tests/unit/NumericalTest.cpp +0 -107
@@ -9,33 +9,27 @@ namespace rnexecutorch {
9
9
 
10
10
  enum class RnExecutorchErrorCode : int32_t {
11
11
  /**
12
- * An umbrella-error that is thrown usually when something unexpected happens,
13
- * for example a 3rd-party library error.
12
+ * An umbrella-error that is thrown usually when something unexpected happens, for example a 3rd-party library error.
14
13
  */
15
14
  UnknownError = 101,
16
15
  /**
17
- * Thrown when a user tries to run a model that is not yet downloaded or
18
- * loaded into memory.
16
+ * Thrown when a user tries to run a model that is not yet downloaded or loaded into memory.
19
17
  */
20
18
  ModuleNotLoaded = 102,
21
19
  /**
22
- * An error ocurred when saving a file. This could be, for instance a result
23
- * image from an image model.
20
+ * An error ocurred when saving a file. This could be, for instance a result image from an image model.
24
21
  */
25
22
  FileWriteFailed = 103,
26
23
  /**
27
- * Thrown when a user tries to run a model that is currently processing. It is
28
- * only allowed to run a single model prediction at a time.
24
+ * Thrown when a user tries to run a model that is currently processing. It is only allowed to run a single model prediction at a time.
29
25
  */
30
26
  ModelGenerating = 104,
31
27
  /**
32
- * Thrown when a language is passed to a multi-language model that is not
33
- * supported. For example OCR or Speech To Text.
28
+ * Thrown when a language is passed to a multi-language model that is not supported. For example OCR or Speech To Text.
34
29
  */
35
30
  LanguageNotSupported = 105,
36
31
  /**
37
- * Thrown when config parameters passed to a model are invalid. For example,
38
- * when LLM's topp is outside of range [0, 1].
32
+ * Thrown when config parameters passed to a model are invalid. For example, when LLM's topp is outside of range [0, 1].
39
33
  */
40
34
  InvalidConfig = 112,
41
35
  /**
@@ -43,8 +37,7 @@ enum class RnExecutorchErrorCode : int32_t {
43
37
  */
44
38
  InvalidModelSource = 255,
45
39
  /**
46
- * Thrown when the number of passed inputs to the model is different than the
47
- * model metadata specifies.
40
+ * Thrown when the number of passed inputs to the model is different than the model metadata specifies.
48
41
  */
49
42
  UnexpectedNumInputs = 97,
50
43
  /**
@@ -52,8 +45,7 @@ enum class RnExecutorchErrorCode : int32_t {
52
45
  */
53
46
  ThreadPoolError = 113,
54
47
  /**
55
- * Thrown when a file read operation failed. This could be invalid image url
56
- * passed to image models, or unsupported format.
48
+ * Thrown when a file read operation failed. This could be invalid image url passed to image models, or unsupported format.
57
49
  */
58
50
  FileReadFailed = 114,
59
51
  /**
@@ -61,8 +53,7 @@ enum class RnExecutorchErrorCode : int32_t {
61
53
  */
62
54
  InvalidModelOutput = 115,
63
55
  /**
64
- * Thrown when the dimensions of input tensors don't match the model's
65
- * expected dimensions.
56
+ * Thrown when the dimensions of input tensors don't match the model's expected dimensions.
66
57
  */
67
58
  WrongDimensions = 116,
68
59
  /**
@@ -71,8 +62,7 @@ enum class RnExecutorchErrorCode : int32_t {
71
62
  */
72
63
  InvalidUserInput = 117,
73
64
  /**
74
- * Thrown when the number of downloaded files is unexpected, due to download
75
- * interruptions.
65
+ * Thrown when the number of downloaded files is unexpected, due to download interruptions.
76
66
  */
77
67
  DownloadInterrupted = 118,
78
68
  /**
@@ -85,23 +75,19 @@ enum class RnExecutorchErrorCode : int32_t {
85
75
  */
86
76
  MultilingualConfiguration = 160,
87
77
  /**
88
- * Thrown when streaming transcription is attempted but audio data chunk is
89
- * missing.
78
+ * Thrown when streaming transcription is attempted but audio data chunk is missing.
90
79
  */
91
80
  MissingDataChunk = 161,
92
81
  /**
93
- * Thrown when trying to stop or insert data into a stream that hasn't been
94
- * started.
82
+ * Thrown when trying to stop or insert data into a stream that hasn't been started.
95
83
  */
96
84
  StreamingNotStarted = 162,
97
85
  /**
98
- * Thrown when trying to start a new streaming session while another is
99
- * already in progress.
86
+ * Thrown when trying to start a new streaming session while another is already in progress.
100
87
  */
101
88
  StreamingInProgress = 163,
102
89
  /**
103
- * Thrown when a resource fails to download. This could be due to invalid URL,
104
- * or for example a network problem.
90
+ * Thrown when a resource fails to download. This could be due to invalid URL, or for example a network problem.
105
91
  */
106
92
  ResourceFetcherDownloadFailed = 180,
107
93
  /**
@@ -117,8 +103,7 @@ enum class RnExecutorchErrorCode : int32_t {
117
103
  */
118
104
  ResourceFetcherAlreadyOngoing = 183,
119
105
  /**
120
- * Thrown when trying to pause, resume, or cancel a download that is not
121
- * active.
106
+ * Thrown when trying to pause, resume, or cancel a download that is not active.
122
107
  */
123
108
  ResourceFetcherNotActive = 184,
124
109
  /**
@@ -13,8 +13,7 @@ using namespace executorch::extension::constants;
13
13
 
14
14
  TokenizerModule::TokenizerModule(
15
15
  std::string source, std::shared_ptr<react::CallInvoker> callInvoker)
16
- : tokenizer(std::make_unique<tokenizers::HFTokenizer>()),
17
- memorySizeLowerBound(std::filesystem::file_size(source)) {
16
+ : tokenizer(std::make_unique<tokenizers::HFTokenizer>()) {
18
17
 
19
18
  auto status = tokenizer->load(source);
20
19
 
@@ -22,6 +21,8 @@ TokenizerModule::TokenizerModule(
22
21
  throw RnExecutorchError(RnExecutorchErrorCode::TokenizerError,
23
22
  "Unexpected issue occured while loading tokenizer");
24
23
  };
24
+ std::filesystem::path modelPath{source};
25
+ memorySizeLowerBound = std::filesystem::file_size(modelPath);
25
26
  }
26
27
 
27
28
  void TokenizerModule::ensureTokenizerLoaded(
@@ -26,7 +26,7 @@ public:
26
26
  private:
27
27
  void ensureTokenizerLoaded(const std::string &methodName) const;
28
28
  std::unique_ptr<tokenizers::HFTokenizer> tokenizer;
29
- const std::size_t memorySizeLowerBound{0};
29
+ std::size_t memorySizeLowerBound{0};
30
30
  };
31
31
 
32
32
  REGISTER_CONSTRUCTOR(TokenizerModule, std::string,
@@ -107,6 +107,11 @@ public:
107
107
  synchronousHostFunction<&Model::getGeneratedTokenCount>,
108
108
  "getGeneratedTokenCount"));
109
109
 
110
+ addFunctions(JSI_EXPORT_FUNCTION(
111
+ ModelHostObject<Model>,
112
+ synchronousHostFunction<&Model::getPromptTokenCount>,
113
+ "getPromptTokenCount"));
114
+
110
115
  addFunctions(
111
116
  JSI_EXPORT_FUNCTION(ModelHostObject<Model>,
112
117
  synchronousHostFunction<&Model::setCountInterval>,
@@ -71,6 +71,13 @@ size_t LLM::getGeneratedTokenCount() const noexcept {
71
71
  return runner->stats_.num_generated_tokens;
72
72
  }
73
73
 
74
+ size_t LLM::getPromptTokenCount() const noexcept {
75
+ if (!runner || !runner->is_loaded()) {
76
+ return 0;
77
+ }
78
+ return runner->stats_.num_prompt_tokens;
79
+ }
80
+
74
81
  size_t LLM::getMemoryLowerBound() const noexcept {
75
82
  return memorySizeLowerBound;
76
83
  }
@@ -23,6 +23,7 @@ public:
23
23
  void interrupt();
24
24
  void unload() noexcept;
25
25
  size_t getGeneratedTokenCount() const noexcept;
26
+ size_t getPromptTokenCount() const noexcept;
26
27
  size_t getMemoryLowerBound() const noexcept;
27
28
  void setCountInterval(size_t countInterval);
28
29
  void setTemperature(float temperature);
@@ -1,6 +1,19 @@
1
1
  "use strict";
2
2
 
3
+ /**
4
+ * Default system prompt used to guide the behavior of Large Language Models (LLMs).
5
+ *
6
+ * @category Utilities - LLM
7
+ */
3
8
  export const DEFAULT_SYSTEM_PROMPT = "You are a knowledgeable, efficient, and direct AI assistant. Provide concise answers, focusing on the key information needed. Offer suggestions tactfully when appropriate to improve outcomes. Engage in productive collaboration with the user. Don't return too much text.";
9
+
10
+ /**
11
+ * Generates a default structured output prompt based on the provided JSON schema.
12
+ *
13
+ * @category Utilities - LLM
14
+ * @param structuredOutputSchema - A string representing the JSON schema for the desired output format.
15
+ * @returns A prompt string instructing the model to format its output according to the given schema.
16
+ */
4
17
  export const DEFAULT_STRUCTURED_OUTPUT_PROMPT = structuredOutputSchema => `The output should be formatted as a JSON instance that conforms to the JSON schema below.
5
18
 
6
19
  As an example, for the schema {"properties": {"foo": {"title": "Foo", "description": "a list of strings", "type": "array", "items": {"type": "string"}}}, "required": ["foo"]}
@@ -9,8 +22,26 @@ the object {"foo": ["bar", "baz"]} is a well-formatted instance of the schema. T
9
22
  Here is the output schema:
10
23
  ${structuredOutputSchema}
11
24
  `;
25
+
26
+ /**
27
+ * Default message history for Large Language Models (LLMs).
28
+ *
29
+ * @category Utilities - LLM
30
+ */
12
31
  export const DEFAULT_MESSAGE_HISTORY = [];
32
+
33
+ /**
34
+ * Default context window length for Large Language Models (LLMs).
35
+ *
36
+ * @category Utilities - LLM
37
+ */
13
38
  export const DEFAULT_CONTEXT_WINDOW_LENGTH = 5;
39
+
40
+ /**
41
+ * Default chat configuration for Large Language Models (LLMs).
42
+ *
43
+ * @category Utilities - LLM
44
+ */
14
45
  export const DEFAULT_CHAT_CONFIG = {
15
46
  systemPrompt: DEFAULT_SYSTEM_PROMPT,
16
47
  initialMessageHistory: DEFAULT_MESSAGE_HISTORY,
@@ -1 +1 @@
1
- {"version":3,"names":["DEFAULT_SYSTEM_PROMPT","DEFAULT_STRUCTURED_OUTPUT_PROMPT","structuredOutputSchema","DEFAULT_MESSAGE_HISTORY","DEFAULT_CONTEXT_WINDOW_LENGTH","DEFAULT_CHAT_CONFIG","systemPrompt","initialMessageHistory","contextWindowLength"],"sourceRoot":"../../../src","sources":["constants/llmDefaults.ts"],"mappings":";;AAEA,OAAO,MAAMA,qBAAqB,GAChC,+QAA+Q;AAEjR,OAAO,MAAMC,gCAAgC,GAC3CC,sBAA8B,IAC3B;AACL;AACA;AACA;AACA;AACA;AACA,EAAEA,sBAAsB;AACxB,CAAC;AAED,OAAO,MAAMC,uBAAkC,GAAG,EAAE;AAEpD,OAAO,MAAMC,6BAA6B,GAAG,CAAC;AAE9C,OAAO,MAAMC,mBAA+B,GAAG;EAC7CC,YAAY,EAAEN,qBAAqB;EACnCO,qBAAqB,EAAEJ,uBAAuB;EAC9CK,mBAAmB,EAAEJ;AACvB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["DEFAULT_SYSTEM_PROMPT","DEFAULT_STRUCTURED_OUTPUT_PROMPT","structuredOutputSchema","DEFAULT_MESSAGE_HISTORY","DEFAULT_CONTEXT_WINDOW_LENGTH","DEFAULT_CHAT_CONFIG","systemPrompt","initialMessageHistory","contextWindowLength"],"sourceRoot":"../../../src","sources":["constants/llmDefaults.ts"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,qBAAqB,GAChC,+QAA+Q;;AAEjR;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gCAAgC,GAC3CC,sBAA8B,IAC3B;AACL;AACA;AACA;AACA;AACA;AACA,EAAEA,sBAAsB;AACxB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,uBAAkC,GAAG,EAAE;;AAEpD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,6BAA6B,GAAG,CAAC;;AAE9C;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAA+B,GAAG;EAC7CC,YAAY,EAAEN,qBAAqB;EACnCO,qBAAqB,EAAEJ,uBAAuB;EAC9CK,mBAAmB,EAAEJ;AACvB,CAAC","ignoreList":[]}