Few-shot learning codebase for language models, similar to GPT-3
Top 80.3% on sourcepulse
This repository provides a codebase for performing few-shot "in-context" learning with large language models, mirroring the approach of the GPT-3 paper. It enables users to leverage models like GPT-3 (via OpenAI API), GPT-2, and others from HuggingFace Transformers by embedding a few training examples within a natural language prompt to guide predictions.
How It Works
The core mechanism involves constructing natural language prompts that include a small number of labeled examples (shots) for a given task. The language model then generates predictions based on these in-context examples without any gradient updates. The codebase abstracts model interaction through a common API, allowing for easy switching between different language models. It also supports contextual calibration, a technique to improve few-shot performance by adjusting model outputs.
Quick Start & Requirements
conda create -n fewshot python=3.6
, source activate fewshot
) and install dependencies (pip install -r requirements.txt
).openai_key.txt
file with your API key is needed.gpt2-xl
. See Replicating Our Results for details.Highlighted Details
Maintenance & Community
Developed by Tony Z. Zhao and Eric Wallace. Contributions via pull requests and issues are welcome. Contact emails are provided for inquiries.
Licensing & Compatibility
The repository does not explicitly state a license in the README. Users should verify licensing for commercial use or integration with closed-source projects.
Limitations & Caveats
The README notes that after code refactoring, the training sets may differ from those used in the original paper's results table, potentially leading to slight variations in replicated results.
1 year ago
1 week