Mindket

LocalAlign_llama3.1_8B

Newversion 1 · updated

Overview

A LoRA adapter for Llama-3.1-8B-Instruct that trains it to follow trusted instructions and ignore commands hidden in external data. A prompt injection defense for people building LLM apps.

LocalAlign_llama3.1_8B is a kit in the Developer category, listed by Mindket. It is free. This is version 1, last updated on . Download it on this page, a zip of its files. Nothing in it runs by itself.

At a glance

You need
  • Python on your computer
  • PyTorch for your hardware, plus Transformers, PEFT and Accelerate
  • Access to the Llama-3.1-8B-Instruct base model
  • A GPU that supports BF16 for the card's example
Runs in
  • Python code that uses Transformers and PEFT
  • A GPU setup that supports BF16, which the card's example uses
  • Windows, macOS or Linux, with Python for the download
Start with
pip install torch "transformers>=4.51.0,<5" "peft==0.14.0" accelerate

Platform

WindowsOperating system
macOSOperating system
LinuxOperating system

About

What it is

LocalAlign is a fine-tuning method that makes a model resist prompt injection, where text inside a document or tool result tries to give the model new orders. The files here form a small add-on, a LoRA adapter, that sits on top of the Llama-3.1-8B-Instruct model. The defense is learned in training, so no separate attack detector runs at inference.

Who it suits

It suits developers who build apps where a model reads outside content, such as documents, web pages or tool output, and who need it to keep following only trusted instructions.

IndustryWho uses itHow they use itExample
SoftwareLLM app developersAdd a prompt injection defense to a model that reads outside dataA summarizer that must ignore commands inside a page
SecurityAI security researchersStudy defenses and test them against injection attacksComparing attack success rates with and without the adapter
AgentsAgent buildersKeep a tool-using model from obeying commands in tool resultsAn agent that reads emails without following hidden orders
ResearchAlignment researchersReproduce the paper's results with the released adapterChecking the reported numbers on the listed benchmarks

You can skip it if your app never feeds untrusted text to the model, or if you use a different base model, since this adapter is for Llama-3.1-8B-Instruct.

Where to use it

  • Python code that uses Transformers and PEFT
  • A GPU setup that supports BF16, which the card's example uses
  • Windows, macOS or Linux, with Python for the download
Use caseWhoWhat they get back
Harden a model against injectionApp developersA model that treats data commands as untrusted
Test injection attacksSecurity teamsAttack success rates to compare
Reproduce the paperResearchersThe adapter behind the reported tables

How to set it up

  • Python on your computer
  • PyTorch for your hardware, plus Transformers, PEFT and Accelerate
  • Access to the Llama-3.1-8B-Instruct base model
  • A GPU that supports BF16 for the card's example
  1. Install the Python packages with pip.
  2. Download the adapter files.
  3. Load the base model and attach the adapter through PEFT.
pip install torch "transformers>=4.51.0,<5" "peft==0.14.0" accelerate
pip install -U huggingface_hub
hf download yuyangGong/LocalAlign_llama3.1_8B

How to use it

You load the base Llama model, attach this adapter, and then prompt the model as usual. Trusted instructions go in the instruction part and outside content goes in the data part. The card's input format section is not part of the text shown here.

Example

A person builds a summarizer that reads a web page. The page hides a line telling the model to reveal its instructions. With the adapter attached, the model summarizes the page and does not follow that line. The card reports lower attack success rates on its test sets.

For newcomers and experts

If you are new to this, picture the model as an assistant that sometimes obeys notes slipped into the papers it reads. This adapter trains it to obey only its owner's instructions. Try it on a short document with a planted command.

If you know the field, the method has three stages: a warm-up preference for trusted instructions, generation of near-target adversarial examples, and margin-aware alignment that presses harder on small-margin examples. Adaptive attacks stay harder, and some benchmark scores drop slightly.

  1. Warm up a preference for trusted instructions
  2. Generate near-target injected examples
  3. Align with margin-aware weighting
  4. Release a LoRA adapter
  5. Attach it to Llama-3.1-8B-Instruct

