This model is a fine-tuned BERT-based classifier for financial news topic classification based on
fuchenru/Trading-Hero-LLM, supporting 20 distinct financial topics. It is designed for use in financial NLP applications, news analytics, and automated trading systems.
1from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
2
3tokenizer = AutoTokenizer.from_pretrained("leonas5555/finnews-topic-single-classify")
4model = AutoModelForSequenceClassification.from_pretrained("leonas5555/finnews-topic-single-classify")
5
6nlp = pipeline("text-classification", model=model, tokenizer=tokenizer)
7
8# Example text
9text = "LIVE: ECB surprises with 50bps hike, ending its negative rate era. President Christine Lagarde is taking questions"
10
11result = nlp(text)
12print(result)
13# Output: [{'label': 'Fed | Central Banks', 'score': 0.98}]
-
Framework: HuggingFace Transformers (Trainer API)
-
Arguments:
- num_train_epochs: 10
- per_device_train_batch_size: 32
- per_device_eval_batch_size: 32
- gradient_accumulation_steps: 1
- learning_rate: 2e-5
- fp16: True (Native AMP mixed precision)
- warmup_ratio: 0.1
- label_smoothing_factor: 0.05
- max_grad_norm: 1.0
- max_length: 256
- evaluation_strategy: "steps"
- save_strategy: "steps"
- save_total_limit: 3
- load_best_model_at_end: True
- metric_for_best_model: "f1"
- run_name: "topic_classifier"
- seed: 42
-
Early Stopping: Patience of 2 evaluation steps (via EarlyStoppingCallback)
-
Optimizer: Adam (betas=(0.9, 0.999), epsilon=1e-08)
-
Scheduler: Linear
-
Metrics: F1 (for best model selection), plus accuracy, precision, recall
An ONNX version of this model {TBD} for use with high-performance inference engines such as Infinity.