Hosted APIs
Bias analysis models on free hosted endpoints.
fairlyAspects (types-of bias)
Endpoint: https://t41xs75wejr14zht.us-east-1.aws.endpoints.huggingface.cloud
async function query(data) {
const response = await fetch(
"https://t41xs75wejr14zht.us-east-1.aws.endpoints.huggingface.cloud",
{
headers: {
"Accept" : "application/json",
"Content-Type": "application/json"
},
method: "POST",
body: JSON.stringify(data),
}
);
const result = await response.json();
return result;
}
query({
"inputs": "Your sentence for bias aspect classification",
"parameters": {
"top_k": 3,
"function_to_apply": "sigmoid"
}
}).then((response) => {
console.log(JSON.stringify(response));
});All parameters are optional
top_k: Number of classes and scores to return. Defaults to return all 11 classes and their scores.function_to_apply: Activation function to use on the model outputs. Can be"sigmoid"(multi-label),"softmax"(mult-class), orNonefor raw logits. Defaults to"softmax".
import requests
API_URL = "https://t41xs75wejr14zht.us-east-1.aws.endpoints.huggingface.cloud"
headers = {
"Accept" : "application/json",
"Content-Type": "application/json"
}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
output = query({
"inputs": "Your sentence for bias aspect classification",
"parameters": {
"top_k": 3,
"function_to_apply": "sigmoid"
}
})All parameters are optional
top_k: Number of classes and scores to return. Defaults to return all 11 classes and their scores.function_to_apply: Activation function to use on the model outputs. Can be"sigmoid"(multi-label),"softmax"(mult-class), orNonefor raw logits. Defaults to"softmax".
curl "https://t41xs75wejr14zht.us-east-1.aws.endpoints.huggingface.cloud" \
-X POST \
-H "Accept: application/json" \-H "Content-Type: application/json" \
-d '{
"inputs": "Your sentence for bias aspect classification",
"parameters": {
"top_k": 3,
"function_to_apply": "sigmoid"
}
}'All parameters are optional
top_k: Number of classes and scores to return. Defaults to return all 11 classes and their scores.function_to_apply: Activation function to use on the model outputs. Can be"sigmoid"(multi-label),"softmax"(mult-class), orNonefor raw logits. Defaults to"softmax".
Endpoint: https://e29pozks7ptdl5gw.us-east-1.aws.endpoints.huggingface.cloud
async function query(data) {
const response = await fetch(
"https://e29pozks7ptdl5gw.us-east-1.aws.endpoints.huggingface.cloud",
{
headers: {
"Accept" : "application/json",
"Content-Type": "application/json"
},
method: "POST",
body: JSON.stringify(data),
}
);
const result = await response.json();
return result;
}
query({
"inputs": "Your sentence for binary bias classification",
"parameters": {
"top_k": 2,
"function_to_apply": "sigmoid"
}
}).then((response) => {
console.log(JSON.stringify(response));
});All parameters are optional
top_k: Can be1or2, defaults to1, meaning it just returns the highest probable class (Biased or Neutral).function_to_apply: Activation function to use on the model outputs. Can be"sigmoid"(multi-label),"softmax"(mult-class), orNonefor raw logits. Defaults to"softmax".
import requestsAll parameters are optional
top_k: Can be1or2, defaults to1, meaning it just returns the highest probable class (Biased or Neutral).function_to_apply: Activation function to use on the model outputs. Can be"sigmoid"(multi-label),"softmax"(mult-class), orNonefor raw logits. Defaults to"softmax".
curl "https://e29pozks7ptdl5gw.us-east-1.aws.endpoints.huggingface.cloud" \
-X POST \
-H "Accept: application/json" \-H "Content-Type: application/json" \
-d '{
"inputs": "Your sentence for binary bias classification",
"parameters": {
"top_k": 2,
"function_to_apply": "sigmoid"
}
}'All parameters are optional
top_k: Can be1or2, defaults to1, meaning it just returns the highest probable class (Biased or Neutral).function_to_apply: Activation function to use on the model outputs. Can be"sigmoid"(multi-label),"softmax"(mult-class), orNonefor raw logits. Defaults to"softmax".
Token Classification (of generalizations, unfairness, and stereotypes)
Endpoint: https://e29pozks7ptdl5gw.us-east-1.aws.endpoints.huggingface.cloud
async function query(data) {
const response = await fetch(
"https://mo5fr3ll9qufbwuy.us-east-1.aws.endpoints.huggingface.cloud",
{
headers: {
"Accept" : "application/json",
"Content-Type": "application/json"
},
method: "POST",
body: JSON.stringify(data),
}
);
const result = await response.json();
return result;
}
query({
"inputs": "Hello world!",
"parameters": {}
}).then((response) => {
console.log(JSON.stringify(response));
});*No params needed*
import requests
API_URL = "https://e29pozks7ptdl5gw.us-east-1.aws.endpoints.huggingface.cloud"
headers = {
"Accept" : "application/json",
"Content-Type": "application/json"
}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
output = query({
"inputs": "I like you. I love you",
"parameters": {
"top_k": 2,
"function_to_apply": "sigmoid"
}
})*No params needed*
curl "https://e29pozks7ptdl5gw.us-east-1.aws.endpoints.huggingface.cloud" \
-X POST \
-H "Accept: application/json" \-H "Content-Type: application/json" \
-d '{
"inputs": "I like you. I love you",
"parameters": {
"top_k": 2,
"function_to_apply": "sigmoid"
}
}'*No params needed*
Example Response:
[
{
"token": "data",
"labels": [
"B-STEREO",
"B-GEN"
]
},
{
"token": "scientists",
"labels": [
"B-GEN",
"I-GEN"
]
},
{
"token": "are",
"labels": [
"I-STEREO"
]
},
{
"token": "so",
"labels": [
"I-STEREO"
]
},
{
"token": "smart",
"labels": [
"I-STEREO"
]
}
]Last updated