Skip to main content

This module provides functions to perform safe vector embeddings on large documents, evaluate cosine similarity and calculate token counts.

This package works with Bun, Node.js, DenoIt is unknown whether this package works with Cloudflare Workers, Browsers
JSR Score
100%
Published
2 weeks ago (0.1.3)

Safe InBed

Safe InBed is a powerful text vector embedding library that allows you to safely perform vector embedding on text that exceeds the context window size supported by traditional methods. By leveraging advanced calculations, Safe InBed ensures accurate and reliable vector embeddings for large text inputs.

Features

  • Safe and reliable vector embedding for large text inputs
  • Advanced calculations to handle text exceeding context window size

Installation

To install Safe InBed, use the appropriate command for your package manager:

Deno

deno add @zac/safe-inbed

pnpm

pnpm add @zac/safe-inbed

Bun

bun add @zac/safe-inbed

npm

npm install @zac/safe-inbed

Yarn

yarn add @zac/safe-inbed

Usage

Here's a quick example of how to use Safe InBed in your project:

 * import { calculateTokenCount } from "@zac/safe-inbed";
 * 
 * console.log("Token count:", calculateTokenCount("Hello, world!"));
 * // Output: Token count: 4

Contributing

Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request.

License

Safe InBed is licensed under the MIT License.

Examples

Example 1

import { calculateTokenCount } from "@zac/safe-inbed";

console.log("Token count:", calculateTokenCount("Hello, world!"));
// Output: Token count: 4

Add Package

deno add @zac/safe-inbed

Import symbol

import * as mod from "@zac/safe-inbed";

Add Package

npx jsr add @zac/safe-inbed

Import symbol

import * as mod from "@zac/safe-inbed";

Add Package

yarn dlx jsr add @zac/safe-inbed

Import symbol

import * as mod from "@zac/safe-inbed";

Add Package

pnpm dlx jsr add @zac/safe-inbed

Import symbol

import * as mod from "@zac/safe-inbed";

Add Package

bunx jsr add @zac/safe-inbed

Import symbol

import * as mod from "@zac/safe-inbed";