Views
No views yet
1import torch
2from transformers import GPT2Tokenizer, GPT2LMHeadModel
3
4# Load pretrained model and tokenizer
5model = GPT2LMHeadModel.from_pretrained("antoiloui/belgpt2")
6tokenizer = GPT2Tokenizer.from_pretrained("antoiloui/belgpt2")
7
8# Generate a sample of text
9model.eval()
10output = model.generate(
11 bos_token_id=random.randint(1,50000),
12 do_sample=True,
13 top_k=50,
14 max_length=100,
15 top_p=0.95,
16 num_return_sequences=1
17)
18
19# Decode it
20decoded_output = []
21for sample in output:
22 decoded_output.append(tokenizer.decode(sample, skip_special_tokens=True))
23print(decoded_output)| Dataset | $corpus_name | Raw size | Cleaned size |
|---|---|---|---|
| CommonCrawl | common_crawl | 200.2 GB | 40.4 GB |
| NewsCrawl | news_crawl | 10.4 GB | 9.8 GB |
| Wikipedia | wiki | 19.4 GB | 4.1 GB |
| Wikisource | wikisource | 4.6 GB | 2.3 GB |
| Project Gutenberg | gutenberg | 1.3 GB | 1.1 GB |
| EuroParl | europarl | 289.9 MB | 278.7 MB |
| NewsCommentary | news_commentary | 61.4 MB | 58.1 MB |
| Total | 236.3 GB | 57.9 GB |
@misc{louis2020belgpt2,
author = {Louis, Antoine},
title = {{BelGPT-2: A GPT-2 Model Pre-trained on French Corpora}},
year = {2020},
howpublished = {\url{https://github.com/ant-louis/belgpt2}},
}