Created
June 6, 2021 07:23
-
-
Save ianpaul/720b9a3212287a7b65430e58ddc53dfc to your computer and use it in GitHub Desktop.
Use a binary classification model on Hugging Face to determine whether a statement in English is positive or negative.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
read -p "Hello! Give me something to work with! A sentence or tweet will do. " sentence | |
# now let's do some curl magic | |
curl --fail --silent --show-error -X POST -H "Authorization: Bearer HUGGINGFACE_API_KEY" -H "Content-Type: application/json" -d '{"inputs": "'"$sentence"'"}' https://api-inference.huggingface.co/models/YOUR_USERNAME/PROJECT_URL | jq '.[0] | map(.) | if .[0].score < .[1].score then "positive" else "negative" end' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment