Text Classification
Transformers
Safetensors
English
modernbert
feature-extraction
decision-model
system-one
typed-decisions
calibration
probabilistic-classification
long-context
Eval Results
text-embeddings-inference
Instructions to use helmo/DecidaBERT-large-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use helmo/DecidaBERT-large-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="helmo/DecidaBERT-large-v2")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("helmo/DecidaBERT-large-v2") model = AutoModel.from_pretrained("helmo/DecidaBERT-large-v2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 1,352 Bytes
b04d205 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | """A minimal `POST /v1/systemone` server for DecidaBERT-large-v2.
pip install torch transformers safetensors fastapi uvicorn huggingface_hub
PORT=8000 python decision_server.py
POST /v1/systemone {"state": ..., "questions": {qid: {"type", "instructions", "criteria"}}}
POST /v1/systemone/batch {"requests": [ {"state", "questions"}, ... ]}
"""
import os
import time
import uvicorn
from fastapi import FastAPI
from pydantic import BaseModel
from decidabert_v2 import load
MODEL = load(os.environ.get("MODEL_PATH", os.path.dirname(os.path.abspath(__file__))))
app = FastAPI(title="DecidaBERT-large-v2")
class Request(BaseModel):
state: object
questions: dict
model: str | None = None
class Batch(BaseModel):
requests: list[Request]
model: str | None = None
def _answer(r: Request) -> dict:
t0 = time.perf_counter()
answers = MODEL.predict(r.state, r.questions)
return {"model": "DecidaBERT-large-v2", "answers": answers, "latency_ms": round((time.perf_counter() - t0) * 1000, 1)}
@app.post("/v1/systemone")
def systemone(r: Request) -> dict:
return _answer(r)
@app.post("/v1/systemone/batch")
def batch(b: Batch) -> dict:
return {"responses": [_answer(r) for r in b.requests]}
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=int(os.environ.get("PORT", 8000)))
|