Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 15 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,19 @@ import React from 'react';
import { Text } from 'react-native';

import { useRAG, MemoryVectorStore } from 'react-native-rag';
import {
ALL_MINILM_L6_V2,
ALL_MINILM_L6_V2_TOKENIZER,
LLAMA3_2_1B_QLORA,
LLAMA3_2_1B_TOKENIZER,
LLAMA3_2_TOKENIZER_CONFIG,
} from 'react-native-executorch';
import { models } from 'react-native-executorch';
import {
ExecuTorchEmbeddings,
ExecuTorchLLM,
} from '@react-native-rag/executorch';

const vectorStore = new MemoryVectorStore({
embeddings: new ExecuTorchEmbeddings({
modelSource: ALL_MINILM_L6_V2,
tokenizerSource: ALL_MINILM_L6_V2_TOKENIZER,
}),
embeddings: new ExecuTorchEmbeddings(
models.text_embedding.all_minilm_l6_v2()
),
});

const llm = new ExecuTorchLLM({
modelSource: LLAMA3_2_1B_QLORA,
tokenizerSource: LLAMA3_2_1B_TOKENIZER,
tokenizerConfigSource: LLAMA3_2_TOKENIZER_CONFIG,
});
const llm = new ExecuTorchLLM(models.llm.lfm2_5_1_2b_instruct());

