Views
No views yet
BAAI/bge-m3
embeddings, so it is multilingual (100+ languages, 8192-token context) and embeds whole
documents.acquisition_agreement, commercial_agreement, constitutional,
employment_agreement, financial_statements, financing_agreement, ip_agreement,
lease_agreement, nda (commercial_agreement is the catch-all for "some other contract").acquisition_agreement: 1.000commercial_agreement: 0.914constitutional: 1.000employment_agreement: 1.000financial_statements: 1.000financing_agreement: 0.983ip_agreement: 0.875lease_agreement: 0.980nda: 0.975
1import numpy as np, skops.io as sio
2from sentence_transformers import SentenceTransformer
3from huggingface_hub import hf_hub_download
4
5REPO = "lydongcanh/tectonic-doctype"
6enc = SentenceTransformer("BAAI/bge-m3")
7enc.max_seq_length = 8192
8head = sio.load(hf_hub_download(REPO, "classifier.skops"), trusted=[])
9
10def classify(text: str):
11 words = text.split()
12 chunks = [" ".join(words[i:i+2000]) for i in range(0, len(words), 2000)][:6] or [""]
13 v = enc.encode(chunks).mean(0); v = v / np.linalg.norm(v)
14 p = head.predict_proba([v])[0]; i = int(p.argmax())
15 return {"label": head.classes_[i], "confidence": float(p[i])}