
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
English | çšéŤä¸ć | ćĽćŹčŞ | íęľě´ | EspaĂąol | Français | Deutsch
Hey there! Welcome to EmbedDB! This is a super cool vector-based tag system written in TypeScript. It makes similarity searching as easy as having an AI assistant helping you find stuff!
First, install the package:
npm install embeddb
Let's see it in action:
import { TagVectorSystem, Tag, IndexTag } from 'embeddb';
// Create a new system
const system = new TagVectorSystem();
// Define our tag universe
const tags: IndexTag[] = [
{ category: 'color', value: 'red' }, // Red is rad!
{ category: 'color', value: 'blue' }, // Blue is cool!
{ category: 'size', value: 'large' } // Size matters!
];
// Build the tag index (important step!)
system.buildIndex(tags);
// Add an item with its tags and confidence scores
const item = {
id: 'cool-item-1',
tags: [
{ category: 'color', value: 'red', confidence: 1.0 }, // 100% sure it's red!
{ category: 'size', value: 'large', confidence: 0.8 } // Pretty sure it's large
]
};
system.addItem(item);
// Set category weights to prioritize color matches
system.setCategoryWeight('color', 2.0); // Color matches are twice as important
// Let's find similar items
const query = {
tags: [
{ category: 'color', value: 'red', confidence: 0.9 }
]
};
// Query with pagination
const results = system.query(query.tags, { page: 1, size: 10 }); // Get first 10 results
// Export the index for later use
const exportedData = system.exportIndex();
// Import the index in another instance
const newSystem = new TagVectorSystem();
newSystem.importIndex(exportedData);
This is our superhero! It handles all the operations.
buildIndex(tags: IndexTag[]): Build your tag universe
// Define your tag world!
system.buildIndex([
{ category: 'color', value: 'red' },
{ category: 'style', value: 'modern' }
]);
addItem(item: ItemTags): Add a single item
// Add something awesome
system.addItem({
id: 'awesome-item',
tags: [
{ category: 'color', value: 'red', confidence: 1.0 }
]
});
addItemBatch(items: ItemTags[], batchSize?: number): Batch add items
// Add multiple items at once for better performance!
system.addItemBatch([item1, item2, item3], 10);
query(tags: Tag[], options?: QueryOptions): Search for similar items
// Find similar stuff
const results = system.query([
{ category: 'style', value: 'modern', confidence: 0.9 }
], { page: 1, size: 20 });
queryFirst(tags: Tag[]): Get the most similar item
// Just get the best match
const bestMatch = system.queryFirst([
{ category: 'color', value: 'red', confidence: 1.0 }
]);
getStats(): Get system statistics
// Check out the system stats
const stats = system.getStats();
console.log(`Total items: ${stats.totalItems}`);
exportIndex() & importIndex(): Export/Import index data
// Save your data for later
const data = system.exportIndex();
// ... later ...
system.importIndex(data);
setCategoryWeight(category: string, weight: number): Set category weight
// Make color matches twice as important
system.setCategoryWeight('color', 2.0);
Want to contribute? Awesome! Here are some handy commands:
# Install dependencies
npm install
# Build the project
npm run build
# Run tests (we love testing!)
npm test
# Check code style
npm run lint
# Make the code pretty
npm run format
EmbedDB uses vector magic to make similarity search possible:
Tag Indexing:
Vector Transformation:
Similarity Calculation:
Performance Optimizations:
Under the hood, EmbedDB uses several clever techniques:
Sparse Vector Implementation
Cosine Similarity
Filter-First Architecture
Category Weight Management
MIT License - Go wild, build awesome stuff!
Got questions or suggestions? We'd love to hear from you:
Let's make EmbedDB even more awesome!
If you find EmbedDB useful, give us a star! It helps others discover this project and motivates us to keep improving it!
FAQs
A vector-based tag system for efficient similarity search and retrieval
We found that embeddb demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rustâs crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.