Pith. sign in

REVIEW 4 major objections 7 minor 17 references

An Initial Exploration of Fine-tuning Small Language Models for Smart Contract Reentrancy Vulnerability Detection

T0 review · 4 major / 7 minor · reviewed 2026-08-07 · deepseek-v4-flash

Pith's one-line read Small, locally run language models can be fine-tuned to detect reentrancy vulnerabilities in Solidity smart contracts, reaching 67% test accuracy with a 3B parameter model and coming within a few points of a 14B model.

desk verdict A new application with a real evaluation flaw: the claimed 19-point gain vanishes when abstained contracts count as errors, so the paper needs major revision before its empirical claims can be trusted. read the letter →

arxiv 2505.19059 v1 pith:FY7JB76O submitted 2025-05-25 cs.SE cs.AIcs.ETcs.LG

classification cs.SEcs.AIcs.ETcs.LG
keywords smalllanguagemodelsparameter-efficientfine-tuningLoRAreentrancydetectionsmartcontractsSoliditysyntheticdatavulnerability
verification ladder T0 review T1 audit T2 compute T3 formal

The pith

A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.

The reading

Small open-source language models in the 1–3B parameter range can be fine-tuned with parameter-efficient methods to detect reentrancy vulnerabilities in Solidity smart contracts, despite the scarcity of real-world vulnerable examples. The paper reports that a LoRA-fine-tuned LLaMA 3B model reaches 67% test accuracy, a 19-percentage-point gain over its 48% baseline, and that a Qwen2.5Coder 3B reaches 59%, a 14-point gain. It places these results against a 14B model that scores 70.43%, arguing that the small model captures most of the detection capability at a fraction of the compute cost. The authors further contend that the general-purpose LLaMA architecture outperforms the code-specialised Qwen, suggesting pre-training diversity can beat domain specialisation for niche security tasks.

What carries the argument

The load-bearing mechanism is the combination of LoRA (Low-Rank Adaptation) fine-tuning with a synthetic-data generation pipeline. LoRA inserts small trainable low-rank matrices into the frozen transformer, so fewer than 1% of parameters are updated, making fine-tuning feasible on consumer hardware with 4-bit quantization. The synthetic pipeline produces 8,000 balanced Solidity contracts — 4,000 vulnerable and 4,000 secure — from parameterised templates covering four reentrancy subtypes and four security patterns, with SMOTE used to balance subtypes. This synthetic corpus supplies 92.5% of the vulnerable training contracts and 90% of the secure ones, compensating for the fact that only a small number of documented exploits (13) were sufficiently isolated for direct use. The test set of 120 contracts (57 vulnerable, 63 secure) blends 44 contracts from the Reentrancy Study Dataset with 13 real-world exploits.

What would settle it

Recompute the fine-tuned LLaMA model's accuracy with the 28 abstained contracts counted as misclassifications: the accuracy drops to about 62/120 ≈ 51.7%, nearly identical to the 48% baseline. A direct test would be to run the baseline model on exactly the same 92 contracts the fine-tuned model classified and check whether the 19-point gap persists, or to force the fine-tuned model to make a prediction on all 120 contracts.

Watch

Extended reading notes

Core claim

The central claim is that parameter-efficient fine-tuning of small language models (1–3B parameters) can repurpose general-purpose models into usable reentrancy detectors. Using Low-Rank Adaptation (LoRA) on 4-bit quantized models and a synthetic-data pipeline that generated 8,000 balanced Solidity contracts, the authors report the fine-tuned LLaMA 3B model attaining 67% test accuracy (19 percentage points over its 48% baseline) and the fine-tuned Qwen2.5Coder 3B attaining 59% (14 points over its 45% baseline). They also report that the 14B DeepSeek-r1 model reaches 70.43% on the same test set, only 3.43 points higher than the 3B LLaMA but at markedly higher computational cost. The authors interpret this as evidence that small models, fine-tuned with fewer than 1% of parameters updated, offer a practical local, privacy-preserving screening capability, and they use the results to argue that code-specialised pretraining is not automatically superior to diverse pretraining for niche security analysis.

