You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/06-api-reference/classes/LLMModule.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Class: LLMModule
2
2
3
-
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:10](https://github.com/software-mansion/react-native-executorch/blob/a9d9b826d75623e7b7d41c2da95ed0c60fbb6424/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L10)
3
+
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:10](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L10)
4
4
5
5
Module for managing a Large Language Model (LLM) instance.
6
6
@@ -10,7 +10,7 @@ Module for managing a Large Language Model (LLM) instance.
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:20](https://github.com/software-mansion/react-native-executorch/blob/a9d9b826d75623e7b7d41c2da95ed0c60fbb6424/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L20)
13
+
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:20](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L20)
14
14
15
15
Creates a new instance of `LLMModule` with optional callbacks.
16
16
@@ -45,7 +45,7 @@ A new LLMModule instance.
45
45
46
46
> **configure**(`config`): `void`
47
47
48
-
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:87](https://github.com/software-mansion/react-native-executorch/blob/a9d9b826d75623e7b7d41c2da95ed0c60fbb6424/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L87)
48
+
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:87](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L87)
49
49
50
50
Configures chat and tool calling and generation settings.
51
51
See [Configuring the model](https://docs.swmansion.com/react-native-executorch/docs/hooks/natural-language-processing/useLLM#configuring-the-model) for details.
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:184](https://github.com/software-mansion/react-native-executorch/blob/a9d9b826d75623e7b7d41c2da95ed0c60fbb6424/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L184)
71
+
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:184](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L184)
72
72
73
73
Method to delete the model from memory.
74
74
Note you cannot delete model while it's generating.
@@ -84,7 +84,7 @@ You need to interrupt it first and make sure model stopped generation.
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:140](https://github.com/software-mansion/react-native-executorch/blob/a9d9b826d75623e7b7d41c2da95ed0c60fbb6424/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L140)
87
+
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:140](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L140)
88
88
89
89
Deletes all messages starting with message on `index` position.
90
90
After deletion it will call `messageHistoryCallback()` containing new history.
@@ -110,7 +110,7 @@ The index of the message to delete from history.
110
110
111
111
> **forward**(`input`): `Promise`\<`string`\>
112
112
113
-
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:104](https://github.com/software-mansion/react-native-executorch/blob/a9d9b826d75623e7b7d41c2da95ed0c60fbb6424/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L104)
113
+
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:104](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L104)
114
114
115
115
Runs model inference with raw input string.
116
116
You need to provide entire conversation and prompt (in correct format and with special tokens!) in input string to this method.
@@ -137,7 +137,7 @@ The generated response as a string.
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:115](https://github.com/software-mansion/react-native-executorch/blob/a9d9b826d75623e7b7d41c2da95ed0c60fbb6424/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L115)
140
+
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:115](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L115)
141
141
142
142
Runs model to complete chat passed in `messages` argument. It doesn't manage conversation context.
143
143
@@ -167,7 +167,7 @@ The generated response as a string.
167
167
168
168
> **getGeneratedTokenCount**(): `number`
169
169
170
-
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:157](https://github.com/software-mansion/react-native-executorch/blob/a9d9b826d75623e7b7d41c2da95ed0c60fbb6424/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L157)
170
+
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:157](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L157)
171
171
172
172
Returns the number of tokens generated in the last response.
173
173
@@ -183,7 +183,7 @@ The count of generated tokens.
183
183
184
184
> **getPromptTokensCount**(): `number`
185
185
186
-
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:166](https://github.com/software-mansion/react-native-executorch/blob/a9d9b826d75623e7b7d41c2da95ed0c60fbb6424/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L166)
186
+
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:166](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L166)
187
187
188
188
Returns the number of prompt tokens in the last message.
189
189
@@ -199,7 +199,7 @@ The count of prompt token.
199
199
200
200
> **getTotalTokensCount**(): `number`
201
201
202
-
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:175](https://github.com/software-mansion/react-native-executorch/blob/a9d9b826d75623e7b7d41c2da95ed0c60fbb6424/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L175)
202
+
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:175](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L175)
203
203
204
204
Returns the number of total tokens from the previous generation. This is a sum of prompt tokens and generated tokens.
205
205
@@ -215,7 +215,7 @@ The count of prompt and generated tokens.
215
215
216
216
> **interrupt**(): `void`
217
217
218
-
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:148](https://github.com/software-mansion/react-native-executorch/blob/a9d9b826d75623e7b7d41c2da95ed0c60fbb6424/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L148)
218
+
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:148](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L148)
219
219
220
220
Interrupts model generation. It may return one more token after interrupt.
221
221
@@ -229,7 +229,7 @@ Interrupts model generation. It may return one more token after interrupt.
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:49](https://github.com/software-mansion/react-native-executorch/blob/a9d9b826d75623e7b7d41c2da95ed0c60fbb6424/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L49)
232
+
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:49](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L49)
233
233
234
234
Loads the LLM model and tokenizer.
235
235
@@ -273,7 +273,7 @@ Optional callback to track download progress (value between 0 and 1).
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:127](https://github.com/software-mansion/react-native-executorch/blob/a9d9b826d75623e7b7d41c2da95ed0c60fbb6424/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L127)
276
+
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:127](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L127)
277
277
278
278
Method to add user message to conversation.
279
279
After model responds it will call `messageHistoryCallback()` containing both user message and model response.
@@ -299,7 +299,7 @@ The message string to send.
299
299
300
300
> **setTokenCallback**(`tokenCallback`): `void`
301
301
302
-
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:73](https://github.com/software-mansion/react-native-executorch/blob/a9d9b826d75623e7b7d41c2da95ed0c60fbb6424/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L73)
302
+
Defined in: [packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts:73](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/modules/natural_language_processing/LLMModule.ts#L73)
303
303
304
304
Sets new token callback invoked on every token batch.
Defined in: [packages/react-native-executorch/src/common/Logger.ts:5](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/common/Logger.ts#L5)
4
+
5
+
High level wrapper that prefixes `console.<command>` with [React Native ExecuTorch] tag.
6
+
7
+
## Constructors
8
+
9
+
### Constructor
10
+
11
+
> **new Logger**(): `Logger`
12
+
13
+
#### Returns
14
+
15
+
`Logger`
16
+
17
+
## Methods
18
+
19
+
### debug()
20
+
21
+
> `static`**debug**(...`data`): `void`
22
+
23
+
Defined in: [packages/react-native-executorch/src/common/Logger.ts:12](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/common/Logger.ts#L12)
24
+
25
+
#### Parameters
26
+
27
+
##### data
28
+
29
+
...`any`[]
30
+
31
+
#### Returns
32
+
33
+
`void`
34
+
35
+
---
36
+
37
+
### error()
38
+
39
+
> `static`**error**(...`data`): `void`
40
+
41
+
Defined in: [packages/react-native-executorch/src/common/Logger.ts:24](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/common/Logger.ts#L24)
42
+
43
+
#### Parameters
44
+
45
+
##### data
46
+
47
+
...`any`[]
48
+
49
+
#### Returns
50
+
51
+
`void`
52
+
53
+
---
54
+
55
+
### info()
56
+
57
+
> `static`**info**(...`data`): `void`
58
+
59
+
Defined in: [packages/react-native-executorch/src/common/Logger.ts:16](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/common/Logger.ts#L16)
60
+
61
+
#### Parameters
62
+
63
+
##### data
64
+
65
+
...`any`[]
66
+
67
+
#### Returns
68
+
69
+
`void`
70
+
71
+
---
72
+
73
+
### log()
74
+
75
+
> `static`**log**(...`data`): `void`
76
+
77
+
Defined in: [packages/react-native-executorch/src/common/Logger.ts:8](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/common/Logger.ts#L8)
78
+
79
+
#### Parameters
80
+
81
+
##### data
82
+
83
+
...`any`[]
84
+
85
+
#### Returns
86
+
87
+
`void`
88
+
89
+
---
90
+
91
+
### warn()
92
+
93
+
> `static`**warn**(...`data`): `void`
94
+
95
+
Defined in: [packages/react-native-executorch/src/common/Logger.ts:20](https://github.com/software-mansion/react-native-executorch/blob/a5440c5efceab4377accbd22e9409b019538907f/packages/react-native-executorch/src/common/Logger.ts#L20)
0 commit comments