Caveman 1.6.0

dotnet add package Caveman --version 1.6.0
                    
NuGet\Install-Package Caveman -Version 1.6.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Caveman" Version="1.6.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Caveman" Version="1.6.0" />
                    
Directory.Packages.props
<PackageReference Include="Caveman" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Caveman --version 1.6.0
                    
#r "nuget: Caveman, 1.6.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Caveman@1.6.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Caveman&version=1.6.0
                    
Install as a Cake Addin
#tool nuget:?package=Caveman&version=1.6.0
                    
Install as a Cake Tool

Caveman

NLP prompt compressor for LLMs. It reduces the tokens of prompts, chats and tool output without a model, without a network call and without embeddings: it uses language data (function words, lemmas, proper nouns) that ships inside the package, for 50+ languages.

Version 1.6.0 targets .NET 10.

Install

dotnet add package Caveman

Quick start

using caveman.core;

var compressor = new CavemanCompressionService();
var result = await compressor.CompressAsync("I would like to know if it is possible to get pizza near Rome.",
                                              CavemanCompressionLevel.Semantic);
Console.WriteLine(result.CompressedText);

Compression levels

Level What it does
Light Removes function words
Semantic Keeps content words and lemmatizes; output is compact keyword text, not grammatical prose
Aggressive Lemmatization and generic-term pruning
Statistical TF-IDF word scoring blended with global IDF tables
Syntactic Rule-based pruning that keeps grammatical glue next to surviving words

Numbers, dates, identifiers, IP addresses, versions and similar values are kept verbatim at every level. JSON, code, SQL, XML, HTML and YAML never go through the word filters: they are routed to structure-aware compressors.

What is new in 1.6.0

  • CavemanDocumentCompressor compresses a whole markdown document in one call, for instruction files and memories that are injected into a model context.
  • CheckDestructiveCommands (default true) can be set to false to compress documents that name destructive commands only to forbid them.
  • CavemanDocumentOptions.Maximum applies the strongest settings: Aggressive level, markdown decoration stripped, JSON/XML/HTML/SQL/code blocks minified without loss, comments and blank lines removed. CavemanDocumentOptions.Safe is the prudent preset.
  • WithCodeProtection(true) keeps comparison operators, backtick spans, hyphenated ids, paths, file names and identifiers verbatim at every level.
var result = new CavemanDocumentCompressor()
    .Compress(markdown, CavemanDocumentOptions.Maximum);
string text = result.Text;

What is new in 1.5.1

Feature Summary
Keep dictionaries Per-language negations and query words (54 languages) are never removed; Italian and English ship more than 1500 each
Numbers and dates Words next to a number or a date are kept, so limits such as more than 65 or after 2022 survive
Markup tags XML/HTML-style tags are protected tokens and survive compression verbatim
Smaller package About 68 MB instead of 149 MB: very rare terms are no longer listed in the frequency tables

What was new in 1.5.0

Feature Summary
CavemanSemanticCache Answers a paraphrased query from a previous answer, in every supported language, without embeddings
Structured content in chats JSON, XML, HTML, Markdown, SQL and code are compressed (still valid) instead of stripped
Tool calls preserved Tool calls and tool results in agentic chats are never removed or altered
Strict APIs ToStrictAlternation and ToConverseMessagesJson build valid payloads for Amazon Bedrock Converse (Nova, Claude)
XML New content type, detected and compressed
More models Token counting for Gemini, Qwen, DeepSeek, Grok, GLM, Spark, Mistral, Nova, Kimi, Ernie, Cohere Command
.NET 10 The package targets net10.0

SemanticCache

var cache = new CavemanSemanticCache();
cache.Set("How do I create a new configuration file for the database?", "Use the init command.");

if (cache.TryGet("How to create database configuration file?", out var hit))
    Console.WriteLine(hit.Response);      // served from the cache

How it works: the query is normalized (language detection, lowercase, no punctuation, function words removed, lemmas) and compared with the Jaccard index of the token sets. A hit needs a similarity of at least 0.65. Numbers, file names, paths, identifiers and quoted strings are protected tokens that must be identical, so a request about Program.cs never matches a request about Startup.cs.

Option Default Meaning
SimilarityThreshold 0.65 Minimum Jaccard similarity for a hit
MaxEntries 1000 Entries kept; least recently used is evicted
Ttl none Entries expire after this time
Language auto Force a language (ISO 639-1 or 639-3)
UseLemmas true Collapse inflected forms
MinTokenLength 3 Shorter plain words are ignored

