Kjarni CLI
Run transformer models from your shell. Same output as PyTorch.
kjarni is the command-line build of Kjarni, a transformer inference library:
classification, embeddings, similarity, reranking, indexing and search, chat,
summarization, translation and speech to text, as ordinary commands that read stdin
and write text or JSON. kjarni mcp serves the same tools to AI agents over MCP.
| |
Commands
Model Management
List available models
# List all models
# Filter by architecture
Download a model
Show model info
Search for models
Text Generation
Basic generation
With options
Greedy decoding (deterministic)
Creative writing
From file
GPU acceleration
Quiet mode (for piping)
|
Chat
Interactive chat
With custom model
With a model folder
Any Llama, Qwen2, Qwen 3.5, Mistral, Phi-3 or GPT-2 folder from the Hugging Face Hub, formatted
with its own chat template. kjarni generate --model-path takes the same folders.
With system prompt
Chat commands
> /help Show available commands
> /quit Exit chat
> /clear Clear conversation history
> /system Show current system prompt
> /system <text> Set new system prompt
> /history Show conversation history
Summarization
Basic summarization
From stdin
|
With options
GPU acceleration
Quiet mode for scripting
|
With a model folder
A BART or T5 folder summarizes, a Marian (Helsinki-NLP/opus-mt-*) or T5 folder
translates, and a Whisper folder transcribes. Weights may be safetensors or
pytorch_model.bin. A Marian folder translates the languages its
tokenizer_config.json names.
Text Encoding (Embeddings)
Encode text
Encode from file
Batch encoding from stdin
|
Output formats
Custom pooling and normalization
Different model
Semantic Similarity
Compare two texts
Compare files
Quiet mode (output score only)
# Output: 0.8234
Reranking
Rerank documents
From stdin (one document per line)
| \
Top-K results
Output formats
Indexing
Create an index
Index multiple paths
Custom chunking
Add to existing index
Show index info
Search
Hybrid search (default)
Keyword-only (BM25)
Semantic search
Limit results
Output formats
HTTP server
kjarni serve serves every task over HTTP: chat, completions, embeddings and
speech-to-text in OpenAI's format, reranking in Cohere's and Jina's, and
classification, translation, summarization and entity recognition in Kjarni's own.
Each request names a model with "model", or gets the endpoint's default:
--chat, --embed, --classify, --zero-shot, --rerank, --transcribe,
--translate, --summarize and --ner set them. GET /v1/models lists every
model and the endpoint it serves.
Advanced Pipelines
Semantic grep (find relevant lines)
|
RAG pipeline
# Search, rerank, then generate
| \
| \
Multi-document summarization
for; do
done |
Build embeddings for external use
|
Zero-shot classification with labels you choose
# ✓ sizing ██████████████████░░ 91.8%
# price █░░░░░░░░░░░░░░░░░░░ 6.6%
# shipping ░░░░░░░░░░░░░░░░░░░░ 1.6%
# One text per line; --multi-label judges each label on its own, and
# --hypothesis changes the sentence each label is put into
Find similar content
Batch processing
# Summarize all articles
Full RAG with chat
CONTEXT=
Global Options
| Option | Description |
|---|---|
--gpu |
Use GPU acceleration (WGPU) |
-q, --quiet |
Suppress status messages |
-m, --model |
Specify model name |
--model-path |
Use local model directory |
Environment Variables
| Variable | Description |
|---|---|
KJARNI_CACHE_DIR |
Model cache directory (default: ~/.cache/kjarni/) |
RUST_LOG |
Logging level (e.g., info, debug) |