const App = () => {
const rag = useRAG({ vectorStore, llm });
Expand All @@ -109,29 +98,20 @@ import {
ExecuTorchEmbeddings,
ExecuTorchLLM,
} from '@react-native-rag/executorch';
import {
ALL_MINILM_L6_V2,
ALL_MINILM_L6_V2_TOKENIZER,
LLAMA3_2_1B_QLORA,
LLAMA3_2_1B_TOKENIZER,
LLAMA3_2_TOKENIZER_CONFIG,
} from 'react-native-executorch';
import { models } from 'react-native-executorch';

const App = () => {
const [rag, setRag] = useState<RAG | null>(null);
const [response, setResponse] = useState<string | null>(null);

useEffect(() => {
const initializeRAG = async () => {
const embeddings = new ExecuTorchEmbeddings({
modelSource: ALL_MINILM_L6_V2,
tokenizerSource: ALL_MINILM_L6_V2_TOKENIZER,
});
const embeddings = new ExecuTorchEmbeddings(
models.text_embedding.all_minilm_l6_v2()
);

const llm = new ExecuTorchLLM({
modelSource: LLAMA3_2_1B_QLORA,
tokenizerSource: LLAMA3_2_1B_TOKENIZER,
tokenizerConfigSource: LLAMA3_2_TOKENIZER_CONFIG,
...models.llm.lfm2_5_1_2b_instruct(),
responseCallback: setResponse,
});

Expand Down Expand Up @@ -163,13 +143,7 @@ import {
ExecuTorchEmbeddings,
ExecuTorchLLM,
} from '@react-native-rag/executorch';
import {
ALL_MINILM_L6_V2,
ALL_MINILM_L6_V2_TOKENIZER,
LLAMA3_2_1B_QLORA,
LLAMA3_2_1B_TOKENIZER,
LLAMA3_2_TOKENIZER_CONFIG,
} from 'react-native-executorch';
import { models } from 'react-native-executorch';

const App = () => {
const [embeddings, setEmbeddings] = useState<ExecuTorchEmbeddings | null>(null);
Expand All @@ -182,16 +156,13 @@ const App = () => {
// Instantiate and load the Embeddings Model
// NOTE: Calling load on VectorStore will automatically load the embeddings model
// so loading the embeddings model separately is not necessary in this case.
const embeddings = await new ExecuTorchEmbeddings({
modelSource: ALL_MINILM_L6_V2,
tokenizerSource: ALL_MINILM_L6_V2_TOKENIZER,
}).load();
const embeddings = await new ExecuTorchEmbeddings(
models.text_embedding.all_minilm_l6_v2()
).load();

// Instantiate and load the Large Language Model
const llm = await new ExecuTorchLLM({
modelSource: LLAMA3_2_1B_QLORA,
tokenizerSource: LLAMA3_2_1B_TOKENIZER,
tokenizerConfigSource: LLAMA3_2_TOKENIZER_CONFIG,
...models.llm.lfm2_5_1_2b_instruct(),
responseCallback: setResponse,
}).load();

Expand Down
4 changes: 2 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"react": "19.2.0",
"react-dom": "19.2.0",
"react-native": "0.83.2",
"react-native-executorch": "^0.8.0",
"react-native-executorch-expo-resource-fetcher": "^0.8.0",
"react-native-executorch": "^0.9.0",
"react-native-executorch-expo-resource-fetcher": "^0.9.0",
"react-native-rag": "workspace:*",
"react-native-safe-area-context": "~5.6.2",
"react-native-svg": "15.15.3",
Expand Down
12 changes: 5 additions & 7 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { type Message, useRAG } from 'react-native-rag';
import { OPSQLiteVectorStore } from '@react-native-rag/op-sqlite';
import {
QWEN3_0_6B_QUANTIZED,
ALL_MINILM_L6_V2,
initExecutorch,
} from 'react-native-executorch';
import { initExecutorch, models } from 'react-native-executorch';
import { ExpoResourceFetcher } from 'react-native-executorch-expo-resource-fetcher';
import {
ExecuTorchEmbeddings,
Expand Down Expand Up @@ -39,13 +35,15 @@ export default function App() {
const vectorStore = useMemo(() => {
return new OPSQLiteVectorStore({
name: 'rag_example_db1',
embeddings: new ExecuTorchEmbeddings(ALL_MINILM_L6_V2),
embeddings: new ExecuTorchEmbeddings(
models.text_embedding.all_minilm_l6_v2()
),
});
}, []);

const llm = useMemo(() => {
return new ExecuTorchLLM({
...QWEN3_0_6B_QUANTIZED,
...models.llm.qwen3_0_6b(),
onDownloadProgress: setDownloadProgress,
});
}, []);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-rag",
"version": "0.8.0",
"version": "0.9.0",
"description": "Private, local RAGs. Supercharge LLMs with your own knowledge base.",
"main": "./lib/module/index.js",
"types": "./lib/typescript/src/index.d.ts",
Expand Down
21 changes: 6 additions & 15 deletions packages/executorch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,23 @@ initExecutorch({ resourceFetcher: ExpoResourceFetcher });
This class allows you to use an ExecuTorch-compatible model to generate text embeddings.

```typescript
import { ALL_MINILM_L6_V2, ALL_MINILM_L6_V2_TOKENIZER } from 'react-native-executorch';
import { models } from 'react-native-executorch';
import { ExecuTorchEmbeddings } from '@react-native-rag/executorch';

const embeddings = new ExecuTorchEmbeddings({
modelSource: ALL_MINILM_L6_V2,
tokenizerSource: ALL_MINILM_L6_V2_TOKENIZER,
});
const embeddings = new ExecuTorchEmbeddings(
models.text_embedding.all_minilm_l6_v2()
);
```

### `ExecuTorchLLM`

This class allows you to use an ExecuTorch-compatible language model for text generation.

```typescript
import {
LLAMA3_2_1B,
LLAMA3_2_TOKENIZER,
LLAMA3_2_TOKENIZER_CONFIG,
} from 'react-native-executorch';
import { models } from 'react-native-executorch';
import { ExecuTorchLLM } from '@react-native-rag/executorch';

const llm = new ExecuTorchLLM({
modelSource: LLAMA3_2_1B,
tokenizerSource: LLAMA3_2_TOKENIZER,
tokenizerConfigSource: LLAMA3_2_TOKENIZER_CONFIG,
});
const llm = new ExecuTorchLLM(models.llm.lfm2_5_1_2b_instruct());
```

### Integration with `react-native-rag`
Expand Down
8 changes: 4 additions & 4 deletions packages/executorch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-rag/executorch",
"version": "0.8.0",
"version": "0.9.0",
"main": "src/index.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand All @@ -17,11 +17,11 @@
"registry": "https://registry.npmjs.org/"
},
"peerDependencies": {
"react-native-executorch": "^0.8.0",
"react-native-rag": "^0.8.0"
"react-native-executorch": "^0.9.0",
"react-native-rag": "^0.9.0"
},
"devDependencies": {
"react-native-executorch": "^0.8.0",
"react-native-executorch": "^0.9.0",
"react-native-rag": "workspace:*"
}
}
4 changes: 2 additions & 2 deletions packages/op-sqlite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-rag/op-sqlite",
"version": "0.8.0",
"version": "0.9.0",
"main": "src/index.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand All @@ -18,7 +18,7 @@
},
"peerDependencies": {
"@op-engineering/op-sqlite": "^15.2.7",
"react-native-rag": "^0.8.0"
"react-native-rag": "^0.9.0"
},
"devDependencies": {
"@op-engineering/op-sqlite": "^15.2.7",
Expand Down
36 changes: 14 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3156,11 +3156,11 @@ __metadata:
version: 0.0.0-use.local
resolution: "@react-native-rag/executorch@workspace:packages/executorch"
dependencies:
react-native-executorch: ^0.8.0
react-native-executorch: ^0.9.0
react-native-rag: "workspace:*"
peerDependencies:
react-native-executorch: ^0.8.0
react-native-rag: ^0.8.0
react-native-executorch: ^0.9.0
react-native-rag: ^0.9.0
languageName: unknown
linkType: soft

Expand All @@ -3172,7 +3172,7 @@ __metadata:
react-native-rag: "workspace:*"
peerDependencies:
"@op-engineering/op-sqlite": ^15.2.7
react-native-rag: ^0.8.0
react-native-rag: ^0.9.0
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -11567,13 +11567,6 @@ __metadata:
languageName: node
linkType: hard

"pngjs@npm:^7.0.0":
version: 7.0.0
resolution: "pngjs@npm:7.0.0"
checksum: b19a018930d27de26229c1b3ff250b3a25d09caa22cbb0b0459987d91eb0a560a18ab5d67da45a38ed7514140f26d1db58de83c31159ec101f2bb270a3c707f1
languageName: node
linkType: hard

"possible-typed-array-names@npm:^1.0.0":
version: 1.1.0
resolution: "possible-typed-array-names@npm:1.1.0"
Expand Down Expand Up @@ -11893,32 +11886,31 @@ __metadata:
languageName: node
linkType: hard

"react-native-executorch-expo-resource-fetcher@npm:^0.8.0":
version: 0.8.0
resolution: "react-native-executorch-expo-resource-fetcher@npm:0.8.0"
"react-native-executorch-expo-resource-fetcher@npm:^0.9.0":
version: 0.9.0
resolution: "react-native-executorch-expo-resource-fetcher@npm:0.9.0"
peerDependencies:
expo: ">=54.0.0"
expo-asset: ">=12.0.0"
expo-file-system: ">=19.0.0"
react-native: "*"
react-native-executorch: "*"
checksum: 3ea4d1059e4cde913009bb4d6c5dd76fad27e5c1992538ebb5f65823ca349c11caad1d8209528b1f8ee5e4a438fd9bc923a61dd3f9d8feffd9ae6e3088da9cc7
checksum: c7e31ff0cdf6d37a6205650a63808e443a690cedbb2df1b2b45e0ad0777caa020e396f44a55662eb2b4da6bb061bd9764e6a64109e54db8a1bab34da49bafb71
languageName: node
linkType: hard

"react-native-executorch@npm:^0.8.0":
version: 0.8.0
resolution: "react-native-executorch@npm:0.8.0"
"react-native-executorch@npm:^0.9.0":
version: 0.9.0
resolution: "react-native-executorch@npm:0.9.0"
dependencies:
"@huggingface/jinja": ^0.5.0
jsonrepair: ^3.12.0
jsonschema: ^1.5.0
pngjs: ^7.0.0
zod: ^4.3.6
peerDependencies:
react: "*"
react-native: "*"
checksum: 433a287be101ee6883d571cd77c54181606a7935fc4b596207e6773e3cf1967932c6d225520defb13111f4cf50da771830fcccced3d98c5096e41549941474ae
checksum: 2a82198053da86694c6f7dc9f1b658d03fdbd1ff3e672f2979972725b82f1307f0fef910b5e4be88018adf7b43e66d48624ec6f0e0f766490d07a6923427cc8d
languageName: node
linkType: hard

Expand Down Expand Up @@ -11959,8 +11951,8 @@ __metadata:
react-dom: 19.2.0
react-native: 0.83.2
react-native-builder-bob: ^0.40.11
react-native-executorch: ^0.8.0
react-native-executorch-expo-resource-fetcher: ^0.8.0
react-native-executorch: ^0.9.0
react-native-executorch-expo-resource-fetcher: ^0.9.0
react-native-monorepo-config: ^0.1.9
react-native-rag: "workspace:*"
react-native-safe-area-context: ~5.6.2
Expand Down
Loading