# Command line

> Every kjarni command with an example and its real output: classify, embed, similarity, rerank, search a folder, find photos, transcribe audio, summarize, translate, generate and chat.

Source: https://kjarni.ai/docs/cli/ (published 2026-11-04)

`kjarni` runs transformer models from your shell: classify text, search a folder by
meaning, find photos by description, transcribe audio, summarize, translate and chat.
Everything runs on your machine. Each model downloads once, the first time a command
needs it.

## Install

```bash
curl -fsSL https://kjarni.ai/install.sh | sh
```

On Windows, in PowerShell:

```powershell
irm https://kjarni.ai/install.ps1 | iex
```

The installer puts `kjarni` in `~/.local/bin` and adds that folder to your PATH, so a new
terminal finds it. Linux (x86-64 and ARM), macOS on Apple Silicon and Windows are
supported. More options are on the [install page](@/docs/install.md).

```bash
kjarni --version
kjarni --help             # every command
kjarni classify --help    # every option of one command
```

## The first run downloads the model

Every command uses a default model, and you can pick another with `-m`. The first time a
model is needed, `kjarni` downloads it and shows the progress:

```text
  Repository: sentence-transformers/all-MiniLM-L6-v2
  Size:       ~90 MB
    model.safetensors 74% (0.1 / 0.1 GB)
✓ Download complete!
```

After that it loads from `~/.cache/kjarni` and works offline. The
[models page](@/docs/models.md) lists every model by name, and `kjarni model list` shows
which ones you have.

## Classify text

Sentiment by default:

```bash
kjarni classify "I love this product"
```

```text
  Input "I love this product"

  ✓       POSITIVE  ████████████████████  100.0%
          NEGATIVE  ░░░░░░░░░░░░░░░░░░░░    0.0%
```

Pick another classifier with `-m`, such as `roberta-emotions` for 28 emotions:

```bash
kjarni classify -m roberta-emotions "I can't believe I won!"
```

```text
  ✓       surprise  ████████████████░░░░   78.3%
        excitement  █████░░░░░░░░░░░░░░░   26.4%
           neutral  █░░░░░░░░░░░░░░░░░░░    4.1%
               joy  █░░░░░░░░░░░░░░░░░░░    3.9%
       realization  ░░░░░░░░░░░░░░░░░░░░    2.5%
```

Several words without quotes are one text. To classify several texts, give one per line
on stdin:

```bash
printf 'I love this product\nThe box arrived crushed\n' | kjarni classify
```

```text
        POSITIVE  ███████████████  100.0%  "I love this product"
        NEGATIVE  ███████████████  100.0%  "The box arrived crushed"
```

`--format json` or `--format jsonl` gives output a script can read. Other classifiers:
`roberta-sentiment` (negative, neutral, positive), `bert-sentiment-multilingual` (1 to 5
stars, six languages) and `toxic-bert`. `kjarni model search sentiment` finds them by
name.

## Compare two texts

```bash
kjarni similarity "a cat sat on the mat" "a kitten rested on the rug"
```

```text
  ████████████░░░░░░░░   61.8%  moderately similar

  ↔ "a cat sat on the mat"
  ↔ "a kitten rested on the rug"
```

## Embeddings

`kjarni embed` prints the vector, normalized to unit length:

```bash
kjarni embed "hello world"
```

```text
-0.03447726 0.031023178 0.0067349467 0.026109012 -0.039362032 -0.16030246 ...
```

`--format json` prints a JSON array. The default model, `minilm-l6-v2`, gives 384
numbers, the same as sentence-transformers. Pick another with `-m`, such as
`nomic-embed-text` or the multilingual `bge-m3`.

## Rerank passages

Score candidate passages against a question with a cross-encoder. The output is score,
original position and text, best first:

```bash
kjarni rerank "how do I reset my password" \
  "Click Forgot password on the sign-in page." \
  "Our office is closed on Sundays." \
  "Passwords must be 12 characters long."
```

```text
-3.6341	0	Click Forgot password on the sign-in page.
-7.5938	2	Passwords must be 12 characters long.
-11.2764	1	Our office is closed on Sundays.
```

Higher is more relevant. With no passages on the command line, it reads one per line from
stdin. `-k 5` keeps the best five.

## Search a folder

Build an index of a folder once, then search it by meaning:

```bash
kjarni index create notes.idx notes/
```

```text
✓ Index created: notes.idx
  Documents: 3
  Dimension: 384
  Size: 9.65 KB
```

```bash
kjarni search notes.idx "the heating is losing pressure" -k 2
```

```text
  Results for "the heating is losing pressure"

    1. notes/boiler.md
       ████████████████████  100.0%
       "# Boiler service The boiler is serviced every October. Call Hamar Heati…"

    2. notes/wifi.md
       ████████████████████   98.4%
       "# Home network The router is in the hall cupboard. Guest network: Hus-G…"
```

The note never says "heating" or "losing pressure"; it matched on meaning. The bar is
relative to the best result, which is always 100%.

`--mode` chooses how results are ranked:

- `hybrid`, the default, combines meaning and keywords, which is usually best.
- `semantic` uses meaning only, and its bars show the gap better: here the Wi-Fi note
  drops to 26%.
- `keyword` uses exact words only (BM25).

Add `--rerank-model minilm-l6-v2-cross-encoder` to re-score the top results with a
cross-encoder, which is slower and more precise. `--format json` includes each result's
file path and chunk.

To keep an index current:

```bash
kjarni index add notes.idx notes/tyres.md       # add a file, or replace it if it changed
kjarni index remove notes.idx notes/tyres.md    # drop a file
kjarni index info notes.idx                     # documents, size, a sample
```

Text, Markdown, HTML, JSON, CSV and source code files are indexed; PDF and Word files are
not read yet. Long files are split into chunks of 512 characters, which `--chunk-size`
changes.

## Find photos by description

```bash
kjarni image index photos/ -o photos.json
kjarni image search photos.json "snow on a mountain" -k 2
```

```text
  Results for snow on a mountain

    1. photos/snowy_mountain.png
       ████████████████████  0.2005
    2. photos/deep_forest.png
       ███████████████░░░░░  0.1535
```

The search uses CLIP and reads the pictures themselves, not their file names. It reads
JPEG and PNG, in subfolders too, but not iPhone HEIC photos. Indexing takes about 20 ms a
photo on a desktop CPU, and every search after that reuses the index.

## Transcribe audio

```bash
kjarni transcribe kennedy.wav
```

```text
 And so my fellow Americans, ask not what your country can do for you, ask what you can do for your country.
```

WAV, MP3, FLAC and Ogg Vorbis files work, at any sample rate. The default is
`whisper-small`, and `-m whisper-large-v3` is more accurate, especially outside English.

- `--timestamps` prints each segment with its time:
  `[00:00.000 --> 00:11.000] And so my fellow Americans, ...`
- `-l is` sets the language instead of detecting it.
- `--translate` gives English text from speech in another language.

## Summarize

```bash
kjarni summarize -i "The city council voted on Tuesday to extend the harbour ferry service through the winter. Ferries will now run every two hours between October and March, instead of stopping entirely. ..."
```

```text
 Ferries will now run every two hours between October and March, instead of stopping entirely . Council said demand from commuters had doubled over the past three years . ...
```

With no `-i`, it reads stdin, so `kjarni summarize < article.txt` works. The default model
is `distilbart-cnn`; `bart-large-cnn` is larger and better. Both were trained on news
articles.

## Translate

```bash
kjarni translate --src en --dst de -i "The ferry leaves at nine."
```

```text
Die Fähre fährt um neun Uhr.
```

English to German and German to English use dedicated Opus-MT models and are reliable.
Other pairs fall back to `flan-t5-base`, which is much weaker.

## Generate text and chat

```bash
kjarni generate --gguf "Three tips for a long flight:"
```

```text
 Stay hydrated, avoid screens before landing, and get some fresh air
```

`--gguf` uses the smaller quantized download, which is also much faster: that answer took
about three seconds on a desktop CPU, loading included. The default model is `llama3.2-1b-instruct`. Others
include `qwen2.5-1.5b-instruct`, `llama3.2-3b-instruct`, `phi3.5-mini-instruct` and
`mistral-7b-instruct`.

- `-n 200` sets the most tokens to generate.
- `-t 0.2` sets the temperature, and `--greedy` makes the output repeatable.
- `--gpu` runs on the graphics card through Vulkan, DirectX 12 or Metal, so AMD, Intel
  and Apple GPUs work as well as NVIDIA.

For a conversation that remembers earlier turns:

```bash
kjarni chat --gguf -m llama3.2-1b-instruct
```

```text
Kjarni Chat: llama3.2-1b-instruct
Type '/help' for commands, '/quit' to exit.

> What is the capital of Iceland? One sentence.
Reykjavik is the capital and largest city of Iceland.
```

`-s "You are a terse assistant"` sets a system prompt.

## Use it in scripts

Results go to stdout and progress goes to stderr, so pipes and redirects get only the
output:

```bash
kjarni embed "hello world" > vector.txt
kjarni transcribe meeting.mp3 > meeting.txt
cat reviews.txt | kjarni classify --format jsonl > scores.jsonl
kjarni search notes.idx "boiler" --format json | jq -r '.[0].metadata.source'
```

`-q` turns off the progress messages entirely. A command that fails exits with a non-zero
status and says why on stderr.

## Use it from an AI agent

`kjarni mcp` gives Claude Code, Cursor and other MCP clients these tools: folder search,
photo search, transcription, classification, reranking and similarity. See
[For AI agents (MCP)](@/docs/mcp.md).

## Manage models

```bash
kjarni model list                  # every model, and which you have
kjarni model search emotion        # find one by name or description
kjarni model info minilm-l6-v2     # size, format, where it is stored
kjarni model download whisper-large-v3
kjarni model remove whisper-large-v3
```

Models are stored in `~/.cache/kjarni`. To use them on a machine with no internet, see
[offline use](@/docs/offline.md).