Load-bearing premise

The finding depends on the assumption that it is valid to exclude the 28 contracts the fine-tuned model abstained on and still compare the resulting 67% accuracy against a 48% baseline that covers the full 120-contract test set.

Editorial extensions

If this is right

  • If the central claim holds, a developer can run reentrancy screening locally on a 3B model, avoiding the privacy and confidentiality risks of sending proprietary smart-contract code to a hosted LLM service.
  • A 3B model coming within roughly 3.4 percentage points of a 14B model implies a large efficiency-performance trade-off: most of the detection capability can be had at a fraction of the compute and memory cost.
  • Because LoRA updates fewer than 1% of parameters, the fine-tuning procedure is reproducible on modest hardware, lowering the barrier for adapting small models to other niche code-analysis tasks.
  • The paper's comparison suggests that model architecture and pre-training corpus diversity, rather than code-domain specialisation, may be the primary drivers of fine-tuning success for vulnerability detection.
  • The synthetic-data generation pipeline, anchored to a small set of real contracts, offers a way to train for vulnerability classes with scarce public labelled examples.

Reading between the lines

Editorial extensions of the paper, not claims the author makes directly.

  • The reported 67% accuracy is computed on the 92 contracts the LLaMA model classified, after it abstained on 28; if those abstentions are counted as errors, the accuracy becomes roughly 62/120 ≈ 51.7%, which would bring the fine-tuned model close to its 48% baseline and remove most of the reported 19-point gain.
  • The baseline figures appear to be computed on the full 120-contract test set, so the paper compares a subset score (67% on 92) against a full-set score (48% on 120); a like-for-like comparison on the same 92-contract subset would be needed to verify the gain.
  • The paper's framing of abstention as 'uncertainty recognition' suggests a natural extension: recasting the task as ternary classification (vulnerable, non-vulnerable, uncertain) would make the model's hedged predictions an explicit output and let users decide whether to send uncertain contracts for expert review.
  • The comparison to DeepSeek-r1 is also complicated by differing effective test sets, since DeepSeek skipped 5 contracts while LLaMA abstained on 28; the relative ranking of the models could shift under a forced-choice evaluation on the full 120 contracts.
Share X Bluesky LinkedIn Reddit HN

Editorial analysis

A structured set of objections, weighed in public.

Desk editor's note, referee report, and a circularity audit.

Referee Report

4 major / 7 minor

Summary. The paper explores fine-tuning two small language models (LLaMA 3B and Qwen2.5Coder 3B) with LoRA for Solidity reentrancy vulnerability detection. The training set of 8,000 contracts is mostly synthetically generated, and evaluation is performed on a 120-contract test set. The authors report that fine-tuned LLaMA 3B reaches 67% test accuracy versus a 48% baseline, Qwen2.5Coder 3B reaches 59%, and that the fine-tuned LLaMA model performs within 3.43 percentage points of a 14B DeepSeek model. The central claim is that small models can be adapted to this niche task with parameter-efficient fine-tuning while preserving local, privacy-preserving deployment.

Significance. If the headline result were credible, it would be a useful data point for privacy-preserving smart-contract screening: a 3B model that gains 19 points over a general-purpose baseline and nearly matches a 14B model would have clear practical value. The paper also contributes a synthetic data-generation pipeline and a comparison of two architectures. However, the evaluation has a load-bearing flaw: the fine-tuned LLaMA accuracy is computed on a subset of the test set after excluding 28 abstained contracts, while the baseline is computed on the full set. Counting abstentions as errors reduces the reported gain to a few points. The training and test sets also appear to share a common source dataset without an explicit disjointness check, which threatens the validity of all reported numbers. These issues must be resolved before the empirical claims can be accepted.

