-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(provider-transformers): added README.md
Signed-off-by: Neko Ayaka <neko@ayaka.moe>
- Loading branch information
1 parent
0c7160d
commit f5859d0
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# `@proj-airi/provider-transformers` | ||
|
||
Experimental provider implementation of [🤗 Transformers.js](https://github.com/huggingface/transformers.js) for [xsai](https://github.com/moeru-ai/xsai). | ||
|
||
This enables you possibilities to use any models supported by [🤗 Transformers.js](https://github.com/huggingface/transformers.js) the feel of [xsai](https://github.com/moeru-ai/xsai) just like you are directly request OpenAI API but **pure locally within the browser**. | ||
|
||
> This is also possible for runtime with WebGPU or Web Workers support, e.g. Node.js. | ||
> [!WARNING] | ||
> | ||
> This haven't been released yet, it is currently only used by [Airi](https://github.com/moeru-ai/airi)'s stage and memory layer, if you found this helpful, join us to discuss on [xsai #41](https://github.com/moeru-ai/xsai/issues/41). | ||
## Example usage | ||
|
||
```ts | ||
// Currently @proj-airi/provider-transformers | ||
import { createTransformers } from '@xsai-ext/provider-transformers' | ||
import EmbedWorkerURL from '@xsai-ext/provider-transformers/worker?worker&url' | ||
import { embed } from '@xsai/embed' | ||
|
||
const transformersProvider = createTransformers({ embedWorkerURL: EmbedWorkerURL }) | ||
|
||
const res = await embed({ | ||
...transformersProvider.embed('Xenova/all-MiniLM-L6-v2'), | ||
input: 'Hello, world!', | ||
}) | ||
|
||
console.log(res.embedding) | ||
// { | ||
// embedding: Array<number>[768], | ||
// } | ||
``` |