loading experience

AI

Caveman

Last update 1.0.3 : Self-Contained & Ultralight Engine: The runtime is now completely standalone, eliminating the need for heavy external NLP models and removing the old dependency on Catalyst. The total footprint has been drastically reduced, going from ~68 MB of raw data to an assembly of just ~13 MB compiled into Brotli artifacts.

Caveman

πŸš€ Caveman v1.0.3


Caveman is an ultralight and fully self-contained .NET library designed to optimize text for Large Language Models (LLMs), drastically reducing token consumption and associated costs, while preserving the semantic integrity of the message.


✨ What's New and Key Features (v1.0.3) - June 2026

  1. Up to 70% Token Reduction: Reduce LLM channel API costs and accelerate local inference by shortening prompt lengths.
  2. Fully Self-Contained Engine: No external NLP models and no runtime dependency on Catalyst. The only package dependency (purely optional and intended for plugins) is Microsoft.SemanticKernel.
  3. Ultra-Compact Format (~13 MB): Language data is compiled into Brotli artifacts (*.yaml.br) with a compact detection index (_index.br). The assembly now weighs only ~13 MB compared to the old ~68 MB of raw data.
  4. High-Performance Custom Parser: The runtime dependency on YamlDotNet has been completely removed and replaced by a proprietary streaming word data parser.
  5. Over 50 Languages with Complete Vocabulary: Lemmas, verb forms, and a proper noun dictionary (gazetteer) derived directly from the Universal Dependencies project.
  6. Proper Noun Preservation: Proper nouns (e.g., Roma, Milano, MΓΌnchen, Termini) are recognized and kept unchanged (verbatim) instead of being erroneously compressed or transformed into common words. This feature is active at the beginning of sentences, mid-text, and even in German.
  7. Standalone Language Detection: Introduces CavemanLanguageDetector, usable in standalone mode without needing to compress text, capable of analyzing input and returning ISO 639-3 codes even for very short texts (one or two words).
  8. True Asynchronous Support: The CompressAsync and CompressBatchAsync methods no longer use fake-async mechanisms; cancellation and failed tasks are now correctly propagated at the system level.


πŸ› οΈ Installation

Due to its modular architecture, the main NLP compression library must be installed separately from other modules (such as the Privacy Guard module):

Bash


dotnet add package Caveman --version 1.0.3
πŸ“„ License & Transparency: Released under the Caveman License (MIT + mandatory attribution clause). Any commercial or private use must explicitly mention the use of Caveman developed by Passaro Francesco Paolo β€” Digitalsolutions.it.


⚑ Quick Start

C#


using Caveman;
using System;
using System.Threading;
using System.Threading.Tasks;

var compressor = new CavemanCompressionService();
string input = "I would like to know if it is possible to receive information about cheap restaurants in Rome.";

// πŸ” NEW v1.0.3: Fast standalone language detection
string languageCode = CavemanCompressionService.DetectLanguage(input); // Output: "ita"

// Compress the text (now with true Async and CancellationToken support)
var result = await compressor.CompressAsync(input, CavemanCompressionLevel.Semantic, CancellationToken.None);

Console.WriteLine($"Compressed: {result.CompressedText}");
Console.WriteLine($"Efficiency: {result.EfficiencyPercentage:F1}%");
Console.WriteLine($"🌿 Energy saved: {result.EstimatedEnergySavedMWh:F3} mWh");


🌿 Sustainability: Why it matters


Every token generated or processed by an LLM has an environmental cost. Caveman introduces an integrated estimator based on industry averages:

  1. Energy consumption: Estimated at 5 mWh per token.
  2. Carbon footprint: Estimated at 0.4 mg of COβ‚‚ per mWh.


By compressing a prompt from 1000 to 400 tokens, approximately 3 mWh of energy are saved. On the scale of millions of requests, Caveman tangibly contributes to building a sustainable AI ecosystem.


πŸ“Š NLP Compression Levels (Updated v1.0.3)


LevelApplied LogicProper Noun & Verb HandlingAverage Savings
LightRemoval of traditional stopwords.Known capitalized tokens preserved.~25–30%
SemanticKey content selection (Nouns, Verbs, Adjectives, Adverbs).Keeps proper nouns verbatim.~50%
AggressiveTotal lemmatization and verb-driven compression.Every conjugated form collapses to the base verb; nouns remain intact.~70%


πŸ” Technical Infrastructure Details (Universal Dependencies)


The old Catalyst mapping tags have been replaced by the native Universal Dependencies dictionary. During compression:

  1. The system reads an ultra-compact index (_index.br) to understand the language.
  2. It decompresses on the fly and caches only the data related to the detected language.
  3. It applies verb-driven compression and screens noisy lemmas or false positives for proper nouns.


πŸ’‘ Transformation Example

StatePrompt textTokens / Characters
Original"I would like to know if it is possible to have a margherita pizza immediately."100% (78 ch)
Light"like know possible have margherita pizza immediately"~70% (54 ch)
Semantic"know possible have margherita pizza immediately"~55% (48 ch)
Aggressive"know possible have margherita pizza" (Proper nouns like Margherita or Roma are not altered)~40% (38 ch)


πŸ’‘ Native Integration: Caveman.Wiki

Purpose

Automatically generate AI-optimized Markdown documentation for any software project, leveraging Caveman v1.0.3's new ultra-compact engine to semantically compress content and maximize the LLM prompt context window.

How it works

  1. Project analysis: Automatically detects project type (.csproj, requirements.txt, package.json).
  2. Smart scanning: Excludes binary files, build folders, and external dependency folders.
  3. Code and Text Compression: For files larger than 2KB, it invokes the new CavemanCompressionService (Semantic or Aggressive level), utilizing fast single-language cache loading.
  4. Clean Output: Returns a complete Markdown file with YAML metadata, tree view, and syntax highlighting.

Usage Example with the New Engine

C#


// Wiki Initialization (Leverages the ~13MB reduced assembly)
var wiki = new CavemanWiki();
string context = await wiki.GenerateAsync(@"C:\Users\Dev\MyAwesomeProject");
await File.WriteAllTextAsync("AI_CONTEXT.md", context);

// Direct integration into the LLM prompt
var prompt = $@"You are an expert assistant for the project described below.
<project_context>
{context}
</project_context>

Answer questions based SOLELY on this context.";

🀝 Contributing

Pull requests are welcome! For major changes to the compression architecture based on Universal Dependencies or the streaming parser, please open a discussion issue first.

Technologies
.net ai
Resources