major comments (4)
  1. [Section 4.2.1, Tables 1-3] The reported 67% accuracy for the fine-tuned LLaMA 3B model is computed on only 92 of the 120 test contracts, because the model 'exhibits ambiguity in 28 of the 120 contracts.' The baseline accuracy of 48% in Table 1 is reported for the full model without such abstention. If the 28 abstained contracts are counted as misclassifications, the fine-tuned LLaMA accuracy becomes 62/120 = 51.7%, only 3.7 percentage points above baseline. The paper does not define the abstention criterion, nor does it justify comparing a subset accuracy against a full-set baseline. This invalidates the '19-percentage-point gain' claimed in Section 4.3, Figure 3, and Section 6.
  2. [Section 5, Table 6] The comparison with DeepSeek-r1 14B is similarly inconsistent: the fine-tuned LLaMA accuracy of 67.39% is computed on 92 contracts after skipping 28, while DeepSeek's 70.43% is computed on 115 contracts after skipping 5. The conclusion that the small model is 'only 3.43%' behind the larger model is therefore not an apples-to-apples comparison. Both models must be evaluated under the same coverage and decision rule before any efficiency-performance trade-off can be claimed.
  3. [Sections 2 and 2.8] The test set and training set appear to draw from the same source: 44 of the 57 vulnerable test contracts come from the Reentrancy Study Dataset, while the training set includes 300 vulnerable and 400 secure contracts from that same dataset. The paper does not report any deduplication or disjointness analysis between training and test splits. If near-duplicate contracts appear in both, the reported accuracies are inflated by memorization. The authors must demonstrate that the test set is disjoint from training data at the contract or near-duplicate level.
  4. [Section 4.2.1, Table 3] Even on the 92-contract subset, the fine-tuned LLaMA model has a vulnerable-class recall of only 0.37 (15 of 41 vulnerable contracts correctly identified). When the 28 abstained contracts are included as failures, the effective recall is even lower. A reentrancy detector with this false-negative rate is unlikely to be useful for security screening regardless of its precision, and the paper's conclusion that the model achieves 'reasonable precision' does not address the security-critical cost of missed vulnerabilities. The evaluation should report full-test-set recall and a cost-sensitive analysis.
minor comments (7)
  1. [Section 4.2.2] The text contains unresolved references to 'Figure ??' for the Qwen2.5Coder confusion matrix; the figure or table number should be corrected.
  2. [Section 2.1] The use of SMOTE on Solidity source code is unusual and is not explained; SMOTE is designed for continuous tabular features, so the paper should clarify how it is applied to code tokens or embeddings.
  3. [Section 3.4 and Section 4.2.1] The LoRA hyperparameters (rank, alpha, learning rate, number of epochs, batch size) and the exact criterion for the model's 'ambiguity' abstention are not reported, which prevents replication and makes the uncertainty-recognition claim untestable.
  4. [Section 4.2.1] The paper states that 'OpenAI language models' were used for cross-validation of test labels and that manual review was performed, but it does not specify the model version, prompt template, or number of reviewers; this information is needed to assess label reliability.
  5. [Section 6] The paper says '14%' for the Qwen gain, but elsewhere uses '14 percentage points'; the text should be consistent, and percentages should be distinguished from percentage points.
  6. [References and Conclusion] Section 6 attributes the small-model comparison to 'Gunasekar et al [16]', but reference [16] is Li et al., 'Textbooks Are All You Need II'; the citation should be corrected.
  7. [Throughout] Several typos and formatting issues appear, including 'T able', 'acheived', 'inlcuding', and missing spaces in table captions; a careful proofreading pass is needed.

Circularity Check

2 steps flagged · score 6.0 of 10

