From the course: Prompt Engineering with LangChain

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

N-gram overlap example selector

N-gram overlap example selector

- [Instructor] The n-gramOverlapExampleSelector selects and orders examples based on which examples are most similar to the input according to an n-gram overlap score. But what is an n-gram? So consider the following sentence, "Sunsets are always beautiful." From this sentence, you can construct a unigram, bigram, and a fourgram. Unigram would just be a sequence of individual words, so this sentence actually has four unigrams. Bigrams would be pairs of words, so this sentence has three bigrams, sunsets are, are always, and always beautiful, so on and so forth. And the N for n-gram just indicates that you can have as many in a sequence as you'd like. So that value of N is entirely up to you. But here I've represented n-grams of bigrams, trigrams, and four grams. The n-gram overlap score relies on the sentence blue score for overlap calculation. And this overlap score is actually a floating point number between zero and one. And it is going to select and order examples based on their…

Contents