Coder Social home page Coder Social logo

fewshotgen's Introduction

fewshot generation

This repository is for few-shot text generation research;

Task Description

Given a handful of training samples, we explore to maximize the adaption performance for CausalLM task.
Specificlly, we use GPT-2 as backbone model and predict next 40 tokens given the previous 200 tokens. We also take the following practical requirements into consideration:

  1. Parameter-efficiency
  2. Generalization ability to any new domain
  3. Stability in change of shotnums

Usage

prepare data

Unzip data.zip to repository main directory.
We provide corpus from 5 different domains: gongwen, international news, peotry, sports news, and short stories.

enviroments

pip install -r requirements.txt

train model

python train.py --shotnum $shotnum --domain $domain --adaption_type $adaption_type
And the model will be saved to save/ directory by default.

test model

python test.py --shotnum $shotnum --domain $domain --adaption_type $adaption_type
And the prediction file will be saved to pred/ directory by default.

command arguments

$shotnum: number of examples, possible values: {0,4,8,16,32,64,128};
$domain: domain of adaption, {'gongwen', 'international', 'peotry', 'sports', 'story'};
$adaption_type: 'finetune', 'adapter', 'lora', or 'retrieval'; indicate methods of adpation to target domain;

  • 'finetune': Traditional full-parameter adaption;
  • 'adapter': Parameter-efficient tuning by adding parameter blocks, paper: https://arxiv.org/pdf/1902.00751.pdf;
  • 'lora': Parameter-efficient tuning by adding low-rank matrics, paper: https://arxiv.org/pdf/2106.09685.pdf;
  • 'retrieval': Input encodings of retrieved passages as reference. Training with this settings will add cross-attention blocks and freeze other parameters. The result should be a domain-agnostic LM with ability to consult given passages.

Results

BLEU

bleu

BERTScore

bertscore

Rouge-2

rouge-2

fewshotgen's People

Contributors

h-guo18 avatar yangjianxin1 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.