Please describe the module you would like to add to bricks
I have fine-tuned a BERT model on a lot of stock news. The model can be used via the HuggingFace inference api.
Do you already have an implementation?
import requests
import json
API_KEY: str = "<API_KEY_GOES_HERE>"
ATTRIBUTE: str = "headline" # only text attributes
def stock_bert_classifier(record):
"""
Uses toxic-bert via Hugging Face Inference API to classify toxicity in text.
"""
api_token = API_KEY
inputs = record[ATTRIBUTE].text
headers = {"Authorization": f"Bearer {api_token}"}
response = requests.post("https://api-inference.huggingface.co/models/KernAI/stockBERT", headers=headers, json={"inputs": inputs})
json_response = response.json()
result = [
{item["label"]: item["score"] for item in entry}
for entry in json_response
]
return json.dumps(result[0])
Please describe the module you would like to add to bricks I have fine-tuned a BERT model on a lot of stock news. The model can be used via the HuggingFace inference api.
Do you already have an implementation?
Additional context https://huggingface.co/KernAI/stockBERT