Using Saagie Hugging Face Model Server Via API
-
Make sure the official Saagie repository is up to date. For more information, see Updating Repositories.
-
Verify that you have enabled the
Saagie HF ModelServer TextCLFapp in your project settings. If not, modify them. The app is available in the official Saagie repository.
-
Create the
Saagie HF ModelServer TextCLFapp in your project by clicking Install an app from your project’sApps page.
Your app appears in the project’s app library. -
Create the
$SHF_APIproject environment variable. Its value must be the URL of the Saagie model deployer,http://app-<YOUR_APP_ID>:8080. Where the value for<YOUR_APP_ID>can be found in the URL of your app page (a)
You can use the breadcrumb trail to navigate more easily. From your app, go back one menu level and click
.
-
Create a new job in Bash, for example, and make a
curlquery to deploy and predict your text. Your code must include the environment variable created earlier.Example 1. Curl query to deploy and predict a textMODEL='j-hartmann/emotion-english-distilroberta-base:main' LABEL='anger|disgust|fear|joy|neutral|sadness|surprise' curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d\'{"model_dir":"'$MODEL'", "label":"'$LABEL'"}' $SHF_API"/deploy" curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d\'{"inputs":["Good Movie, best of the year", "Highly recommended","very bad", "worst movie"]}' $SHF_API"/predict"The expected result must be as follows:
{"response":"j-hartmann/emotion-english-distilroberta-base:main is deployed."} [{"label":"joy","score":0.89230877161026}, {"label":"neutral","score":0.8408186435699463}, {"label":"disgust","score":0.6104941368103027}, {"label":"disgust","score":0.9444230198860168}]You can adapt the code for use with other Saagie technologies.