Papers › Jatmo: Prompt Injection Defense by Task-Specific Finetuning

Jatmo: Prompt Injection Defense by Task-Specific Finetuning

29 Dec 2023arXiv:2312.17673archive 2025-07-28

Julien Piet, Maha Alrashed, Chawin Sitawarin, Sizhe Chen, Zeming Wei, Elizabeth Sun, Basel Alomair, David Wagner

Large Language Models (LLMs) are attracting significant research attention due to their instruction-following abilities, allowing users and developers to leverage LLMs for a variety of tasks. However, LLMs are vulnerable to prompt-injection attacks: a class of attacks that hijack the model's instruction-following abilities, changing responses to prompts to undesired, possibly malicious ones. In this work, we introduce Jatmo, a method for generating task-specific models resilient to prompt-injection attacks. Jatmo leverages the fact that LLMs can only follow instructions once they have undergone instruction tuning. It harnesses a teacher instruction-tuned model to generate a task-specific dataset, which is then used to fine-tune a base model (i.e., a non-instruction-tuned model). Jatmo only needs a task prompt and a dataset of inputs for the task: it uses the teacher model to generate outputs. For situations with no pre-existing datasets, Jatmo can use a single example, or in some cases none at all, to produce a fully synthetic dataset. Our experiments on seven tasks show that Jatmo models provide similar quality of outputs on their specific task as standard LLMs, while being resilient to prompt injections. The best attacks succeeded in less than 0.5% of cases against our models, versus 87% success rate against GPT-3.5-Turbo. We release Jatmo at https://github.com/wagner-group/prompt-injection-defense.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2312.17673")

Code

Syntology Ran 10 of 18 code samples harvested from 1 repository linked to this paper; 8 have no recorded run. Of those that ran: 10 ran with no contract checked.

By repository: official repository: 18 samples from 1 repository, 10 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

wagner-group/prompt-injection-defense officialmentioned in paper report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

18 samples harvested; 10 ran; 0 honoured the contract we drafted; 8 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

10ran
8unverified

Licence: 18 of the 18 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from wagner-group/prompt-injection-defense. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

call_openai wagner-group/prompt-injection-defense/src/jatmo/server.py official repository ran no licence file found · pointer only · 58f375594c3a65c3 · report
format_finetune_data wagner-group/prompt-injection-defense/src/jatmo/automatic_pipeline/utils.py official repository ran no licence file found · pointer only · afdfabcae731b1b3 · report
gather_inputs wagner-group/prompt-injection-defense/src/jatmo/example_tasks/auto_tasks/code_summarization.py official repository ran no licence file found · pointer only · 011dc1d185aadcee · report
get_formatting_input wagner-group/prompt-injection-defense/src/jatmo/automatic_pipeline/utils.py official repository ran no licence file found · pointer only · d8dd0fab84fbf910 · report
get_generation_prompt wagner-group/prompt-injection-defense/src/jatmo/automatic_pipeline/utils.py official repository ran no licence file found · pointer only · e0da5c3f437fc507 · report
init_servers wagner-group/prompt-injection-defense/src/jatmo/server.py official repository ran no licence file found · pointer only · 57b9140b8e2e42bb · report
load_hackaprompt_injections wagner-group/prompt-injection-defense/src/jatmo/semi_automatic_pipeline/utils.py official repository ran no licence file found · pointer only · af2d33fbd2f2574e · report
normalize_book wagner-group/prompt-injection-defense/src/jatmo/example_tasks/auto_tasks/translation.py official repository ran fingerprinted no licence file found · pointer only · de6f63f3c4a1f298 · report
perturb_passage wagner-group/prompt-injection-defense/src/jatmo/semi_automatic_pipeline/utils.py official repository ran fingerprinted no licence file found · pointer only · cf548b8291737d65 · report
write_prompt wagner-group/prompt-injection-defense/src/jatmo/example_tasks/auto_tasks/review_summarization.py official repository ran no licence file found · pointer only · 09ca1d2547f6362b · report
compare_to_ft_model wagner-group/prompt-injection-defense/src/jatmo/automatic_pipeline/eval_model.py official repository unverified no licence file found · pointer only · f64affb6add891aa · report
format_inputs wagner-group/prompt-injection-defense/src/jatmo/automatic_pipeline/input_generation.py official repository unverified no licence file found · pointer only · 4877041f759749d1 · report
gather_inputs wagner-group/prompt-injection-defense/src/jatmo/example_tasks/auto_tasks/news_summarization.py official repository unverified no licence file found · pointer only · aa55ccc6d4abdf48 · report
gather_inputs wagner-group/prompt-injection-defense/src/jatmo/example_tasks/auto_tasks/review_summarization.py official repository unverified no licence file found · pointer only · da6bcc46ae271b58 · report
gather_inputs wagner-group/prompt-injection-defense/src/jatmo/example_tasks/auto_tasks/translation.py official repository unverified no licence file found · pointer only · 64875c7d8e21226c · report
get_input_list wagner-group/prompt-injection-defense/src/jatmo/automatic_pipeline/input_generation.py official repository unverified no licence file found · pointer only · ecbd4b9dae46b569 · report
load_reviews wagner-group/prompt-injection-defense/src/jatmo/example_tasks/auto_tasks/review_summarization.py official repository unverified no licence file found · pointer only · 45f097951892870c · report
rate_completions wagner-group/prompt-injection-defense/src/jatmo/server.py official repository unverified no licence file found · pointer only · 3b5261f8ca59d546 · report

Tasks

Instruction Following

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

AdamAttentionAttention DropoutBASEBPECosine AnnealingDense ConnectionsDropoutGPT-3Layer NormalizationLinear LayerLinear Warmup With Cosine AnnealingMulti-Head AttentionResidual ConnectionSoftmaxWeight Decay

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections