Exemple of Confidential AI inference with LightGBM on Klave.
This contract implements a single method getExposureRisk
that take user input, load lightGBM model, infer from user input, unload LightGBM model and return results to the user.
We use as an example the model we have created for determinating COVID contamination risk - Paper
Fork the repo https://github.com/secretarium/klave-ai-inference and clone it on your machine. You can build your template into wasm locally, allowing you to validate the hash of the application deployed on Klave.
Note: You should have node and yarn installed to be able to build locally.
yarn install
yarn build
You can deploy the back-end of the secure data room to Klave with one click:
Retrieve the address of your honest application after deployment on klave website as you will target it within the UI and the storage server.
After deploying the contract and allocating Credit the App, you can try to call the method getExposureRisk
method with the following input:
{
"riskProfile": "low",
"questionnaire": {
"locationType": 8,
"locationInsideOrOutside": 0,
"numberOfPeoplePresent": 3,
"timeSpentOnLocation": 0,
"wearingMask": 0,
"staffProperlyWearingPPE": 0,
"peopleProperlyWearingPPE": 0,
"socialDistancing": 1,
"additionalMeasuresInPlace" : 0,
"numberOfPeopleInTheParty": 1,
"allMemberOfHousehold": 1,
"allMemberOfSupportBubble": 0,
"qualityOfTheAirflow": 3,
"temperatureInVenue": 2,
"humidityInVenue": 1,
"cleanAfterEveryUsage": 3,
"anyContactBetweenMembers": 2,
"physicalActivity": 2,
"exposureLedContamination": 2
}
}
And you should get the following output:
{
"inferred": 0.5018788418268543,
"riskIndex": 1,
"contaminationStatus": "medium",
"colour": "#fe6100",
"visuallyImpairedColour": "#dc267f"
}
Don't hesitates to play with the input to infer different results.
This library is created by Klave and Secretarium team members, with contributions from:
- Jeremie Labbe (@jlabbeklavo) - Klave | Secretarium
- Florian Guitton (@fguitton) - Klave | Secretarium
- Damian Tziamtzis (@damtzi) - Klave | Secretarium
- Etienne Bosse (@Gosu14) - Klave | Secretarium