Skip to content

Quick Start Guide

Welcome! This guide will help you get started with InferEdge MOSS in just a few minutes.

1. Install the MOSS SDK

First, add the MOSS SDK to your project using npm:

bash
npm install @inferedge/moss

2. Initialize the Client

Import the client and connect using your API key:

typescript
import { MossClient } from "@inferedge/moss";

const client = new MossClient("your-api-key");

3. Create Your First Index

You can choose between two models, depending on your needs:

typescript
// For fast performance
await client.createIndex("my-docs", "moss-minilm");

// For higher accuracy
await client.createIndex("my-docs", "moss-mediumlm");

Tip:

  • moss-minilm: Fast, lightweight, great for real-time use
  • moss-mediumlm: More accurate, ideal for precision tasks

4. Add Your Content

Add documents to your index:

typescript
await client.addItems("my-docs", [
  { id: "guide-1", text: "How to set up machine learning pipelines" },
  { id: "guide-2", text: "Understanding neural network architectures" },
  { id: "guide-3", text: "Data preprocessing techniques for AI models" },
]);

5. Search Your Content

Query your index and display the results:

typescript
const results = await client.query("my-docs", "neural networks");

results.matches.forEach((match) => {
  console.log(`${match.id}: ${match.score.toFixed(3)} - ${match.text}`);
});

Key Features

  • On-Device Processing: All operations run locally—your data never leaves your device.
  • Lightweight & Fast: WebAssembly-powered for near-native speed in browsers and Node.js.
  • API Key Required: Make sure you have a valid API key from InferEdge.

Advanced Usage

Custom Index Settings

typescript
await client.createIndex(
  "custom-index",
  "moss-mediumlm",
  768,      // embedding dimensions
  "cosine", // similarity metric
  "content" // text field name
);

Search Options

typescript
const results = await client.query("my-docs", "search query", {
  topResultsCount: 10,
  measurePerformance: true,
});

if (results.metrics) {
  console.log(`Search took ${results.metrics.totalTime}ms`);
}

Index Management

typescript
if (client.hasIndex("my-docs")) {
  console.log("Index exists");
}

const indexes = client.listIndexes();
console.log("Available indexes:", indexes);

const count = client.getItemCount("my-docs");
console.log(`Index contains ${count} items`);

Next Steps


Need Help?

If you encounter issues or need assistance:

  • Check the SearchResult interface for response structure
  • Review QueryOptions for search configuration
  • Understand the Item interface for document structure