Reported 19-point LLaMA gain is computed on 92 of 120 contracts (67% = 62/92) while the 48% baseline covers all 120; counting abstentions as errors gives ~52%, so the central claim reduces to the evaluation rule.

  1. fitted input called prediction [Section 4.2.1 (Tables 1 and 2) and Section 6, 'Small Model Adaptation']
    "the LLaMA 3B model's performance increased to 67% test accuracy — a 19-percentage-point gain over the baseline. ... The model exhibits ambiguity in 28 of the 120 contracts. [Table 2: confusion-matrix rows sum to 92; Table 1 baseline: 'LLaMA 3B 48%']"

    Table 2 sums to 92 (47+4+26+15), so 67% = 62/92 is scored only on the contracts the fine-tuned model chose to output a class for, after abstaining on 28 of 120. Table 1's 48% baseline is quoted with no abstention and covers the full 120-contract test set. The claimed 19-percentage-point gain is therefore 62/92 minus ~58/120, a difference of two incompatible denominators. If the 28 abstentions are counted as errors, accuracy is 62/120 = 51.7%, a 3.7-point gain, and the fine-tuned LLaMA no longer beats the fine-tuned Qwen (59%, scored on all 120, Table 4). Section 6's central claim of 'substantial gains ... 19 percentage points' is thus forced by an unstated evaluation rule that lets only the fine-tuned model exclude its hardest cases while the baseline must answer everything.

  2. other [Section 5, Table 6]
    "The larger model delivered 70.43% test accuracy — only a 3.43% gain over the fine-tuned LLaMA 3B model (67.39%). ... five smart contracts had to be omitted due to resource constraints. [Table 6: DeepSeek-r1 skipped 5; Fine-tuned LLaMA skipped 28]"

    The near-parity conclusion (70.43% vs 67.39%) compares accuracies computed on different self-selected subsets: DeepSeek-r1 14B on 115 contracts (120 minus 5 omitted for resource constraints) and fine-tuned LLaMA on 92 contracts (120 minus 28 self-abstentions). With inconsistent denominators, the 3.43-point gap is not an apples-to-apples measure of relative capability. The Section 6 efficiency-performance trade-off claim depends on this comparison, so it too is partly an artifact of each model being scored on a different subset of the test set rather than on a common set of contracts.

full rationale

This is an empirical fine-tuning study with no mathematical derivation chain, and I find no load-bearing self-citation: the co-authors' own references [4,5] are cited only as examples of traditional verification tooling, and the Reentrancy Study Dataset [6] is an external resource. The accuracy numbers are measured, not fitted in the usual parameter sense. However, the paper's central claim — 'achieving substantial gains over baseline model performance, 19 percentage points for the fine-tuned LLaMA 3B model' (Section 6) — reduces by construction to an inconsistent evaluation protocol. Section 4.2.1 reports 67% test accuracy, which Table 2 shows is 62/92 (47+15 correct) after the model 'exhibits ambiguity in 28 of the 120 contracts,' whereas Table 1's 48% baseline is reported on the full 120-contract set with no abstention. Subtracting percentages over different denominators manufactures the 19-point gain: counting the 28 abstained contracts as errors gives 62/120 = 51.7%, a 3.7-point gain, and the fine-tuned LLaMA (51.7%) would no longer outperform the fine-tuned Qwen (59% on all 120). The same artifact corrupts the DeepSeek comparison in Section 5 and Table 6 (70.43% on 115 versus 67.39% on 92). Because the model's learned abstention determines which contracts enter the accuracy numerator, the reported gain is statistically forced by the evaluation design rather than being a property of the models. A secondary validation concern — test labels were partly produced by the same tooling family (Slither, OpenAI cross-check, manual review) rather than an independent oracle — is noted but is not itself the enumerated circular pattern. Since the headline result would not survive a consistent denominator, partial circularity (score 6) is warranted; this is not a full equivalence (score 8-10) because there is no derivation chain and no self-citation that asserts the result.

Assumptions & free parameters 5 free parameters · 4 assumptions · 0 invented entities

The central empirical claim rests on the correctness of the test labels, on the representativeness of synthetic training data, and on an evaluation protocol that treats abstentions as a legitimate exclusion. The paper does not release artifacts, so these assumptions cannot be independently checked.

free parameters (5)
  • LoRA rank r = not reported
    Determines capacity of fine-tuning; success of adaptation depends on it.
  • LoRA alpha = not reported
    Scaling factor for LoRA updates; not stated in paper.
  • Learning rate = not reported
    Critical for fine-tuning outcome; not stated.
  • Number of training epochs = not reported
    Stopping criterion; not stated.
  • Abstention threshold/criterion = not reported
    LLaMA abstained on 28 of 120 contracts; the criterion for abstention is not defined, and it directly changes the reported accuracy.
