初始化项目,由ModelHub XC社区提供模型
Model: flax-community/gpt-2-spanish Source: Original Platform
This commit is contained in:
18
.gitattributes
vendored
Normal file
18
.gitattributes
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tar.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.model filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
model.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||||
0
.run.sh.swp
Normal file
0
.run.sh.swp
Normal file
43
README.md
Normal file
43
README.md
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
---
|
||||||
|
language: es
|
||||||
|
tags:
|
||||||
|
- text-generation
|
||||||
|
datasets:
|
||||||
|
- oscar
|
||||||
|
widgets:
|
||||||
|
- text: 'Érase un vez '
|
||||||
|
- text: >-
|
||||||
|
Frase: Esta película es muy agradable. Sentimiento: positivo Frase: Odiaba
|
||||||
|
esta película, apesta. Sentimiento: negativo Frase: Esta película fue
|
||||||
|
bastante mala. Sentimiento:
|
||||||
|
license: apache-2.0
|
||||||
|
---
|
||||||
|
|
||||||
|
# Spanish GPT-2
|
||||||
|
|
||||||
|
GPT-2 model trained from scratch on the Spanish portion of [OSCAR](https://huggingface.co/datasets/viewer/?dataset=oscar).
|
||||||
|
The model is trained with Flax and using TPUs sponsored by Google since this is part of the
|
||||||
|
[Flax/Jax Community Week](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104)
|
||||||
|
organised by HuggingFace.
|
||||||
|
|
||||||
|
## Model description
|
||||||
|
|
||||||
|
The model used for training is [OpenAI's GPT-2](https://openai.com/blog/better-language-models/), introduced in the paper ["Language Models are Unsupervised Multitask Learners"](https://d4mucfpksywv.cloudfront.net/better-language-models/language_models_are_unsupervised_multitask_learners.pdf) by Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei and Ilya Sutskever.
|
||||||
|
|
||||||
|
This model is available in the 🤗 [Model Hub](https://huggingface.co/gpt2).
|
||||||
|
|
||||||
|
## Training data
|
||||||
|
|
||||||
|
Spanish portion of OSCAR or **O**pen **S**uper-large **C**rawled **A**LMAnaCH co**R**pus, a huge multilingual corpus obtained by language classification and filtering of the [Common Crawl](https://commoncrawl.org/) corpus using the [goclassy](https://github.com/pjox/goclassy) architecture.
|
||||||
|
|
||||||
|
This corpus is available in the 🤗 [Datasets](https://huggingface.co/datasets/oscar) library.
|
||||||
|
|
||||||
|
## Team members
|
||||||
|
- Manuel Romero ([mrm8488](https://huggingface.co/mrm8488))
|
||||||
|
- María Grandury ([mariagrandury](https://huggingface.co/mariagrandury))
|
||||||
|
- Pablo González de Prado ([Pablogps](https://huggingface.co/Pablogps))
|
||||||
|
- Daniel Vera ([daveni](https://huggingface.co/daveni))
|
||||||
|
- Sri Lakshmi ([srisweet](https://huggingface.co/srisweet))
|
||||||
|
- José Posada ([jdposa](https://huggingface.co/jdposa))
|
||||||
|
- Santiago Hincapie ([shpotes](https://huggingface.co/shpotes))
|
||||||
|
- Jorge ([jorgealro](https://huggingface.co/jorgealro))
|
||||||
36
config.json
Normal file
36
config.json
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"activation_function": "gelu_new",
|
||||||
|
"architectures": [
|
||||||
|
"GPT2LMHeadModel"
|
||||||
|
],
|
||||||
|
"attn_pdrop": 0.0,
|
||||||
|
"bos_token_id": 50256,
|
||||||
|
"embd_pdrop": 0.0,
|
||||||
|
"eos_token_id": 50256,
|
||||||
|
"gradient_checkpointing": false,
|
||||||
|
"initializer_range": 0.02,
|
||||||
|
"layer_norm_epsilon": 1e-05,
|
||||||
|
"model_type": "gpt2",
|
||||||
|
"n_ctx": 1024,
|
||||||
|
"n_embd": 768,
|
||||||
|
"n_head": 12,
|
||||||
|
"n_inner": null,
|
||||||
|
"n_layer": 12,
|
||||||
|
"n_positions": 1024,
|
||||||
|
"resid_pdrop": 0.0,
|
||||||
|
"scale_attn_weights": true,
|
||||||
|
"summary_activation": null,
|
||||||
|
"summary_first_dropout": 0.1,
|
||||||
|
"summary_proj_to_labels": true,
|
||||||
|
"summary_type": "cls_index",
|
||||||
|
"summary_use_proj": true,
|
||||||
|
"task_specific_params": {
|
||||||
|
"text-generation": {
|
||||||
|
"do_sample": true,
|
||||||
|
"max_length": 50
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"transformers_version": "4.9.0.dev0",
|
||||||
|
"use_cache": true,
|
||||||
|
"vocab_size": 50257
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:7f5a6cef1983c8dcbf34fc6d98bc192078bb1949efeea81672ee0edcf125fbd7
|
||||||
|
size 367772
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:f0c3cf7a5e63d4a77d3e7d14b72a3f38a9e604efcb0e78faa3ece56e96707932
|
||||||
|
size 735617
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:116109fbd23b28c6a4dc9ea828729181901502ced8d7c20ce220b9438ddc4341
|
||||||
|
size 73496
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:e8d395a87948d65cb9d66207f2321ec9b3cfa06afe2d800d2b246fb3aa6385eb
|
||||||
|
size 11003489
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:a13db211fb1e8fcab57645f6987bab32b307ade0e149d5954194e5e433200c12
|
||||||
|
size 1397738
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:0224f764bf692ac3bd6d6b158147621d510be7926328ca69c4b91c71846e0442
|
||||||
|
size 1397738
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:49d618c3b6ece936a9e3ae7cfcf162166289a2ad3729a48abf2dd46ac0728b02
|
||||||
|
size 40
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:ee72a372d2f2bbe5ab9a307269cabc0e6d36909d6096ad5dbb58c546c57ad9d5
|
||||||
|
size 11059767
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:7e852c812c8c31772be718e7995671cc231b73689899ca307c67d834e1537a51
|
||||||
|
size 14749
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:d91156cf42fec78270c1a1bad4c3e771c71ddc50987c79fc26604691ed4ac2bc
|
||||||
|
size 9293307
|
||||||
3
flax_model.msgpack
Normal file
3
flax_model.msgpack
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:f5e3bd9282196a12dd5de77e69d8b231f6077e9dbe237586ad6d349fa544e281
|
||||||
|
size 497764120
|
||||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:31ce24d2db59bcc5a7b715591334f4762d4ea58e3efb595d126c80a94cff8cd7
|
||||||
|
size 510359598
|
||||||
3
pytorch_model.bin
Normal file
3
pytorch_model.bin
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:e56fb07dd88794a4374ebafa12178489cfeb4a1f029d2ed0337bc3c1268d71ca
|
||||||
|
size 510401385
|
||||||
23
run.sh
Executable file
23
run.sh
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
./run_clm_flax.py \
|
||||||
|
--output_dir="./" \
|
||||||
|
--model_type="gpt2" \
|
||||||
|
--model_name_or_path="./" \
|
||||||
|
--config_name="./" \
|
||||||
|
--tokenizer_name="./" \
|
||||||
|
--dataset_name="oscar" \
|
||||||
|
--dataset_config_name="unshuffled_deduplicated_es" \
|
||||||
|
--do_train \
|
||||||
|
--do_eval \
|
||||||
|
--block_size="512" \
|
||||||
|
--per_device_train_batch_size="64" \
|
||||||
|
--per_device_eval_batch_size="64" \
|
||||||
|
--adafactor \
|
||||||
|
--learning_rate="3e-3" --warmup_steps="1000" \
|
||||||
|
--adam_beta1="0.9" --adam_beta2="0.98" --weight_decay="0.001" \
|
||||||
|
--overwrite_output_dir \
|
||||||
|
--num_train_epochs="20" \
|
||||||
|
--logging_steps="100" \
|
||||||
|
--save_steps="2500" \
|
||||||
|
--eval_steps="1000000" \
|
||||||
|
--preprocessing_num_workers="64"
|
||||||
|
|
||||||
1
run_clm_flax.py
Symbolic link
1
run_clm_flax.py
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../examples/flax/language-modeling/run_clm_flax.py
|
||||||
1
tokenizer.json
Normal file
1
tokenizer.json
Normal file
File diff suppressed because one or more lines are too long
20
train_tokenizer.py
Executable file
20
train_tokenizer.py
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from datasets import load_dataset
|
||||||
|
from tokenizers import ByteLevelBPETokenizer
|
||||||
|
# load dataset
|
||||||
|
dataset = load_dataset("oscar", "unshuffled_deduplicated_es", split="train")
|
||||||
|
# Instantiate tokenizer
|
||||||
|
tokenizer = ByteLevelBPETokenizer()
|
||||||
|
def batch_iterator(batch_size=10000):
|
||||||
|
for i in range(0, len(dataset), batch_size):
|
||||||
|
yield dataset[i: i + batch_size]["text"]
|
||||||
|
# Customized training
|
||||||
|
tokenizer.train_from_iterator(batch_iterator(), vocab_size=50265, min_frequency=2, special_tokens=[
|
||||||
|
"<s>",
|
||||||
|
"<pad>",
|
||||||
|
"</s>",
|
||||||
|
"<unk>",
|
||||||
|
"<mask>",
|
||||||
|
])
|
||||||
|
# Save files to disk
|
||||||
|
tokenizer.save("./tokenizer.json")
|
||||||
Reference in New Issue
Block a user