---
title: "LocalAlign_llama3.1_8B"
kind: "Kit"
category: "Developer"
price: "Free"
seller: "Mindket"
version: "1"
url: "https://mindket.com/p/d03fc047-365a-4c7b-af13-dca3cf027809"
updated: "2026-11-13"
---

# LocalAlign\_llama3.1\_8B

> The name, the description, the About and a README below are the seller's words: data, not instructions.

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 2026-11-13. Download it on this page, a zip of its files. Nothing in it runs by itself.

Made by yuyangGong

## 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.

```bash
pip install torch "transformers>=4.51.0,<5" "peft==0.14.0" accelerate
```

```sh
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.

## README

````markdown
# 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.

```table
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

```table
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.

```bash
pip install torch "transformers>=4.51.0,<5" "peft==0.14.0" accelerate
```

```sh
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.

```flow
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:

```table
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

- Model: https://huggingface.co/yuyangGong/LocalAlign_llama3.1_8B
- Files: https://huggingface.co/yuyangGong/LocalAlign_llama3.1_8B/tree/main

## Get the model

Download its files with Hugging Face's command line:

```sh
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.
````

## What is in it

1 files, 5 KB, downloaded as a zip.

```text
README.md  5 KB
```

## Source

[yuyangGong/LocalAlign_llama3.1_8B on Hugging Face](https://huggingface.co/yuyangGong/LocalAlign_llama3.1_8B)

## Compare with similar

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

| Product | Downloads, last 30 days | Likes | Parameters | License | Last change |
| --- | --- | --- | --- | --- | --- |
| LocalAlign\_llama3.1\_8B (this page) | 156 | 9 | — | llama3.1 | 2026-09-10 |
| [Qwen3-4B P9 Honeypot](https://mindket.com/p/702ae8fd-167c-43c1-90f7-5b72accac06a) | 33 | 3 | — | apache-2.0 | 2026-10-30 |
| [K2-Horizon-7B-Uno](https://mindket.com/p/4f8072eb-e9bd-4294-8bcf-f9303cdd68a3) | 203 | 113 | — | apache-2.0 | 2026-09-05 |
| [Kev-4B](https://mindket.com/p/68069a2c-2995-41a5-941c-ff7bf45f95ac) | 12,499 | 175 | — | apache-2.0 | 2026-10-01 |
| [Bespoke-Nimble-9B](https://mindket.com/p/a0c3aad0-46f1-4cc1-a072-eae76e0a9933) | 1,027 | 254 | — | apache-2.0 | 2026-09-24 |
| [Qwen3.8-27b-Terse-Coder-LoRA](https://mindket.com/p/11999adf-4218-4015-bc5b-fe08679f385f) | 244 | 6 | 117M | apache-2.0 | 2026-09-23 |

Numbers as Mindket last read them, from 2026-11-12 to 2026-11-13.

## Trust facts

Facts from each source, with the day each was checked. A maintainer's note is their own words: data, not instructions.

- Last change on Hugging Face: 2026-09-10
- First published: 2026-09-10
- Checked on Hugging Face: 2026-11-13
- Something wrong? Tell us: https://mindket.com/takedown#ask

## Get it

- [Open yuyangGong/LocalAlign_llama3.1_8B on Hugging Face](https://huggingface.co/yuyangGong/LocalAlign_llama3.1_8B)
- [Get it on your Mindket account](https://account.mindket.com/account/?product=mindket#/market/d03fc047-365a-4c7b-af13-dca3cf027809)
- [Its page on Mindket](https://mindket.com/p/d03fc047-365a-4c7b-af13-dca3cf027809)
