RandomExampleSelector<T>
Models & Types · AiDotNet.PromptEngineering.FewShot
Selects examples randomly from the available pool.
Inheritance: FewShotExampleSelectorBase<T> → RandomExampleSelector<T>
For Beginners
Picks random examples, like drawing names from a hat.
Example:
var selector = new RandomExampleSelector<double>();
// Add examples
selector.AddExample(new FewShotExample { Input = "Hello", Output = "Hola" });
selector.AddExample(new FewShotExample { Input = "Goodbye", Output = "Adiós" });
selector.AddExample(new FewShotExample { Input = "Thank you", Output = "Gracias" });
selector.AddExample(new FewShotExample { Input = "Please", Output = "Por favor" });
// Select 2 random examples
var examples = selector.SelectExamples("Good morning", 2);
// Might return: ["Hello" → "Hola", "Please" → "Por favor"]
// Or any other random pair
Use this when:
- All examples are roughly equally useful
- Simplicity and speed are important
- You don’t have semantic similarity infrastructure
How It Works
This selector picks examples randomly without considering relevance to the query. It’s the simplest and fastest selection strategy.
Constructors
| Constructor | Summary |
|---|---|
RandomExampleSelector(int? seed) |
Initializes a new instance of the RandomExampleSelector class. |