Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for GPT-2 #644

Closed
wants to merge 4 commits into from
Closed

Support for GPT-2 #644

wants to merge 4 commits into from

Conversation

Bycob
Copy link
Collaborator

@Bycob Bycob commented Sep 24, 2019

  • GPT-2 next token prediction
  • GPT-2 finetuning on a custom dataset
  • Script to generate text with successive predict calls

@beniz beniz changed the base branch from master to bert_training September 27, 2019 12:38
@Bycob
Copy link
Collaborator Author

Bycob commented Sep 27, 2019

Example: trace gpt2 and run it with the demo

Run dede, then

mkdir gpt2_repo
cd tools/torch/
./trace_pytorch_transformers.py gpt2 -vo ../../gpt2_repo --vocab
cd ../../demo/gpt2
python3 -m run_gpt2 --r ../../gpt2_repo/ --host localhost --port 8080 --input-size 512 --topk 40

Example: call gpt2 inference with curl

curl -X PUT "http://10.10.77.61:8501/services/torch_gpt2" -d '{
    "description": "GPT2 service",
    "mllib": "torch",
    "model": {
        "repository": "/opt/models/gpt2"
    },
    "parameters": {
        "input": {
            "connector": "txt",
            "ordered_words": true,
            "wordpiece_tokens": true,
            "punctuation_tokens": true,
            "lower_case": false,
            "width":512,
            "word_start":"Ġ",
            "suffix_start":""
        },
        "mllib": {
            "template":"gpt2",
            "gpu": true
        }
    },
    "type": "supervised"
}
' | jq
echo "\n"
curl -X POST "http://10.10.77.61:8501/predict" -d '{
    "service": "torch_gpt2",
    "parameters": {
        "input": {
        },
        "output": {
            "best":3
        }
    },
    "data": ["Why did the chicken cross the"]
}
' | jq

Example: finetuning gpt2

<!> Test takes a lot of time and memory -- requires f1 sparse

curl -X PUT "http://10.10.77.61:8501/services/gpt2" -d '{
    "description": "gpt2 training",
    "mllib": "torch",
    "model": {
        "repository": "/data1/louisj/gpt2_news20/"
    },
    "parameters": {
        "input": {
            "connector": "txt",
            "ordered_words": true,
            "wordpiece_tokens": true,
            "punctuation_tokens": true,
            "lower_case": false,
            "width":256
        },
        "mllib": {
            "template":"gpt2",
            "finetuning": true,
            "gpu": true
        }
    },
    "type": "supervised"
}
' | jq
echo "\n"
curl -X POST "http://10.10.77.61:8501/train" -d '{
    "service": "gpt2",
    "parameters": {
        "mllib": {
            "solver":{
                "iterations": 3000,
                "test_interval":250,
                "base_lr":1e-3,
                "iter_size":8,
                "save_period":250,
                "solver_type":"ADAM"
            },
            "net":{
                "test_batch_size":1,
                "batch_size":4
            }
        },
        "input": {
            "shuffle":true,
            "word_start":"Ġ",
            "suffix_start":""
        },
        "output": {
            "measure":["f1", "mcll", "acc", "cmdiag", "cmfull"]
        }
    },
    "data":["/home/louisj/dede/data/news20/train/"]
}
' | jq

@beniz beniz changed the title Support of GPT-2 Support for GPT-2 Nov 25, 2019
@fantes fantes closed this Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants