Internal Representations of Safety Across Post-Training
Aug – Oct 2026Safety SFT keeps a model’s internal harmful–benign contrast, while DPO redirects it in every run.
M.Sc. EECS, University of Belgrade, previously Applied Science Intern at Microsoft
I work on machine learning systems from both ends: building them and testing what they do. I have built retrieval pipelines, evaluation harnesses and containerized services, and I study models with controlled experiments, causal interventions and preregistered analysis.
Most of my work comes down to checking whether a change did anything: LLM evaluation and knowledge-graph QA generation at Microsoft, a study of how post-training changes a model’s internal representations, and performance measurement across CPU, GPU and TPU.
Paper accepted at TELFOR 2026 from my safety SFT vs DPO study.
Finished the Applied Science internship at Microsoft, working on LLM evaluation, knowledge graphs and multi-hop reasoning.
Gave a talk on attention across computational paradigms at SICAAI, the 5th Serbian International Conference on Applied Artificial Intelligence, in Kragujevac.
Started as Research Collaborator at IPSI Belgrade.
Applied science at Microsoft, and an ongoing research collaboration at IPSI Belgrade.
Microsoft, Applied Science Intern
Mar 2026 – Jul 2026ResultWhere a graph-based ranker and a surface-level grader agree (65.5% of questions), they matched expert difficulty labels 81.2% of the time, against 64.6% for a hop-count policy on the same questions.
Applied Science internship, Microsoft. Hop count is the standard proxy for multi-hop difficulty. Paired difference 16.6 points, document-bootstrap 95% CI 5.8–28.4.
| Scorer | Agreement |
|---|---|
| Both views agree | 81.2% |
| Hop count, same questions | 64.6% |
IPSI Belgrade, Research Collaborator
Feb 2026 – presentSix projects.
Safety SFT keeps a model’s internal harmful–benign contrast, while DPO redirects it in every run.
Contrastive fine-tuning on 20k CoSQA pairs for better code retrieval, with FAISS search over 550+ indexed snippets.
Benchmarked attention on 12 execution substrates and 17 implementations: eight measured on CPU, an NVIDIA T4 and a TPU, the rest modelled.
CNN-LSTM and ResNet-Transformer recognition models, packaged as a Dockerized FastAPI service with W&B tracking and CircleCI, architected for AWS Lambda.
Engagement prediction to an MAE of about 5.1 days from 30+ features over 90k sessions, plus A/B tests worked both frequentist and Bayesian.
Backpropagation written from scratch in NumPy and raced against a genetic algorithm, plus 2-opt, simulated annealing and differential evolution.
Three projects with the measurements behind them.
FindingSafety SFT preserved the model's internal harmful–benign contrast and DPO redirected it, even though SFT changed the weights 6.6–6.7× as much.
Bands span six training runs per recipe (two starts × three runs). The line is their mean. Qwen2.5-1.5B, final prompt token.
| Layer | Safety SFT | DPO |
|---|---|---|
| 16 | 0.32 (0.23–0.42) | 1.17 (0.82–1.41) |
| 20 | 0.32 (0.23–0.42) | 1.64 (1.43–1.86) |
| 24 | 0.31 (0.23–0.40) | 1.31 (1.16–1.46) |
| 28 | 0.34 (0.24–0.43) | 1.29 (1.12–1.41) |
Two starting models, instruction-tuned on Alpaca or Dolly. Bars span three training runs per recipe. Harmful prompts: HarmBench, n=150. Alarming benign prompts: XSTest, n=250.
| Measure | Start | Safety SFT | DPO |
|---|---|---|---|
| Alpaca start | 83% | 73–76% | 0–2% |
| Dolly start | 81% | 71–77% | 0–1% |
| Alpaca start | 0% | 2–4% | 24–37% |
| Dolly start | 1% | 2–5% | 30–53% |
FindingOne NumPy scalar, a 20× slowdown. Under NumPy 2 a float32 array times a NumPy float64 scalar becomes float64, so the FP32 attention benchmark was measuring FP64 (199 against 4,002 GFLOP/s on the same T4), and scaled_dot_product_attention fell back to its unfused math path. Clean FP32 and FP64 microbenchmarks and PyTorch's own dispatch warnings pinned it down.
Blue rows ran on hardware I had access to (CPU, an NVIDIA T4 and a TPU). Orange rows are simulators or analytical cost models. Where the roofline model can be checked against a measurement, it behaves as an upper bound should: 6,592 GFLOP/s for decomposed FP32 GPU against a measured 4,002. Checked against the literature, every model is optimistic, so treat them as order-of-magnitude bounds. This chart shows the 14 implementations that share n=2048, d=256; the chemical, biological and quantum simulators only run at n=32, d=16 and are reported separately.
| Implementation | GFLOP/s | Source |
|---|---|---|
| TPU, fused (JAX/XLA) | 15,772 | measured |
| GPU FP16, fused SDPA | 9,368 | measured |
| GPU FP16, decomposed | 9,103 | measured |
| TPU, decomposed (per-op JIT) | 4,908 | measured |
| GPU FP32, decomposed | 4,002 | measured |
| GPU FP32, fused SDPA | 2,354 | measured |
| Dataflow (Maxeler-style) | 977 | modeled |
| Optical (photonic MZI) | 510 | modeled |
| CPU, fused SDPA (PyTorch) | 71 | measured |
| CPU, decomposed (NumPy) | 38 | measured |
| GaAs RISC-V | 0.15 | modeled |
| IoT edge (ARM M4F) | 0.11 | modeled |
| WSN, 64 nodes | 0.01 | modeled |
| Minimal-ISA machine | 0.0007 | modeled |
FindingContrastive fine-tuning moved MRR@10 from 0.786 to 0.911 on CoSQA, a 16% relative gain.
Evaluated with torchmetrics on the held-out split. Recall@10 was already high, so most of the gain is in ranking quality.
| Metric | Before | After |
|---|---|---|
| MRR@10 | 0.786 | 0.911 |
| NDCG@10 | 0.831 | 0.932 |
| Recall@10 | 0.969 | 0.996 |
Education, volunteering, skills and awards.
Volunteer with EESTEC, the European EECS student association (34 universities, 4,000+ members), since February 2019. It is where I learned to run teams and teach.
EESTEC, Soft Skills Trainer
Aug 2021 – presentEESTEC, Training Team Coordinator, LC Belgrade
Feb 2022 – May 2023EESTEC, Regionalization Coordinator, then Project Leader
Aug 2019 – Aug 2021EESTEC, PR Team Leader and Event Organizer
2019
Recommendation letterEESTEC International Board, Zürich, August 2025Christa Ward, Chairperson, and Atina Velinovska, Vice Chairperson for Internal AffairsRead it (PDF, 2 pages)Topics I trainFacilitation and meeting design, feedback and nonviolent communication, emotional intelligence, team dynamics, presentation, strategic and design thinking, problem solving and creativity, training design, learning from experience