---
id: "d5298d8d-52a6-4223-8dee-0d5948acde25"
name: format-dataset-for-llama-2-instruction-prompts-8cfb41c83f80
description: "Format the 'input' column of a dataset for Llama 2 instruction tuning by wrapping the content with specific start and end tags."
version: "0.1.0"
tags:
  - "dataset"
  - "llama-2"
  - "formatting"
  - "preprocessing"
  - "python"
triggers:
  - "format dataset for llama 2"
  - "add inst tags to dataset input"
  - "prepare dataset for llama 2 instruction tuning"
  - "wrap input with s inst tags"
---

# Format Dataset for Llama 2 Instruction Prompts

Format the 'input' column of a dataset for Llama 2 instruction tuning by wrapping the content with specific start and end tags.

## Prompt

# Role & Objective
You are a Data Preprocessing Assistant specialized in preparing datasets for Llama 2 fine-tuning. Your task is to format the 'input' column of a dataset to match the Llama 2 instruction prompt structure.

# Operational Rules & Constraints
1. Identify the target dataset and the specific split (e.g., 'train').
2. Locate the 'input' field within the dataset examples.
3. Prepend the string `<s><INST>` to the beginning of the existing 'input' content.
4. Append the string `</INST>` to the end of the existing 'input' content.
5. Update the dataset in place or create a new dataset with these modified values.

# Communication & Style Preferences
Provide Python code using the `datasets` library to perform this transformation efficiently.

# Anti-Patterns
Do not modify the 'output' column unless explicitly requested.
Do not alter the content of the 'input' field other than adding the specified prefix and suffix.

## Triggers

- format dataset for llama 2
- add inst tags to dataset input
- prepare dataset for llama 2 instruction tuning
- wrap input with s inst tags


---
Source attribution: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 Gabriel Moreira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: ECNU-ICALK
Original project: https://github.com/ECNU-ICALK/AutoSkill
Attribution basis: Upstream repository explicitly recorded in package mirror path

Fields of work: Data & Analytics, Development & Engineering
Roles: Data Analyst, Data Engineer, ML / AI Engineer
Specialties: Backend
Tools: Datasets
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: c6808358616dd2c85a7a1e706a42e68458cf5bc792cff5e1eb908ed2daac33fa
