npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@unrdf/semantic-search

v26.4.3

Published

AI-powered semantic search over RDF knowledge graphs using vector embeddings

Downloads

258

Readme

@unrdf/semantic-search

AI-powered semantic search over RDF knowledge graphs using vector embeddings and transformer models.

Features

  • Vector Embeddings: Convert RDF triples to semantic vectors using transformer models
  • Natural Language Queries: Search knowledge graphs with plain English queries
  • Hybrid Search: Combine semantic search with SPARQL for precise filtering
  • Knowledge Discovery: Find similar entities and recommend related concepts
  • Fast & Efficient: Sub-second query times with intelligent caching

Installation

pnpm add @unrdf/semantic-search

Quick Start

import { createStore, dataFactory } from '@unrdf/oxigraph';
import { SemanticQueryEngine } from '@unrdf/semantic-search';

const { namedNode, literal, triple } = dataFactory;

// Create and populate RDF store
const store = createStore();
store.add(triple(
  namedNode('http://example.org/JavaScript'),
  namedNode('http://schema.org/description'),
  literal('programming language for web development')
));

// Initialize semantic search
const engine = new SemanticQueryEngine(store);
await engine.initialize();
await engine.indexStore();

// Search with natural language
const results = await engine.search('web development language', {
  limit: 5,
  threshold: 0.5,
});

results.forEach(result => {
  console.log(`${result.text} (score: ${result.score})`);
});

Architecture

Components

  1. RDFEmbedder - Converts RDF triples to vector embeddings

    • Uses Xenova/all-MiniLM-L6-v2 transformer model (384 dimensions)
    • Intelligent caching for performance
    • Batch processing support
  2. SemanticQueryEngine - Natural language queries over RDF

    • Vector similarity search
    • Hybrid semantic + SPARQL queries
    • Autocomplete suggestions
    • Similar triple discovery
  3. KnowledgeRecommender - Discover related concepts

    • Entity similarity analysis
    • Concept recommendations
    • Diversity-aware results

Model Details

  • Model: Xenova/all-MiniLM-L6-v2 (HuggingFace)
  • Type: Sentence Transformer
  • Embedding Dimension: 384
  • Inference: Browser + Node.js via @xenova/transformers
  • Performance: ~50-100ms per embedding (cached: <1ms)

Examples

Semantic Search

const results = await engine.search('machine learning framework', {
  limit: 10,
  threshold: 0.6,
});

Hybrid Search (Semantic + SPARQL)

const results = await engine.hybridSearch(
  'web development',
  '?s <http://example.org/language> "JavaScript"',
  { limit: 5, hybridWeight: 0.7 }
);

Find Similar Entities

const similar = await recommender.findSimilarEntities(
  'http://example.org/Python',
  { limit: 5, threshold: 0.7 }
);

Recommend Concepts

const recommendations = await recommender.recommendConcepts(
  'data science tools',
  { limit: 5, threshold: 0.6 }
);

Performance Benchmarks

Based on 250 triples (50 entities):

| Operation | Time | Rate | |-----------|------|------| | Single triple embedding | ~50-100ms | - | | Batch 10 triples | ~300-500ms | - | | Index 250 triples | ~15-25s | ~12-15 triples/sec | | Semantic search | <500ms | - | | Hybrid search | <1000ms | - | | Entity similarity | <1500ms | - |

Cache speedup: 10-100x for repeated queries

API Reference

RDFEmbedder

const embedder = new RDFEmbedder({
  model: 'Xenova/all-MiniLM-L6-v2',
  pooling: 'mean',
  normalize: true,
  cache: true,
});

await embedder.initialize();
const embedding = await embedder.embedTriple(triple);
const embeddings = await embedder.embedTriples(triples);
const entityEmbedding = await embedder.embedEntity(triples);

SemanticQueryEngine

const engine = new SemanticQueryEngine(store, options);

await engine.initialize();
await engine.indexStore();

const results = await engine.search(query, { limit, threshold });
const hybrid = await engine.hybridSearch(nlQuery, sparqlPattern, options);
const similar = await engine.findSimilar(triple, limit);
const suggestions = await engine.autocomplete(partialQuery, limit);

KnowledgeRecommender

const recommender = new KnowledgeRecommender(store, options);

await recommender.initialize();

const similar = await recommender.findSimilarEntities(entityUri, options);
const concepts = await recommender.recommendConcepts(query, options);

Development

# Install dependencies
pnpm install

# Run tests
pnpm test

# Run benchmarks
pnpm bench

# Run demo
pnpm demo

# Lint & format
pnpm lint
pnpm format

License

MIT

Links