Documentation & NPM Manual

LocalResearcher Manual.

Learn how to integrate LocalResearcher's deterministic extraction protocol into your scientific applications, research pipelines, and data stacks.


Introduction

LocalResearcher is a research-grade intelligence engine designed for academic scholars, engineers, and machine learning practitioners who require zero-hallucination factual extraction from peer-reviewed PDFs. Unlike standard LLM chatbots which blindly dump entire documents into a context window, LocalResearcher operates entirely on your local machine using WebAssembly.

Zero-API Architecture

Commercial AI tools suffer from strict token caps, paid credit card dependencies, and privacy concerns when uploading proprietary research papers to remote cloud endpoints. LocalResearcher is built on three core zero-API pillars:

  • Zero Data Egress: Documents are parsed in-browser via WebAssembly PDF.js streams. Your proprietary PDFs never leave your device.
  • Zero Cloud Dependencies: Embeddings are computed with ONNX WebAssembly models (Xenova/all-MiniLM-L6-v2) directly on local hardware.
  • Cryptographic Provenance: Answers are deterministically synthesized using TextRank centrality and SQuAD extractive QA with exact page references.

Installation

Install the package from npm or clone the open-source repository:

# Install via NPM
npm install localresearcher@latest

# Or install via pnpm / bun
pnpm add localresearcher@latest

Quickstart

Initialize the deterministic engine, parse an academic preprint, and execute extractive queries with zero API keys:

import { LocalResearcher } from 'localresearcher';// Initialize local engine (no API key required)const engine = new LocalResearcher({chunkSize: 800, chunkOverlap: 150});// Ingest and vectorize paper client-sideconst paper = await engine.ingest(pdfBuffer, (progress) => {console.log(`Parsing: ${progress}%`);}); console.log(paper.title); console.log(paper.metadata);// Query the paper's vector indexconst answer = await engine.query('What is the primary architectural contribution?', paper.chunks ); console.log(answer);

Class: LocalResearcher

The primary orchestrator class exported by the library.

new LocalResearcher({
  provider?: 'local' | 'gemini' | 'openai' | 'anthropic' | 'groq',
  apiKey?: string | null,
  model?: string | null,
  chunkSize?: number, // Default: 800
  chunkOverlap?: number // Default: 150
})

engine.ingest(file, onProgress?)

Processes a raw PDF stream or file into deterministic AST tokens, groups them into sliding-window text chunks, generates ONNX dense vector embeddings, and infills structured metadata and summaries.

  • file: File | Buffer | Blob | ArrayBuffer
  • onProgress (optional): (progress: number) => void callback reporting 0 to 100%.
  • Returns: Promise<PaperObject> containing id, title, authors, year, pageCount, metadata, summary, and chunks.

engine.query(question, targetChunks, history?)

Executes hybrid search (70% Cosine Similarity + 30% TF-IDF keyword match), extracts relevant candidate sentences via DistilBERT SQuAD, and returns a cited response.

Standalone Utilities

You can import individual sub-modules directly from the package without instantiating the full orchestrator:

import {parsePdfFile, chunkPageText, retrieveChunks, generateEmbedding, generateLocalSummary, extractNumericalResults} from 'localresearcher';// 1. Parse raw PDFconst pdfData = await parsePdfFile(fileBuffer);// 2. Chunk textconst chunks = chunkPageText(pdfData.pages[0].text, 1, 'doc-1', 800, 150);// 3. Generate dense vectorsconst vector = await generateEmbedding('Attention mechanism');// 4. Extract numerical SOTA metricsconst metrics = extractNumericalResults(chunks);

Open Academic Scrapers

Query millions of open-access papers across arXiv, PubMed, Semantic Scholar, and CrossRef without registering for API credentials:

import { scrapeArxiv, scrapePubmed } from 'localresearcher';// Stream results directly from arXivawait scrapeArxiv({ title: 'state space models', tags: ['cs.LG'], timeline: '2024' },25, (batch) => console.log('Received batch:', batch.length) );

Multi-Paper Multitasking

Research rarely involves reading one paper in isolation. LocalResearcher includes first-class multitasking capabilities:

  • Batch Summarization: Select multiple documents in your library and trigger simultaneous local RAG extraction with zero UI freezing.
  • Comparative Matrix: Review problems, methodologies, benchmarks, and datasets side-by-side in synchronized columns.
  • Cross-Paper Q&A: Scope terminal chat to @selected or @all to synthesize comparative insights across papers.
  • Batch BibTeX Export: Aggregate clean citation keys for all selected documents in one click.

Explore the System Architecture

Learn about the 3-layer deterministic retrieval model, AST parser, and WebAssembly compilation pipeline.

Architecture Guide →