Skills-in-Context Prompting: Unlocking Compositionality in Large Language Models

Jiaao Chen, Xiaoman Pan, Dian Yu, Kaiqiang Song, Xiaoyang Wang, Dong Yu, Jianshu Chen · DOI

Abstract

Large Language Models (LLMs) often struggle with compositional generalization—the ability to combine basic skills to solve complex, multi-step problems that exceed the complexity of their training examples. This paper introduces Skills-in-Context (SKiC), a prompting framework that explicitly defines foundational skills and requires models to ground their reasoning steps in these skills. Experimental results demonstrate that SKiC significantly outperforms Chain-of-Thought (CoT) prompting on symbolic manipulation, arithmetic, and competition-level mathematics. Notably, SKiC enables "weak-to-strong" generalization and unlocks latent internal knowledge that models possess but fail to utilize through standard prompting methods.

Introduction

While LLMs exhibit remarkable reasoning capabilities, their performance often degrades when faced with tasks requiring high levels of composition. For instance, a model may successfully concatenate the last letters of two words but fail when the task scales to twenty words. This failure in compositional generalization suggests that existing strategies, such as Chain-of-Thought (CoT) or Least-to-Most prompting, do not sufficiently guide the model in systematically applying its foundational knowledge to increasingly complex structures.

Researchers from Tencent AI Lab address this gap with Skills-in-Context (SKiC). The core hypothesis is that by explicitly grounding reasoning steps in a predefined set of foundational skills, LLMs can maintain logical consistency and accuracy even as problem complexity scales far beyond the examples provided in the prompt.

The SKiC Framework

SKiC is a one-stage prompting strategy structured into three distinct components:

  1. Foundational Skills: A concise list of basic operations or concepts required for the task (e.g., "How to extract the last letter of a word" or "How to perform a single-digit carry").
  2. Compositional Exemplars: A small set of few-shot examples (typically two) that demonstrate how to solve a problem by explicitly naming and applying the foundational skills. The model is prompted to use the syntax: "Using the Skill [X], I do [Y]."
  3. The Test Question: The target complex problem to be solved.

This "explicit grounding" serves as a structural anchor, preventing the model from losing track of the logic during long-form reasoning. Furthermore, these skills can be either manually defined by humans or automatically "distilled" by the LLM itself by analyzing a set of training examples to identify the underlying primitives required for a solution.

Experimental Evaluation

The researchers evaluated SKiC across a diverse array of benchmarks designed to test different facets of reasoning:

  • Symbolic and Arithmetic Scaling: Tasks like last-letter concatenation and multi-digit multiplication, where test cases were significantly longer or larger than the prompt examples.
  • Complex Reasoning: CommaQA-E (multi-hop QA) and Dynamic Programming (DP) problems.
  • Mathematical Problem Solving: GSM8K (grade school level) and the challenging MATH benchmark (competition level).
  • Semantic Parsing: SCAN and RTE datasets for natural language inference.

Key Insights

1. Robustness to Complexity

Unlike CoT, which shows a sharp decline in accuracy as problem length increases, SKiC maintains near-perfect performance. In a 12-word last-letter concatenation task, ChatGPT using 4-shot CoT achieved only ~10% accuracy, whereas 2-shot SKiC achieved 100%. This suggests that SKiC effectively teaches the model the logic of composition rather than just pattern matching.

2. Unlocking Latent Knowledge

A significant discovery was SKiC's ability to activate "internal skills." In the MATH benchmark, models began utilizing advanced theorems (e.g., Heron’s Formula) that were not present in the prompt. By providing a structured framework for skill application, SKiC encourages the model to search its internal weights for relevant tools. In GPT-4 trials, approximately 24% of the skills utilized were retrieved internally rather than from the prompt text.

3. Weak-to-Strong Generalization

The study found that fine-tuning models on SKiC-formatted data allows for significant performance gains on harder tasks. A Llama-2 model fine-tuned on simple GSM8K problems using SKiC showed substantially better performance on the more difficult MATH dataset compared to a model fine-tuned with standard CoT. This indicates that learning the meta-skill of composition is more transferable than learning specific task solutions.

Results and Performance

SKiC demonstrated superior performance across nearly all tested domains:

  • MATH Benchmark: Improved ChatGPT’s accuracy from 34.1% (ComplexCoT) to 40.6%.
  • Symbolic Tasks: Achieved nearly 100% accuracy on symbolic manipulation and arithmetic even when scaling test cases to 100 words or 7-digit numbers.
  • Cross-Task Transfer: Prompts designed for basic math (GSM8K) were found to improve performance on logical inference tasks (FOLIO), highlighting the generalizability of the skill-composition mindset.

Conclusion and Future Work

Skills-in-Context prompting provides a robust mechanism for improving the compositional generalization of LLMs. By explicitly defining and grounding reasoning in foundational skills, SKiC bridges the gap between simple examples and complex real-world problems.

However, limitations remain. The framework's effectiveness is bounded by the model's pre-existing knowledge; SKiC cannot "unlock" a skill the model never learned during pre-training. Additionally, for extremely broad domains, the context window may limit the number of foundational skills that can be listed. Future research may focus on hybrid systems that allow SKiC to compose both internal latent skills and external tools, such as code interpreters or specialized calculators, within a single unified framework.

Summary updated

BibTeX
@misc{chen2023skills,
  author = {Jiaao Chen and Xiaoman Pan and Dian Yu and Kaiqiang Song and Xiaoyang Wang and Dong Yu and Jianshu Chen},
  title = {{Skills-in-Context Prompting: Unlocking Compositionality in Large Language Models}},
  year = {2023},
  eprint = {2308.00304},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2308.00304},
}
Figure