Skip to main content

Text Processing & Search

AgentOS processes, measures, searches and scores text with classes and functions a host calls directly, with no agent in the loop. The memory and retrieval layers use the same parts: HybridRetriever searches with a BM25Index, LibraryIndex fuses its legs with reciprocalRankFusion, and RetrievalAugmentor reranks with RerankerService.

ToUsePage
Split text into words, drop stop words, stemTextProcessingPipeline, createProsePipeline(), createRagPipeline(), createCodePipeline()Text Processing Pipeline
Count, compare and classify text: sentences, n-grams, keywords, readability, similarity, language, summariesStatisticalUtilityAI, LLMUtilityAI, HybridUtilityAIText Statistics and Classification
Search by keywords, save the index as JSON, search in a browserLexicalIndex, BM25IndexLexical and Hybrid Search
Search records as someone types, with typos, word beginnings and field weights, and mark the matchesFuzzyIndexLexical and Hybrid Search
Fuse keyword and vector searchHybridSearcher, reciprocalRankFusion()Lexical and Hybrid Search
Cut documents and transcripts into passages, show a hit's wordsSemanticChunker, chunkTurns(), ChunkingEngine, snippetAround()Chunking and Snippets
Reorder retrieved passagesRerankerService and its providersReranking
Search a library of sources by tenant and access groupLibraryIndexLibrary Index
Fuse BM25 with memory retrievalHybridRetrieverHybrid BM25 + Dense Retriever

Where each part runs​

PartImportRuns inCalls a model
LexicalIndex, FuzzyIndex, lexicalTokens, snippetAround, chunkTurns@framers/agentos/cognition/library/browserA browser or NodeNo
Text pipeline and presets@framers/agentos/cognition/nlpNode: it loads natural through node:moduleNo
StatisticalUtilityAIThe package root, @framers/agentos/cognition/nlp, @framers/agentos/cognition/nlp/ai_utilitiesNodeNo
LLMUtilityAIThe package root, @framers/agentos/cognition/nlp, @framers/agentos/cognition/nlp/ai_utilitiesNodeYes: a provider's key or a local model server
BM25Index, HybridSearcher, SemanticChunker@framers/agentos/cognition/ragNodeHybridSearcher calls the embedder you give it
reciprocalRankFusion@framers/agentos/cognition/memoryNodeNo
Rerankers@framers/agentos/cognition/rag/rerankingNode; its modules import no Node module of their ownThe local cross-encoder runs a model in-process; Cohere and the LLM judge call out

Examples​

Four examples in the repository's examples/ folder run with no API key:

FileWhat it shows
text-processing-pipeline.mjsThe three preset pipelines over a paragraph and a line of code; tokens with positions and stems; a pipeline built stage by stage
text-statistics.mjsStatisticalUtilityAI's measures over one text
text-search-bm25.mjsBM25Index with any, all and prefix matching, saved as JSON and restored; a stemming pipeline; LexicalIndex with snippets
text-hybrid-search.mjsHybridSearcher over an in-memory vector store, with a stand-in embedder written in the example, and each result's ranks

They import the package by its name, which resolves to the build through the package's exports map, and CI runs all four against each build. From a clone:

pnpm install && pnpm run build
node examples/text-search-bm25.mjs