The cache is thread-safe and exposes Stats (Hits, Misses, HitRate, CharsSaved).

Compressing a chat

var textRank = new CavemanTextRank();
var result = textRank.RankAndSummarizeChatDetailed(messagesJson, new ChatSummarizeOptions
{
    ParseConversation = true,
    KeepLastTurnsVerbatim = 4,
    KeepSystemVerbatim = true,
    MaxTokens = 4000
});
string messages = result.Conversation.ToMessagesJson();
Content in a message Treatment
Prose Summarized and compressed
JSON Minified, still valid
XML Comments and indentation removed, still well-formed
HTML Comments and whitespace between tags removed
Markdown Tables and blank lines compacted
Code, SQL Comments and blank lines removed
Tool calls and results Never removed, never altered

Recognized tool formats: OpenAI-compatible (OpenAI, DeepSeek, Qwen, Grok, GLM, Spark, Mistral, Kimi), Anthropic tool_use and tool_result, Bedrock Converse toolUse and toolResult, Gemini functionCall and functionResponse, Cohere tool_results, and the text markers used by Qwen, DeepSeek, Mistral, Llama and GLM.

Strict chat APIs (Amazon Bedrock Converse, Nova)

var result = textRank.RankAndSummarizeChatDetailed(messagesJson, new ChatSummarizeOptions { ParseConversation = true });
string converse = result.Conversation.ToConverseMessagesJson(out string? system);
// pass system in the system field and converse as the messages
Provider error Fix
First message must be a user message ToStrictAlternation or ToConverseMessagesJson
Roles must alternate Same helpers: they merge consecutive turns
Text content is empty Same helpers: no empty turn is emitted
Unknown role system or tool Take the system prompt out with the out parameter

Other services

Service Purpose
CavemanContentRouter Detects the content type and picks the right compressor
CavemanTextRank Sentence ranking, summarization, chat compaction
CavemanLanguageDetector Language detection from function words, 50+ languages
CavemanContextWindow Incremental conversation compaction under a token budget
CavemanCodeCompressor, CavemanSqlCompressor, CavemanJsonCrusher Structure-aware compressors
CavemanCacheAligner Finds volatile tokens that break provider prompt caching
CavemanSimHash Near-duplicate detection
ModelTokenizer Token estimates for the main model families

Family

Package Purpose
Caveman The compressor (this package)
Caveman.SemanticKernel Semantic Kernel plugins
Caveman.Mcp MCP server for Claude Code, Cursor and similar tools
Caveman.PrivacyGuard PII detection and masking

License

MIT with mandatory attribution to Passaro Francesco Paolo, Digitalsolutions.it. See the LICENSE file in the package.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Caveman:

Package Downloads
Caveman.SemanticKernel

Semantic Kernel plugins for Caveman (NLP Prompt Compressor): prompt token optimization, conversation/agent context tools (summarize, fit-to-budget, memory, focus, token estimate), developer services and on-demand project documentation. Add-on package; references the dependency-free Caveman core. Licensed under the Caveman License (MIT + mandatory attribution to Passaro Francesco Paolo - Digitalsolutions.it).

CavemanML

The optional ML tier of the Caveman family, in pure C# (no torch, no onnxruntime, no native code): SynthelionML, a learned per-token prompt compressor (39 languages, 70% target), and PrivacyGuardML, a learned PII confirmation model for Caveman.PrivacyGuard. Models from Hugging Face (digitalsolutionsai), fully offline at inference.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.6.0 149 11/9/2026
1.5.1 79 11/8/2026
1.5.0 93 11/8/2026
1.4.6 83 11/5/2026
1.4.5 239 10/11/2026
1.4.4 280 8/13/2026
1.4.3 185 7/19/2026
1.4.2 103 7/18/2026
1.4.1 107 7/18/2026
1.4.0 135 6/24/2026
1.3.1 136 6/24/2026
1.3.0 155 6/23/2026 1.3.0 is deprecated because it has critical bugs.
1.2.1 128 6/16/2026
1.2.0 116 6/13/2026
1.1.0 109 6/12/2026
1.0.3 116 6/3/2026
1.0.2 107 5/3/2026
1.0.1 105 4/27/2026
1.0.0 118 4/27/2026

