Skip to content

Commit

Permalink
docs(provider-transformers): added README.md
Browse files Browse the repository at this point in the history
Signed-off-by: Neko Ayaka <neko@ayaka.moe>
  • Loading branch information
nekomeowww committed Feb 28, 2025
1 parent 0c7160d commit f5859d0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/provider-transformers/README.md
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],
// }
```

0 comments on commit f5859d0

Please sign in to comment.