Class CompressionOptions
- Namespace
- AiDotNet.PromptEngineering.Compression
- Assembly
- AiDotNet.dll
Options for controlling prompt compression behavior.
public class CompressionOptions
- Inheritance
-
CompressionOptions
- Inherited Members
Remarks
Configures how aggressive compression should be, what techniques to use, and constraints on the output.
For Beginners: Settings for how to compress your prompt.
Example:
var options = new CompressionOptions
{
TargetReduction = 0.3, // Try to reduce by 30%
PreserveVariables = true, // Don't remove {placeholders}
MinTokenCount = 50 // Don't compress below 50 tokens
};
Properties
Aggressive
Gets aggressive compression options for maximum reduction.
public static CompressionOptions Aggressive { get; }
Property Value
Conservative
Gets conservative compression options that preserve more content.
public static CompressionOptions Conservative { get; }
Property Value
Default
Gets default compression options with moderate settings.
public static CompressionOptions Default { get; }
Property Value
MaxTokens
Gets or sets the maximum number of tokens in the output.
public int? MaxTokens { get; set; }
Property Value
- int?
Remarks
If set, compression will try to get the output below this token count. Useful when you need to fit within a specific context window.
For Beginners: The maximum tokens allowed after compression. Set this if you have a hard limit to fit within.
MinTokenCount
Gets or sets the minimum number of tokens in the output.
public int MinTokenCount { get; set; }
Property Value
Remarks
A safety limit to prevent over-compression that would lose essential content.
For Beginners: Don't compress below this many tokens. Prevents the prompt from becoming too short to be useful.
ModelName
Gets or sets the model name for accurate token counting.
public string ModelName { get; set; }
Property Value
Remarks
Different models tokenize differently. Specifying the target model ensures accurate token counts for that model.
For Beginners: Which AI model you'll use this prompt with. Helps count tokens accurately for your specific model.
PreserveCodeBlocks
Gets or sets whether to preserve code blocks during compression.
public bool PreserveCodeBlocks { get; set; }
Property Value
Remarks
When true, content within code blocks (```) will not be modified. Important for prompts that include code examples.
For Beginners: Keep code examples unchanged. You don't want compression to break your code!
PreserveVariables
Gets or sets whether to preserve template variables during compression.
public bool PreserveVariables { get; set; }
Property Value
Remarks
When true, placeholders like {variable_name} will not be modified or removed.
For Beginners: Keep {placeholders} intact. You don't want compression to break your template!
TargetReduction
Gets or sets the target reduction ratio (0.0 to 1.0).
public double TargetReduction { get; set; }
Property Value
Remarks
The desired percentage of tokens to remove. A value of 0.3 means try to remove 30% of tokens. The compressor will try to achieve this target but may not always succeed.
For Beginners: How much smaller you want the prompt. - 0.2 = Try to make it 20% smaller - 0.5 = Try to make it 50% smaller Higher values = more aggressive compression