skills/nlp/structured-prompt-formatting/SKILL.md
Format multi-field tabular data into a structured natural language prompt with labeled sections for encoder or LLM classification
npx skillsauth add wenmin-wu/ds-skills nlp-structured-prompt-formattingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
When input data has multiple fields (question, answer, explanation, metadata), concatenate them into a structured text prompt with labeled sections. This converts tabular rows into natural language that encoder models (BERT, DeBERTa) or LLMs (Gemma, Qwen) can process. Field labels act as implicit attention anchors, helping the model parse structure.
def format_prompt(row, fields, separator='\n'):
"""Format a row of data into a labeled text prompt.
Args:
row: dict-like row (DataFrame row, dict)
fields: list of (label, column_name) tuples
separator: delimiter between fields
"""
parts = []
for label, col in fields:
value = row[col]
if isinstance(value, bool):
value = "Yes" if value else "No"
parts.append(f"{label}: {value}")
return separator.join(parts)
# Define field mapping
fields = [
("Question", "QuestionText"),
("Answer", "MC_Answer"),
("Correct", "is_correct"),
("Student Explanation", "StudentExplanation"),
]
df['text'] = df.apply(lambda row: format_prompt(row, fields), axis=1)
# Output: "Question: What is 2+2?\nAnswer: 5\nCorrect: No\nStudent Explanation: ..."
data-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF