kjarni

Local AI inference for C# and the command line

Classification, embeddings, semantic search, and reranking. One native library. No Python. No CUDA. No containers. Reads from stdin, writes JSON, pipes like any UNIX tool.

kjarni CLI demo
dotnet add package Kjarni
cargo install kjarni-cli
Zero dependencies
Models auto-download
Works offline
Reads from stdin
Written in Rust

What It Does

Four capabilities. Same API in C# and on the command line.

Classification

Sentiment, emotion, toxicity detection. Pass text in, get labels with confidence scores.

DistilBERT · RoBERTa · BERT Multilingual · Toxic-BERT

Embeddings

Dense vector representations for semantic similarity, clustering, and retrieval.

MiniLM-L6 · MPNet · DistilBERT

Semantic Search

Index files from a directory. Keyword, semantic, and hybrid retrieval built in.

HNSW · BM25 · Hybrid

Reranking

Cross-encoder scoring to reorder search results and improve retrieval quality.

MiniLM Cross-Encoder

Why Kjarni?

You shouldn't need a PhD to classify an email.

Self-Contained

One install, nothing else. No Python runtime, no CUDA toolkit, no Docker containers, no API keys. Models download on first use and cache locally.

  • dotnet add package Kjarni
  • cargo install kjarni-cli
  • Works offline after first run

Task-Level API

You get Classifier, not BertForSequenceClassification. Kjarni hides tokenizers, attention masks, and pooling strategies.

  • Classifier, Embedder, Searcher, Reranker
  • 6 classifiers, 3 embedders, cross-encoder
  • Pick a model name, call a method

UNIX-Native

The CLI reads from stdin, writes to stdout, and outputs JSON. Pipe it to jq, grep, or into your scripts. It's a tool, not a framework.

  • cat reviews.txt | kjarni classify
  • kjarni classify --format json | jq
  • SIMD-optimized (AVX2, NEON)

Three Lines of Code

Same capabilities in C# or the terminal.

C# Sentiment Analysis
using Kjarni;

var clf = new Classifier("roberta-sentiment");
var result = clf.Classify("Best purchase I've ever made!");

Console.WriteLine($"{result.Label}: {result.Score:P}");
// positive: 99.98%
CLI Sentiment Analysis
# Classify from argument
$ kjarni classify "Best purchase I've ever made!"
positive   99.98%  ██████████████████████████████████████

# Pipe from stdin
$ echo "Terrible quality" | kjarni classify
negative   99.69%  █████████████████████████████████████

# JSON output for scripting
$ echo "Great product" | kjarni classify --format json | jq '.label'
"positive"
C# Toxicity Detection
var clf = new Classifier("toxic-bert");
var result = clf.Classify(userMessage);

if (result.Label == "toxic" && result.Score > 0.8f)
{
    // flag for moderation
}
// Multi-label: toxic, insult, obscene, threat, ...
CLI Toxicity Detection
$ kjarni classify "you are an idiot" --model toxic-bert
toxic       98.61%  ███████████████████████████████████████
insult      96.00%  ██████████████████████████████████████
obscene     75.64%  ██████████████████████████████████████
severe       4.56%  █
identity     1.41%
threat       0.13%
C# Embeddings & Similarity
var emb = new Embedder("minilm-l6-v2");

float sim = emb.Similarity("doctor", "physician");
Console.WriteLine($"Similarity: {sim:F4}");
// Similarity: 0.8598
CLI Embeddings & Similarity
# Semantic similarity
$ kjarni similarity "doctor" "physician"
0.8598

$ kjarni similarity "doctor" "banana"
0.3379

# Generate embedding vector
$ kjarni embed "hello world" --format json | jq '.dimensions'
384
C# Document Search
var indexer = new Indexer("minilm-l6-v2");
indexer.Create("./my-index", new[] { "./docs" });

var searcher = new Searcher("minilm-l6-v2");
var results = searcher.Search("./my-index", "query");

foreach (var r in results)
    Console.WriteLine($"{r.Score:F3}: {r.Text}");
CLI Index & Search
# Index a folder of documents
$ kjarni index create my-docs --inputs ./docs/
✓ Indexed 51 documents (186 KB)

# Search with hybrid retrieval
$ kjarni search my-docs "password reset"
0.0325  account.txt   To reset your password, click...
0.0159  faq.txt       How do I change my login cred...

Run Anywhere

Native binaries for every major platform

Linux

x64

Windows

x64