Semantic Router node

Semantic router node takes in 1 string input and can route it to one of the outputs you create based on the semantic similarity of the input to the examples you provide. It has conditional output handles; that is, it will redirect the flow to only one of its outputs.

Proximity classification

This is the concept of classification of text in the embedding space based on the proximity to the centroid of each route.

When you run a pipeline with semantic router node, it embeds all examples in each route, and then clusters them together and stores the “coordinates” of the “centroid” of each cluster. The input of the pipeline is also be embedded. Then, semantic distance between the input’s embedding and the centorid embeddings is calculated. The closest centroid is selected, and the output is directed to that route.

Example

Route 1 name: “colors”; Examples: “red”, “blue”, “magenta”

Route 2 name: “cats”; Examples: “lion”, “munchkin”, “puma”

Input: “tiger” will go to route 2

Example use

The pipeline in the picture below will only keep the names of desserts for a simple recipe generator

Pipeline with three semantic routes