### **1. Model config:**
```
{
"id" : 123,
"key" : "/model/retail/b2b/store_x_sku/demand_forecasting_weekwise"
"name" : "demand forecasting",
"version" : 1,
"record_key" : "store_x_sku",
"input" : {
"knowledge" : "...",
"features" : "...",
"inferences" : "..."
},
"output" : "/inference/retail/demand"
}
"knowledge" : {
"entity_type" : "/entity/retail/sku",
"attributes" : {
"value" : ["mrp" ,"brand"],
"qualifier_condition" : {
"mrp" { "active_date" > "01-01-2023"}
}
}
}
"features" :[
{
"record_key" : "store_x_sku",
"value" : [/feature/store_x_sku/mrp_average/weekly, /feature/store_x_sku/salesprice_average/weekly] ,
"condition" : {..}
},
{
"record_key" : "store",
"value" : [/feature/store/traffic/weekly, /feature/store/revenue/monthly]
},
{
"record_key" : "category",
"value" : [/feature/category/revenue/monthly]
}
"inferences" :[
{
"record_key" : "store_x_sku",
"value" : [/inference/store_x_sku/demand/weekly]
}
```
### 2. Model Inferencing
2.1. **Real Time Inferencing** -> For any change in store_x_sku related input features , model will be invoked for that key.
2.2. **Batch Inferencing** -> For all store and sku, do inferencing in batches.
For batch input **FetchRequest** will look like below:
```
"row" : {
"condition" : {
"/entity/retail/store" : {
"conditional" : {
"feature_condition" : {
"/feature/retail/store/total_sales" > 10000
},
"attribute_condition" : {
"zipcode" IN [120010,120011,120012..]
}
}
},
"/entity/retail/sku" : {
"conditional" : {
"attribute_condition" : {
"/entity/retail/brand" == "Amul"
}
}
}
}
}
```
3. Using FetchRequest and ModelSchema get RepositoryFetchRequest:
```
{
"knowledge" :
{
"entity_type" : "/entity/retail/sku",
"entity_ids" : [sku1, sku2 ...]
"attributes" : {
"value" : ["mrp" ,"brand"],
}
}
"features" : {
"/entity/retail/category" : {
"row" : { "str" : [cat1 , cat2, cat3]}
"column" : {
"/feature/category/revenue/monthly" : {
"time_criteria" : { "ticks" : { "no." : 1 , "start_tick" : 0}}
}
}
}
"/entity/retail/store" : {
"row" : { "str" : [s1 , s2, s3]}
"column" : {
"/feature/store/traffic/weekly" : {
"time_criteria" : { "ticks" : { "no." : 1 , "start_tick" : 0}}
}
}
}
}
```
Questions ->
1. We need to call the model only for sku which has brand as "Amul", so do we need to make a call to knowledge repo first to get the list of all the skus ?
2. That means row condition in FETCH request will be converted to Knowledge fetch always.
3. There will never be row condition in table fetch request, as feature/inference repo can't evaluate the row conditions. Its only possible in case of KG fetch and which will be executed before table fetch.
4. "category" of sku is not coming in fetch request. how will it be fetched ?
keep track of parent record key to the row mapping
```
message FetchMergeIndex {
map<string, FetchMergeIndexMap> index = 1; // key = category
}
message FetchMergeIndexMap {
map<string, core.type.StrVector> index = 1; // key = category1 , value = sha256(store1*sku1)
}
```