Business Logic
Sometimes you want to override what the model spits out for either business initiatives or some other reasons. Wyvern’s business logic is the layer to to overrule something in the model. Business logic layer allows you to further tune the results based on a deliberate set of heuristics
For example, one important business logic use case in ranking is boosting and burying product. Sometimes, there’s one particular product that you want to promote or demote from your ranking list. For instance, if a product contains NSFW (Not Safe For Work) content, wyvern offers you the ability to demote or remove the product from the result even though this product has a good ranking score returned from the model.
Another example - if your analysis shows that having more different brands showing up in the same page would increase the conversion - the diversity of brands matters. On the other hand, having products from the same brand next to each other makes conversion worse. In a case like this to improve the diversity of the product brands, you could easily implement business logic that reorder your page so that products from the same brand are not adjacent to each other.
How It Works
BusinessLogicPipeline is the representation of a sequeance chain of business logics. Within the BusinessLogicPipeline, you can chain many BusinessLogicComponent one after another. BusinessLogicPipeline steps through this series of business logic components and returns the final output
The input to the BusinessLogicPipeline is BusinessLogicRequest. The output of each business logic component is passed as an input to the next business logic component.
Build a BusinessLogicPipeline
In this example, we’re building a SearchBusinessLogicPipeline, which your marketplace might use to do the following sequentially:
- first Boost candle products
- then boost wax seal products
- finally bury products in your blocklist.
The business logic’s target entity type is Product
. ProductRankingRequest
is exactly the same request of your ML pipeline.
Now let’s look at how a BusinessLogic component AlwaysBoostWaxSealProduct
is built:
The input of this BusinessLogicComponent, AlwaysBoostWaxSealProduct
, is BusinessLogicRequest, same as the input of BusinessLogicPipeline, SearchBusinessLogicPipeline
.
Was this page helpful?