1.6.0: CavemanDocumentCompressor compresses whole markdown documents such as agent instruction files and memories injected into a model context. CavemanDocumentOptions has a CheckDestructiveCommands property (default true) that can be switched off, a Maximum preset (Aggressive NLP, markdown decoration stripped, embedded JSON/XML/HTML/SQL/code minified without loss, comments and blank lines removed) and a Safe preset. CavemanCompressionService.WithCodeProtection keeps comparison operators, backtick spans, hyphenated ids, paths, file names and identifiers verbatim at every level. 1.5.1: Words that carry the meaning of a request are never removed. Negations and query vocabulary now come from per-language data (54 languages, new embedded keep dictionaries): negations (curated for 16 languages), and query words such as interrogatives, quantifiers, comparisons, time and range words (before, after, since, until, between, dopo, dal, fino, entro, senza, at least, almeno) plus numerals, units of time, months, weekdays, aggregation and sorting words; Italian and English ship more than 1500 each. Any word next to a number or a date (two before, one after) is kept, so limits such as "more than 65 years" or "after 2022" survive. XML/HTML-style tags (for example the thinking and response tags used in prompts) are isolated as protected tokens and survive verbatim. The package is less than half the size (about 68 MB instead of 149 MB): the embedded document-frequency tables no longer carry terms that appear in fewer than 6 reference documents. 1.5.0: CavemanSemanticCache (algorithmic, multilingual, protected tokens for files/numbers/identifiers); chats compress JSON, XML, HTML, Markdown, SQL and code instead of stripping them; tool calls and tool results are never removed or altered (OpenAI-compatible, Anthropic, Bedrock Converse, Gemini, Cohere and text formats of Qwen, DeepSeek, Mistral, Llama, GLM); ToStrictAlternation / ToConverseMessagesJson for Amazon Bedrock Converse (Nova); XML content type; token counting for Gemini, Qwen, DeepSeek, Grok, GLM, Spark, Mistral, Nova, Kimi, Ernie, Command; targets .NET 10. 1.4.6: An inline JSON-object example embedded in prose (e.g. an instruction telling the model to answer with {"foo":"bar"}) is now isolated as a protected token, the same way a URL or IP address already was, so the literal braces/quotes/colons survive every compression level instead of being torn apart by the word filters. Only brace spans that contain at least one quoted string are protected (up to one level of nesting), so ordinary prose using curly braces for other reasons is unaffected. 1.4.5: Synthelion 1.2.5 fixes ported. (1) Structured values (IPs, versions, dates, URLs, e-mails, grouped decimals, percentages) survive every compression level. (2) Chinese/Japanese output is no longer longer than the input. (3) Indentation-based languages (Python, Ruby, shell) are detected as code. (4) Comment stripping is string-aware: it never cuts inside a string literal. (5) Structured-content guard: JSON, code, SQL, HTML, diffs and tables are routed to their structure-aware compressors and YAML/config is returned unchanged instead of being corrupted by the word filters. 1.4.4: Synthelion 1.2.5 feature port. (1) Numeric tokens preserved across every compression level — Semantic/Aggressive/Statistical/Syntactic previously dropped ports, amounts, percentages, versions, dates and temperatures; numbers are now always retained verbatim (never lemmatised). (2) New global-IDF provider and tables: 56 per-language {iso3}.idf.br document-frequency tables (built from Wikipedia, shipped as embedded brotli like the other worddata — same tables as Synthelion 1.2.5, ~128 MB) blended 50/50 into the Statistical level's TF-IDF scoring so word importance is grounded in real-world rarity, and used by Aggressive to additionally drop words ubiquitous in >50% of the reference corpus. Languages without a table fall back to the exact 1.4.3 local-only behavior. (3) SQL-aware compression: new CavemanSqlCompressor — SQL is auto-detected (ContentType.Sql) and routed away from the NLP path into a lossless whitespace/formatting collapse that protects keywords, string/numeric literals, quoted identifiers and comments; optional VALUES-tuple folding (lossy, CCR-hashed) mirrors CavemanJsonCrusher's row-drop. All changes additive and backward-compatible. Includes full 1.4.2/1.4.3 history below: 1.4.3 was a corrective re-publish of 1.4.2 (previously the 1.4.2 NuGet package was packed from a stale snapshot missing 1.4.0/1.4.1 features), carrying the language-quality pass ported back from Synthelion 1.2.0, negation-particle protection (eng/ita/fra/spa/deu/por/zho), the Italian "subito" ADV-homograph lemma fix, CavemanCjkSegmenter (jieba-style dictionary Chinese segmentation), mojibake repair in worddata/zho* and 10 further languages, and language-detection data contamination fixes ("john"/"ha"/"e"/"ate").