Skip to content
Back to skills

Prompt Text Concatenation

ASecurity

Prepends prompt question or full prompt text to input with SEP token for context-aware text evaluation.

  • 61 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 12, 2026
developmentpython

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add wenmin-wu/ds-skills --skill prompt-text-concatenation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Prompt Text Concatenation?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Prompt Text Concatenation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wenmin-wu-prompt-text-concatenation/badge)](https://www.skillsdirectory.com/skills/wenmin-wu-prompt-text-concatenation)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: nlp-prompt-text-concatenation
description: >
  Prepends prompt question or full prompt text to input with SEP token for context-aware text evaluation.
---
# Prompt-Text Concatenation

## Overview

When evaluating text quality relative to a prompt (e.g., "how well does this summary capture the source?"), prepend the prompt question or full prompt text to the input, separated by the tokenizer's SEP token. This gives the transformer explicit context about what the text should contain.

## Quick Start

```python
def build_input(row, tokenizer, add_question=True, add_prompt=False):
    parts = []
    if add_question:
        parts.append(row["prompt_question"])
    if add_prompt:
        parts.append(row["prompt_text"])
    parts.append(row["text"])

    sep = f" {tokenizer.sep_token} "
    return sep.join(parts)

# Tokenize with combined input
df["input_text"] = df.apply(lambda r: build_input(r, tokenizer), axis=1)
encodings = tokenizer(df["input_text"].tolist(), truncation=True, max_length=512)
```

## Workflow

1. Decide what context to prepend: question only, full prompt, or both
2. Join with tokenizer's SEP token (not a raw separator)
3. Tokenize the combined string with truncation
4. The model sees prompt context → can judge relevance, not just quality

## Key Decisions

- **Question vs full prompt**: Question is shorter, less truncation risk; full prompt gives richer context
- **SEP token**: Use the model's native separator for proper segment handling
- **Truncation**: Long prompts may push out the actual text — consider head-tail truncation
- **When to use**: Any task where quality is relative to a reference or instruction

## References

- CommonLit - Evaluate Student Summaries (Kaggle)
- Source: [infer-2x-t4](https://www.kaggle.com/code/nbroad/infer-2x-t4)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.