AIRust 0.2.0
A Modular Knowledge Intelligence Engine
AIRust is a Rust library for finding information, comparing text, and suggesting possible connections. Give it entries with IDs, text, and optional metadata. Your application decides how to display and store the results.
Version 0.2.0 adds optional embeddings, provider-neutral model integration, and exact semantic retrieval. The default build remains the lexical library. See the 0.2.0 change report, embedding API guide, and local-model guide.
What it does
| Operation | Result | Useful for |
|---|---|---|
search() |
Relevant entries ranked with BM25. TF-IDF is also available. | Finding notes and document passages. |
find_matches() |
Exact matches, spelling similarity, or shared words. Rust also accepts r#match(). |
Reviewing duplicates and similar content. |
relate() |
Suggested connections with the shared terms that explain them. | Helping users review possible links. |
SemanticIndex::search() |
Exact cosine ranking with an application-supplied embedding provider. | Finding related meanings, including across languages when the model supports them. |
The default search(), matching, and relate() methods compare words and characters. The optional semantic index uses model embeddings instead. Its quality depends on the provider and corpus. AIRust has no required model, cloud account, HTTP client, or LLM dependency.
A relationship suggestion is evidence of shared words. The application must decide whether that evidence supports a useful connection, hierarchy, prerequisite, or contradiction.
Try the source checkout
Use Rust 1.89 or newer for the core and provider-neutral embeddings. The optional local ONNX adapter needs Rust 1.92. From the project directory:
The example demonstrates search, text comparison, duplicates, relation suggestions, filters, and JSON round trips.
Add AIRust to an application
For the current lexical library, add this to your Cargo.toml:
[]
= { = "=0.2.0", = false }
For local source development, use the checkout path instead:
[]
= { = "../airust-master" }
A complete example:
use ;
Your application owns the IDs, storage model, and presentation. AIRust accepts the same entry format from document tools, graph applications, and agent services.
Search results contain the original entry, a relevance score, and matching terms. A query without a match returns an empty list. BM25 scores are relevance values, not probabilities. Equal scores use ascending entry IDs for a stable order.
Optional semantic search
Enable features = ["embeddings"] for validated vectors, the provider interface, and SemanticIndex. This feature adds no dependencies. Supply an EmbeddingProvider or precomputed vectors. Each model space records a complete model recipe identifier and dimension; incompatible spaces are rejected.
The example uses hand-written vectors to demonstrate the API. For real local inference, enable local-embeddings and supply the E5 model files and an ONNX Runtime shared library explicitly. Compiling the crate downloads neither model weights nor runtime binaries. See the local-model guide.
The fixed release smoke corpus contains twelve public records and sixteen German, English, French, and Spanish queries. Actual model results and their limits are recorded in the 0.2.0 change report. The embedding API guide explains updates, batches, filtering, and exact search costs.
Semantic retrieval scans all eligible vectors. There is no hybrid rank fusion, graph traversal, persistent vector index, or approximate nearest-neighbor index in this release. Those are separate roadmap stages.
Tested lexical baseline and limits
The additional 0.1.9 validation report records checks of the published crates.io package. Its complete default-feature suite passed again: 187 tests, including the README example. The earlier release checks, including all optional features, are recorded separately in the 0.1.9 change report.
| Check | Observed result |
|---|---|
| Real records | Indexed 722 exported entries from three local maps. Private text and databases are excluded from this repository. |
| Incremental changes | After 200 replacements or deletions, checked search scores, statistics, duplicate groups, fuzzy results, and relation proposals against a fresh index. |
| SQLite replay | A separate in-memory test database passed 300 steps with committed changes and rollbacks. The test caller updated the index. |
| German text | Equivalent Unicode umlauts matched exactly. The checked spelling-error example scored 0.92 character similarity. |
A synthetic scale check also measured frequent queries. Each size used short five-token records, a result limit of ten, and twelve warm samples per query on macOS ARM64 with 64 GiB memory and Rust 1.98.0:
| Entries | Rare query median (ms) | Common query median (ms) | Peak process memory (MiB) |
|---|---|---|---|
| 10,000 | 0.000604 | 2.737 | 25.62 |
| 100,000 | 0.001896 | 28.509 | 187.50 |
| 1,000,000 | 0.018708 | 313.901 | 1,914.19 |
The rare query matched about 1, 10, and 100 candidates; the common query matched every entry. These single-process results describe this workload. They do not establish application speedups, production capacity, or tail latency. The report includes raw samples and a runnable public test consumer.
Keep these limits in mind:
- Default search, matching, and relation suggestions are lexical. Optional semantic retrieval can find model-based similarities, but does not prove logical relationships. Opposing statements can share words and receive a
Relatedsuggestion. - Normalization preserves accents.
StraßeandStrasse, orFührerscheinandFuehrerschein, are not exact duplicates. Search has no stemming and can return entries matching only some query terms. - The core index is in memory. JSON loading rebuilds it. Applications own durable storage, committed-change replay, crash recovery, and permissions. AIRust does not automatically monitor SQLite.
Contextfilters search. Matching, duplicate grouping, and relation suggestions require the caller to supply an appropriately scoped index or otherwise enforce the authorized record set.- These checks do not establish semantic retrieval quality, token savings, or a completed production security audit. The real-corpus queries had no labeled relevance judgments.
DenkMaps was inspected read-only and its exported records were tested in a separate consumer. No DenkMaps or MCP integration was implemented. A direct comparison with the application's existing search, including relevance and end-to-end performance, remains future work.
Optional integrations
The default build is the library. PDF processing, HTTP, SQLite, bots, command-line programs, and embedded sample knowledge are enabled explicitly.
| Cargo feature | Enables |
|---|---|
| None | Knowledge index, BM25, TF-IDF, matching, duplicates, filters, and relation suggestions. |
embeddings |
Provider-neutral validated embeddings, atomic updates, and exact semantic retrieval. No added dependencies; Rust 1.89. |
local-embeddings |
Explicit local E5 inference using FastEmbed and a separately supplied dynamic ONNX Runtime library. Rust 1.92. |
cli |
The existing command-line programs and embedded sample knowledge. |
pdf |
PDF text extraction and chunking. |
web |
The existing dashboard, HTTP, SQLite, bots, PDF, and CLI. |
bots |
A compatibility name for the existing web and bot integration. |
embedded-knowledge |
Sample data from knowledge/train.json at build time. |
The existing MatchAgent, TfidfAgent, ContextAgent, and KnowledgeBase adapters remain available. The historical TfidfAgent name uses the shared BM25 index. The actual TF-IDF search mode is SearchAlgorithm::Tfidf.
Run the tools
Run a stored-answer query:
Convert a sample PDF into training data:
Start the optional dashboard:
The default dashboard address is http://127.0.0.1:7070. The console uses port 7071. Administration is disabled by default; network-facing operation requires a configured API token. Follow STARTUP.md and the security guide for configuration.
Project layout
| Location | Purpose |
|---|---|
src/text.rs |
Shared tokenization and Unicode normalization. |
src/matching.rs |
Character and token comparisons. |
src/search.rs |
Search modes, BM25 settings, and result types. |
src/context.rs |
Search filters for IDs and metadata. |
src/knowledge.rs |
Generic knowledge entries and the existing training collection. |
src/index.rs |
Shared storage and retrieval operations. |
src/semantic.rs, src/semantic/local.rs |
Optional semantic index, provider contract, and local E5 adapter. |
src/agent.rs, src/*_agent.rs |
Compatibility with the existing agent API. |
src/pdf_loader.rs, src/bin/, src/web/ |
Import and user-interface integrations. |
examples/ |
Runnable examples, a small runtime comparison, and a scalable index benchmark. |
tests/ |
Cross-module tests and regression cases. |
docs/ |
API contracts, architecture, migration, change reports, and follow-up validation with reproducible checks. |
knowledge/, data/pdf/ |
Sample knowledge and a PDF fixture. |
airust.db |
Existing local dashboard database, excluded from the crate package. |
backups/ |
The preserved original archive, excluded from the crate package. |
build.rs |
Copies optional sample knowledge into the build directory. |
Dockerfile, .dockerignore |
Container configuration for the dashboard. |
test.sh, .github/workflows/ci.yml |
Repeatable validation. |
The API guide describes the public contracts. The architecture guide explains how the modules work together. Source code is kept free of comments; explanations live in these documents and executable examples.
Changes and compatibility
See the 0.2.0 change report and migration guide for optional embedding features. Existing lexical APIs and default features are preserved. Cargo dependencies on 0.1.x must explicitly select 0.2.0 to use the new release.
See the 0.1.9 change report and 0.1.9 migration guide for the English-language and hardening work.
The additional validation report adds measurements and records remaining limits without changing the library version or introducing an application integration.
The roadmap separates the implemented optional embeddings from later hybrid search, graph, context assembly, provenance, persistent-index, ANN, revision, and quality work. External application integrations remain separate.
The published 0.1.8 baseline is described in the 0.1.8 change report. The original analysis records what existed in 0.1.7. CHANGELOG.md lists the versions.
Validate a change
The script checks formatting, the default library, optional integrations, documentation examples, and Clippy. Validation results for a particular version belong in its change report.
License
MIT. See LICENSE.