assumptions (4)
  • domain assumption Training and test subsets drawn from the Reentrancy Study Dataset are disjoint.
    Section 2: 300 train and 44 test contracts come from the same source with no disjointness statement; if violated, the central accuracy is inflated.
  • domain assumption Test-set labels are correct.
    Section 2.8: labels rely on Slither, OpenAI LLM cross-validation, and manual review; any label errors directly change the reported performance.
  • domain assumption Synthetic and modernized contracts preserve the vulnerability/security semantics.
    Sections 2.1-2.6: 92.5% of training data is synthetic; if the templates do not match real exploit distributions, the measured accuracy does not transfer.
  • domain assumption Excluding abstained contracts does not bias accuracy comparisons.
    Section 4.2.1: 28 of 120 contracts are omitted from the fine-tuned LLaMA accuracy while baseline evaluations do not use an abstention option; without a shared evaluation protocol the 19-point gain claim is unsupported.

how reviews work

0 comments
Cite this review

Pith. "Pith review of An Initial Exploration of Fine-tuning Small Language Models for Smart Contract Reentrancy Vulnerability Detection." pith.science (2026). https://pith.science/paper/FY7JB76O

@misc{pith2026250519059,
  author       = {Pith},
  title        = {Pith review of: An Initial Exploration of Fine-tuning Small Language Models for Smart Contract Reentrancy Vulnerability Detection},
  year         = {2026},
  howpublished = {\url{https://pith.science/paper/FY7JB76O}},
  note         = {Machine review of arXiv:2505.19059}
}
read the original abstract

Large Language Models (LLMs) are being used more and more for various coding tasks, including to help coders identify bugs and are a promising avenue to support coders in various tasks including vulnerability detection -- particularly given the flexibility of such generative AI models and tools. Yet for many tasks it may not be suitable to use LLMs, for which it may be more suitable to use smaller language models that can fit and easily execute and train on a developer's computer. In this paper we explore and evaluate whether smaller language models can be fine-tuned to achieve reasonable results for a niche area: vulnerability detection -- specifically focusing on detecting the reentrancy bug in Solidity smart contracts.

Discussion (0). Sign in to comment.

Reference graph

Works this paper leans on

17 extracted references · 10 canonical work pages

  1. [1]

    Millam, A., Bakke, C.: Coding with ai as an assistant: Can ai generate concise computer code? Journal of Information Technology Education: Innovations in Practice 23, 009 (2024)

  2. [2]

    Krishna, K., Murthy, P., Sarangi, S.: Exploring the synergy between generative ai and software engineering: Automating code optimization and bug fixing (2024)

  3. [3]

    arXiv preprint arXiv:2304.07232 (2023)

    Cheshkov, A., Zadorozhny, P., Levichev, R.: Evaluation of chatgpt model for vulnerability detection. arXiv preprint arXiv:2304.07232 (2023)

  4. [4]

    In: Fundamentals of Software Engineering: 8th International Conference, FSEN 2019, Tehran, Iran, May 1-3, 2019, Revised Selected Papers 8, pp

    Ahrendt, W., Bubel, R., Ellul, J., Pace, G.J., Pardo, R., Rebiscoul, V., Schneider, G.: Verification of smart contract business logic: exploiting a java source code verifier. In: Fundamentals of Software Engineering: 8th International Conference, FSEN 2019, Tehran, Iran, May 1-3, 2019, Revised Selected Papers 8, pp. 228–243 (2019). Springer 17

  5. [5]

    In: 2018 14th European Dependable Computing Conference (EDCC), pp

    Ellul, J., Pace, G.J.: Runtime verification of ethereum smart contracts. In: 2018 14th European Dependable Computing Conference (EDCC), pp. 158–163 (2018). IEEE

  6. [6]

    In: 2023 IEEE/ACM 45th International Conference on Software Engineering (ICSE), pp

    Zheng, Z., Zhang, N., Su, J., Zhong, Z., Ye, M., Chen, J.: Turn the rudder: A beacon of reentrancy detection for smart contracts on ethereum. In: 2023 IEEE/ACM 45th International Conference on Software Engineering (ICSE), pp. 295–306 (2023). IEEE

  7. [7]

    In: 2017 32nd IEEE/ACM International Conference on Automated Software Engineering (ASE), pp

    Godefroid, P., Peleg, H., Singh, R.: Learn&fuzz: Machine learning for input fuzzing. In: 2017 32nd IEEE/ACM International Conference on Automated Software Engineering (ASE), pp. 50–59 (2017). IEEE

  8. [8]

    In: International Conference on Learning Representations (2019)

    Hellendoorn, V.J., Sutton, C., Singh, R., Maniatis, P., Bieber, D.: Global relational models of source code. In: International Conference on Learning Representations (2019)

Show all 17 references
  1. [9]

    Journal of artificial intelligence research 16, 321–357 (2002)

    Chawla, N.V., Bowyer, K.W., Hall, L.O., Kegelmeyer, W.P.: Smote: synthetic minority over-sampling technique. Journal of artificial intelligence research 16, 321–357 (2002)

  2. [10]

    5-coder technical report

    Hui, B., Yang, J., Cui, Z., Yang, J., Liu, D., Zhang, L., Liu, T., Zhang, J., Yu, B., Lu, K., et al.: Qwen2. 5-coder technical report. arXiv preprint arXiv:2409.12186 (2024)

  3. [11]

    the Journal of machine Learning research 12, 2825–2830 (2011)

    Pedregosa, F., Varoquaux, G., Gramfort, A., Michel, V., Thirion, B., Grisel, O., Blondel, M., Prettenhofer, P., Weiss, R., Dubourg, V.,et al.: Scikit-learn: Machine learning in python. the Journal of machine Learning research 12, 2825–2830 (2011)

  4. [12]

    Information and Software Technology 135, 106552 (2021)

    Rabin, M.R.I., Bui, N.D., Wang, K., Yu, Y., Jiang, L., Alipour, M.A.: On the generalizability of neural program models with respect to semantic-preserving program transformations. Information and Software Technology 135, 106552 (2021)

  5. [13]

    Neurocomputing 568, 127063 (2024)

    Su, J., Ahmed, M., Lu, Y., Pan, S., Bo, W., Liu, Y.: Roformer: Enhanced transformer with rotary position embedding. Neurocomputing 568, 127063 (2024)

  6. [14]

    In: 2021 36th IEEE/ACM International Conference on Automated Software Engineering (ASE), pp

    Choi, J., Kim, D., Kim, S., Grieco, G., Groce, A., Cha, S.K.: Smartian: Enhanc- ing smart contract fuzzing with static and dynamic data-flow analyses. In: 2021 36th IEEE/ACM International Conference on Automated Software Engineering (ASE), pp. 227–239 (2021). IEEE

  7. [15]

    arXiv preprint arXiv:2206.03715 (2022) 18

    Kim, Y.J., Kwak, B.-w., Kim, Y., Amplayo, R.K., Hwang, S.-w., Yeo, J.: Modular- ized transfer learning with multiple knowledge graphs for zero-shot commonsense reasoning. arXiv preprint arXiv:2206.03715 (2022) 18

  8. [16]

    arXiv preprint arXiv:2309.05463 (2023)

    Li, Y., Bubeck, S., Eldan, R., Del Giorno, A., Gunasekar, S., Lee, Y.T.: Text- books are all you need ii: phi-1.5 technical report. arXiv preprint arXiv:2309.05463 (2023)

  9. [17]

    arXiv preprint arXiv:2307.09288 (2023) 19

    Touvron, H., Martin, L., Stone, K., Albert, P., Almahairi, A., Babaei, Y., Bash- lykov, N., Batra, S., Bhargava, P., Bhosale, S., et al.: Llama 2: Open foundation and fine-tuned chat models. arXiv preprint arXiv:2307.09288 (2023) 19

Pith tools

Reviewed August 7, 2026 · model on record in the stance chip above.