DiversityExampleSelector<T>

Models & Types ยท AiDotNet.PromptEngineering.FewShot

Selects diverse examples to maximize coverage of different patterns.

Inheritance: FewShotExampleSelectorBase<T> โ†’ DiversityExampleSelector<T>

For Beginners

Picks examples that are different from each other.

Instead of picking similar examples, this ensures variety:

  • If you have 100 sentiment examples
  • Random might give 3 positive examples
  • Diversity gives 1 positive, 1 negative, 1 neutral

Example:

Use this when:

  • You want broad coverage of the example space
  • Your examples cluster into natural groups
  • Model needs to understand the full range of possibilities

How It Works

This selector picks examples that are different from each other to provide broad coverage. It uses a greedy algorithm to iteratively select examples that are most different from already-selected examples.

Constructors

Constructor Summary
DiversityExampleSelector(Func<string, Vector<T>> embeddingFunction) Initializes a new instance of the DiversityExampleSelector class.
DiversityExampleSelector(Func<string, Vector<T>> embeddingFunction, T diversityThreshold) Initializes a new instance of the DiversityExampleSelector class.
DiversityExampleSelector(IEmbeddingModel<T> embeddingModel) Initializes a new instance of the DiversityExampleSelector class.
DiversityExampleSelector(IEmbeddingModel<T> embeddingModel, T diversityThreshold) Initializes a new instance of the DiversityExampleSelector class.

Properties

Property Summary
T DiversityThreshold { get; } Gets the diversity threshold used for selection.