Good to know

DefenseHotpotQA attack rateQasper attack rateInjecAgent attack rate
No defense74.0%83.0%81.1%
Meta-SecAlign44.0%45.0%13.5%
LocalAlign8.0%7.0%0.0%
  • Limits: adaptive attacks remain harder, with a 23.0% attack success rate on HotpotQA for this model.
  • Utility: some benchmarks drop slightly, for example IFEval goes from 80.34 to 73.93 for Llama 3.1.
  • Scope: it is an adapter, so it needs the Llama-3.1-8B-Instruct base model.
  • License: Llama 3.1 license, which comes from the base model.
  • Cost to run: none named.
  • Data it reaches: it copies the adapter files to your computer and reads only the prompts and documents you give it.

README and files

README

LocalAlign_llama3.1_8B

A LoRA adapter for Llama-3.1-8B-Instruct that trains it to follow trusted instructions and ignore commands hidden in external data. A prompt injection defense for people building LLM apps.

Made by yuyangGong on Hugging Face. These notes are Mindket's, written from its model page and model card; the model's own files and license are on Hugging Face.

About

What it is: LocalAlign is a fine-tuning method that makes a model resist prompt injection, where text inside a document or tool result tries to give the model new orders. The files here form a small add-on, a LoRA adapter, that sits on top of the Llama-3.1-8B-Instruct model. The defense is learned in training, so no separate attack detector runs at inference.

Who it suits: It suits developers who build apps where a model reads outside content, such as documents, web pages or tool output, and who need it to keep following only trusted instructions.

Industry | Who uses it | How they use it | Example
Software | LLM app developers | Add a prompt injection defense to a model that reads outside data | A summarizer that must ignore commands inside a page
Security | AI security researchers | Study defenses and test them against injection attacks | Comparing attack success rates with and without the adapter
Agents | Agent builders | Keep a tool-using model from obeying commands in tool results | An agent that reads emails without following hidden orders
Research | Alignment researchers | Reproduce the paper's results with the released adapter | Checking the reported numbers on the listed benchmarks

You can skip it if your app never feeds untrusted text to the model, or if you use a different base model, since this adapter is for Llama-3.1-8B-Instruct.

Where to use it:

  • Python code that uses Transformers and PEFT
  • A GPU setup that supports BF16, which the card's example uses
  • Windows, macOS or Linux, with Python for the download
Use case | Who | What they get back
Harden a model against injection | App developers | A model that treats data commands as untrusted
Test injection attacks | Security teams | Attack success rates to compare
Reproduce the paper | Researchers | The adapter behind the reported tables

How to set it up:

  • Python on your computer
  • PyTorch for your hardware, plus Transformers, PEFT and Accelerate
  • Access to the Llama-3.1-8B-Instruct base model
  • A GPU that supports BF16 for the card's example
  1. Install the Python packages with pip.
  2. Download the adapter files.
  3. Load the base model and attach the adapter through PEFT.
pip install torch "transformers>=4.51.0,<5" "peft==0.14.0" accelerate
pip install -U huggingface_hub
hf download yuyangGong/LocalAlign_llama3.1_8B

How to use it: You load the base Llama model, attach this adapter, and then prompt the model as usual. Trusted instructions go in the instruction part and outside content goes in the data part. The card's input format section is not part of the text shown here.

Example: A person builds a summarizer that reads a web page. The page hides a line telling the model to reveal its instructions. With the adapter attached, the model summarizes the page and does not follow that line. The card reports lower attack success rates on its test sets.

For newcomers and experts: If you are new to this, picture the model as an assistant that sometimes obeys notes slipped into the papers it reads. This adapter trains it to obey only its owner's instructions. Try it on a short document with a planted command.

