Instructions to use yusifnuri/phi-4-mini-instruct_financial_sentiment with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use yusifnuri/phi-4-mini-instruct_financial_sentiment with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("microsoft/phi-4-mini-instruct") model = PeftModel.from_pretrained(base_model, "yusifnuri/phi-4-mini-instruct_financial_sentiment") - Notebooks
- Google Colab
- Kaggle
phi-4-mini-instruct โ Financial sentiment adapter
A LoRA adapter that specialises microsoft/Phi-4-mini-instruct (3.80 B parameters) for a single enterprise task: it classifies a financial sentence as negative, neutral or positive.
It was produced for the MSc thesis Fine-Tune or Pay Per Token? An Enterprise Benchmark of Small Language Models (SRH University Hamburg), which measures fine-tuned small models against frontier provider APIs on accuracy, latency, cost, privacy exposure and return-on-investment breakeven volume. The adapter is released so that the benchmark can be independently verified.
Read this before using the adapter
The training corpus (Financial PhraseBank) is licensed CC BY-NC-SA 3.0. This adapter is a research artefact and is not commercially deployable; commercial use would require a licensed corpus or your own annotations.
This adapter scores below its own split's neutral-majority share (~0.61), which indicates a failure to produce the target output format rather than partial competence. Do not use it. The cause is under investigation; see ยง4.2.4 of the thesis.
Measured performance
| Metric | Value |
|---|---|
| Accuracy | 0.545 |
| Mean latency, batch 1 | 522 ms |
| Cost per 1M generated tokens | USD 18.09 |
Measured on a single NVIDIA H200 (141 GB) at batch size one and full utilisation, priced at an imputed USD 3.99 per GPU-hour. Latency excludes network transit. Scores are not comparable across tasks โ each task carries its own metric. Evaluation ran on 5 July 2026; the complete matrix is at results/benchmark_matrix.csv.
Training
| Method | LoRA |
| Dataset | Financial PhraseBank (AllAgree) ((not redistributable)) |
| Dataset licence | CC BY-NC-SA 3.0 โ non-commercial |
| Training examples | 5,000 (500 held out for checkpoint selection) |
| Rank / alpha / dropout | 16 / 32 / 0.05 |
| Target modules | q_proj, k_proj, v_proj, o_proj |
| Learning rate | 2e-4, cosine schedule, 3% warmup |
| Epochs | 3 |
| Effective batch size | 16 (4 x 4 gradient accumulation) |
| Max sequence length | 512 tokens |
| Optimiser | AdamW |
| Seed | 42 |
Hyperparameters were held constant across every model and task rather than tuned per cell, so these figures are a conservative lower bound on attainable performance.
Usage
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base = AutoModelForCausalLM.from_pretrained("microsoft/Phi-4-mini-instruct", device_map="auto")
model = PeftModel.from_pretrained(base, "<your-hf-username>/phi-4-mini-instruct_financial_sentiment")
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-4-mini-instruct")
The adapter was trained on this prompt format and expects it at inference:
Classify the sentiment of this financial sentence (negative / neutral / positive):
{text}
Sentiment:
Limitations
- Trained once, with a single seed. Reported differences confound model quality with initialisation variance.
- Specialised to one task on one public corpus. It is not a general-purpose assistant and should not be treated as one.
- The evaluation corpora are long-standing public benchmarks and are plausibly present in the base model's pretraining data, which inflates absolute scores.
- Evaluation used 200 held-out instances (all 164 problems for code generation), so detectable effect sizes are bounded at roughly ten percentage points.
Links
- Code, configurations and evaluation harness: https://github.com/Yusifnuri/slm-benchmark
- Full benchmark matrix:
results/benchmark_matrix.csv - Per-request cost analysis:
results/cost_per_request.csv
Citation
@mastersthesis{nuri2026finetune,
title = {Fine-Tune or Pay Per Token? An Enterprise Benchmark of Small Language Models},
author = {Nuri, Yusif},
school = {SRH University Hamburg},
year = {2026}
}
- Downloads last month
- 11
Model tree for yusifnuri/phi-4-mini-instruct_financial_sentiment
Base model
microsoft/Phi-4-mini-instruct