ViGPT2 AIO is a Vietnamese GPT-2 style causal language model pretrained for open-ended text generation and general Vietnamese language modeling.
This model was developed to support teaching and hands-on practice in the AIO course, while also serving as a general Vietnamese pretrained language model for experimentation and downstream adaptation.
The model was pretrained on a mixture of Vietnamese news and Vietnamese Wikipedia text.
bkai-foundation-models/BKAINewsCorpusBefore pretraining, the corpora were cleaned and deduplicated.
bkai_train.parquetvi_wiki_articles_clean.parquetThe pretraining mixture used:
bkai_train.parquet with weight 1vi_wiki_articles_clean.parquet with weight 3The model was pretrained with a standard causal language modeling objective, where the model learns to predict the next token in a sequence.
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
repo_id = "VLAI-AIVN/vigpt2-aio"
tokenizer = AutoTokenizer.from_pretrained(repo_id)
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token
model = AutoModelForCausalLM.from_pretrained(repo_id)
model.config.pad_token_id = tokenizer.pad_token_id
device = "cuda" if torch.cuda.is_available() else "cpu"
model = model.to(device).eval()
prompt = "Việt Nam là một đất nước"
inputs = tokenizer(prompt, return_tensors="pt").to(device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=80,
do_sample=True,
temperature=0.8,
top_p=0.9,
repetition_penalty=1.1,
pad_token_id=tokenizer.pad_token_id,
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
model.safetensors 498 MBtraining_args.bin 5.8 kB