If you know the field, the method has three stages: a warm-up preference for trusted instructions, generation of near-target adversarial examples, and margin-aware alignment that presses harder on small-margin examples. Adaptive attacks stay harder, and some benchmark scores drop slightly.

Warm up a preference for trusted instructions
Generate near-target injected examples
Align with margin-aware weighting
Release a LoRA adapter
Attach it to Llama-3.1-8B-Instruct

Good to know:

Defense | HotpotQA attack rate | Qasper attack rate | InjecAgent attack rate
No defense | 74.0% | 83.0% | 81.1%
Meta-SecAlign | 44.0% | 45.0% | 13.5%
LocalAlign | 8.0% | 7.0% | 0.0%
  • Limits: adaptive attacks remain harder, with a 23.0% attack success rate on HotpotQA for this model.
  • Utility: some benchmarks drop slightly, for example IFEval goes from 80.34 to 73.93 for Llama 3.1.
  • Scope: it is an adapter, so it needs the Llama-3.1-8B-Instruct base model.
  • License: Llama 3.1 license, which comes from the base model.
  • Cost to run: none named.
  • Data it reaches: it copies the adapter files to your computer and reads only the prompts and documents you give it.

On Hugging Face, 14 November 2026

  • Task: text generation
  • Library: peft
  • Formats: Safetensors
  • Downloads in the last 30 days: 156
  • Likes: 9
  • License: llama3.1
  • Based on: meta-llama/Llama-3.1-8B-Instruct
  • Tags: peft, safetensors, localalign, lora, prompt-injection, alignment, text-generation, conversational

Links

Get the model

Download its files with Hugging Face's command line:

pip install -U huggingface_hub
hf download yuyangGong/LocalAlign_llama3.1_8B

Then follow the usage in its model card. Nothing in this kit runs by itself.

Files
README.md  5 KB

1 file, 5 KB, downloaded as a zip.

What’s new

  • Version 1 · 2026-11-13

Compare with similar

Listed Hugging Face models in the same category that share the most tags with this one.

ProductDownloads, last 30 daysLikesParametersLicenseLast change
LocalAlign_llama3.1_8B This page1569—llama3.1
Qwen3-4B P9 HoneypotShares prompt-injection · peft · lora333—apache-2.0
K2-Horizon-7B-UnoShares peft · lora · text-generation203113—apache-2.0
Kev-4BShares peft · lora · safetensors12,499175—apache-2.0
Bespoke-Nimble-9BShares peft · lora · safetensors1,027254—apache-2.0
Qwen3.8-27b-Terse-Coder-LoRAShares peft · lora · safetensors2446117Mapache-2.0
Numbers as Mindket last read them, from 2026-11-12 to 2026-11-13.

Reviews

No ratings yet

Write a review

No reviews yet.

More from Mindket

See all from Mindket

Huashu Design

alchaincyf · Skill

Turns a one-line request in your AI agent into a finished design: a launch animation, a clickable app prototype, an editable slide deck, an infographic or a se…

New29.4k

Guizang PPT Skill

op7418 · Skill

Skill that makes single-file HTML slide decks, slide illustrations and platform covers in two visual styles, with a presenter mode for rehearsal. For speakers…

New29.8k

Claude Code Skills & Plugins

alirezarezvani · Skill

Adds 411 ready-made skills for Claude Code and other coding agents, grouped by role from engineering and product to marketing, finance and compliance. Installs…

New29.8k

Similar in Developer

See all in Developer

buzz

block · Kit

Self-hostable workspace where people and AI agents share the same rooms, built on a Nostr relay that logs every action as a signed event. For teams that want t…

New37.3k

plannotator

backnotprop · Kit

Opens your AI coding agent's plans, specs and code changes in a browser so you can annotate or comment on them and send the feedback straight back to the agent.

New10.5k

open-code-review

alibaba · Kit

Reviews Git changes with an AI agent that reads files and searches the codebase, then writes comments tied to exact lines. It suits developers who want automat…

New50.7k