模型:

birgermoell/swedish-gpt

英文

模型系列

这个模型是在Huggingface Flax/Jax挑战赛期间使用TPU和Flax Jax进行训练的一系列模型中的一部分。

Gpt 模型

瑞典 Gpt

https://huggingface.co/birgermoell/swedish-gpt/

瑞典 gpt 维基百科

https://huggingface.co/flax-community/swe-gpt-wiki

北欧 gpt 维基百科

https://huggingface.co/flax-community/nordic-gpt-wiki

丹麦 gpt 维基百科

https://huggingface.co/flax-community/dansk-gpt-wiki

挪威 gpt 维基百科

https://huggingface.co/flax-community/norsk-gpt-wiki

Roberta 模型

北欧 Roberta 维基百科

https://huggingface.co/flax-community/nordic-roberta-wiki

Swe Roberta 维基百科 Oscar

https://huggingface.co/flax-community/swe-roberta-wiki-oscar

Roberta 瑞典 Scandi

https://huggingface.co/birgermoell/roberta-swedish-scandi

瑞典 Roberta

https://huggingface.co/birgermoell/roberta-swedish

瑞典 T5 模型

https://huggingface.co/birgermoell/t5-base-swedish

GPT-svenska-wikipedia

使用Flax CLM流程基于wiki40b数据集的瑞典部分和Oscar数据集训练的瑞典GPT2风格模型。 https://huggingface.co/datasets/wiki40b

模型训练约为22600个步骤(42小时),作为Huggingface Jax/Flax挑战赛的一部分,使用以下损失和学习率进行Loss: 3.1715331077575684, 学习率: 0.0024816440418362617)

可能可以继续训练模型。

数据清理和预处理

使用以下脚本对数据进行了清理和预处理。确保安装beam_runner的依赖项使数据集正常工作。

from datasets import load_dataset
def load_and_clean_wiki():
    dataset = load_dataset('wiki40b', 'sv', beam_runner='DirectRunner', split="train")
    #dataset = load_dataset('wiki40b', 'sv', beam_runner='DirectRunner')
    dataset = dataset.remove_columns(['wikidata_id', 'version_id'])
    filtered_dataset = dataset.map(filter_wikipedia)
    # filtered_dataset[:3]
    # print(filtered_dataset[:3])
    return filtered_dataset

def filter_wikipedia(batch):
    batch["text"] = " ".join(batch["text"].split("\
_START_SECTION_\
"))
    batch["text"] = " ".join(batch["text"].split("\
_START_ARTICLE_\
"))
    batch["text"] = " ".join(batch["text"].split("\
_START_ARTICLE_\
"))
    batch["text"] = " ".join(batch["text"].split("\
_START_PARAGRAPH_\
"))
    batch["text"] = " ".join(batch["text"].split("_NEWLINE_"))
    batch["text"] = " ".join(batch["text"].split("\xa0"))
    return batch

训练脚本

以下训练脚本用于训练模型。

./run_clm_flax.py     --output_dir="${MODEL_DIR}"     --model_type="gpt2"     --config_name="${MODEL_DIR}"     --tokenizer_name="${MODEL_DIR}"     --dataset_name="wiki40b"     --dataset_config_name="sv"     --do_train --do_eval     --block_size="512"     --per_device_train_batch_size="64"     --per_device_eval_batch_size="64"     --learning_rate="5e-3" --warmup_steps="1000"     --adam_beta1="0.9" --adam_beta2="0.98" --weight_decay="0.01"     --overwrite_output_dir     --num_train_epochs="20"     --logging_steps="500"     --save_steps="1000"     --eval_steps="2500"     --push_to_hub