Views
No views yet
jina-embeddings-v3 (8192 token context) trained via Contrastive Learning (Triplet Loss).| Metric | Score | Description |
|---|---|---|
| Production Reliability | 90.0% | Accuracy on documents with confidence > 75%. |
| Automation Coverage | 89.7% | Percentage of documents handled automatically. |
| Raw Accuracy | 85.44% | Baseline accuracy across all 29 classes. |
| Macro F1 | 0.86 | Balanced performance across rare and common classes. |
| Class | Precision | Recall | F1-Score |
|---|---|---|---|
| Director's Dealing | 96% | 98% | 0.97 |
| Remuneration Info | 98% | 90% | 0.94 |
| Net Asset Value | 94% | 99% | 0.96 |
| Voting Results | 95% | 92% | 0.93 |
| Annual Report | 90% | 86% | 0.88 |
pip install sentence-transformers xgboost huggingface_hub numpy1import joblib
2import xgboost as xgb
3import numpy as np
4from huggingface_hub import hf_hub_download
5from sentence_transformers import SentenceTransformer
6
7class FinancialClassifier:
8 def __init__(self, repo_id="FinancialReports/jina-v3-financial-classifier"):
9 print(f"Loading model from {repo_id}...")
10
11 # 1. Load the Brain (Jina Encoder)
12 self.encoder = SentenceTransformer(repo_id, trust_remote_code=True)
13 self.encoder.max_seq_length = 8192 # Full context window
14
15 # 2. Download & Load the Head (XGBoost)
16 classifier_path = hf_hub_download(repo_id=repo_id, filename="financial_classifier_final_v1.json")
17 self.classifier = xgb.XGBClassifier()
18 self.classifier.load_model(classifier_path)
19
20 # 3. Download & Load the Label Decoder
21 decoder_path = hf_hub_download(repo_id=repo_id, filename="label_decoder_final_v1.pkl")
22 self.id2label = joblib.load(decoder_path)
23 print("✅ System Ready.")
24
25 def predict(self, text):
26 # 1. Feature Extraction (Text + Log-Length)
27 # We inject document length to distinguish short Earnings Releases from long Interim Reports.
28 embedding = self.encoder.encode([text])[0]
29 length_feature = np.log1p(len(text))
30 length_norm = length_feature / 12.0 # Normalized scale
31
32 # Combine features
33 features = np.hstack([embedding, [length_norm]])
34
35 # 2. Inference
36 probs = self.classifier.predict_proba([features])[0]
37 pred_id = np.argmax(probs)
38 confidence = float(np.max(probs))
39 label = self.id2label[pred_id]
40
41 return {
42 "label": label,
43 "confidence": round(confidence, 4),
44 "status": "accept" if confidence > 0.75 else "manual_review"
45 }
46
47# Example
48clf = FinancialClassifier()
49doc = "We are pleased to announce the acquisition of..."
50result = clf.predict(doc)
51print(result)jinaai/jina-embeddings-v3AutoModelForSequenceClassification alone; it requires the accompanying XGBoost artifacts found in this repository.