Skip to content

Commit 7f32adf

Browse files
authored
Merge pull request #13 from jgw96/rag
v0.3.3: RAG
2 parents c108892 + b16650f commit 7f32adf

File tree

8 files changed

+875
-52
lines changed

8 files changed

+875
-52
lines changed

README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,33 @@ the code will attempt to choose the GPU first and then the CPU otherwise.*
3030
| | model | string | "Xenova/trocr-small-printed"| |
3131
| classifyImage | image | Blob | - | NPU / GPU / CPU |
3232
| | model | string | "Xenova/resnet-50"| |
33-
34-
## Technical Details
35-
36-
The Web AI Toolkit utilizes the [transformers.js project](https://huggingface.co/docs/transformers.js/index) to run AI workloads. All AI processing is performed locally on the device, ensuring data privacy and reducing latency. AI workloads are run using the [WebNN API](https://learn.microsoft.com/en-us/windows/ai/directml/webnn-overview) when available, otherwise falling back to the WebGPU API, or even to the CPU with WebAssembly. Choosing the correct hardware to target is handled by the library.
33+
| doRAGSearch | texts | Array<string> | [] | GPU
34+
| | query | string | "" | |
3735

3836
## Usage
3937

4038
Here are examples of how to use each function:
4139

40+
### RAG (Retrieval-Augmented Generation)
41+
42+
```javascript
43+
import { doRAGSearch } from 'web-ai-toolkit';
44+
45+
window.showOpenFilePicker().then(async (file) => {
46+
const fileBlob = await file[0].getFile();
47+
const text = await fileBlob.text();
48+
49+
// text can be derived from anything
50+
// this sample is just meant to be extremely simple
51+
// for example, your text could be an array of text that you have OCR'ed
52+
// from some photos
53+
54+
const query = "My Search Query";
55+
const ragQuery = await doRAGSearch([text], query);
56+
console.log(ragQuery);
57+
});
58+
```
59+
4260
### Transcribe Audio File
4361

4462
```javascript
@@ -89,6 +107,10 @@ const text = await classifyImage(image);
89107
console.log(text);
90108
```
91109

110+
## Technical Details
111+
112+
The Web AI Toolkit utilizes the [transformers.js project](https://huggingface.co/docs/transformers.js/index) to run AI workloads. All AI processing is performed locally on the device, ensuring data privacy and reducing latency. AI workloads are run using the [WebNN API](https://learn.microsoft.com/en-us/windows/ai/directml/webnn-overview) when available, otherwise falling back to the WebGPU API, or even to the CPU with WebAssembly. Choosing the correct hardware to target is handled by the library.
113+
92114
## Contribution
93115

94116
We welcome contributions to the Web AI Toolkit. Please fork the repository and submit a pull request with your changes. For major changes, please open an issue first to discuss what you would like to change.

0 commit comments

Comments
 (0)