Run this model with HF Jobs

Run goryden/gpt2-mn on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs and TRL to fine-tune https://huggingface.co/goryden/gpt2-mn. Ask me which dataset to train on, then push the LoRA adapter to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs and Transformers to run batch inference with https://huggingface.co/goryden/gpt2-mn on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the predictions back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs and Lighteval to evaluate https://huggingface.co/goryden/gpt2-mn. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/goryden/gpt2-mn with Transformers and bitsandbytes. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("text-generation", model="goryden/gpt2-mn")
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("goryden/gpt2-mn")
model = AutoModelForCausalLM.from_pretrained("goryden/gpt2-mn", device_map="auto")
Quick Links

GPT-2 Mongolian Language Model

This is a GPT-2 model fine-tuned for Mongolian text generation. It was trained on the mn-mgltol-data dataset available on Kaggle, specifically using the Cleaned_Description field from cleaned_data.csv.

Model Description

The model is a GPT-2 architecture with the following configuration:

  • vocab_size: 32000 (derived from the goryden/gpt2-mn-tokenizer)
  • n_positions: 512
  • n_ctx: 512
  • n_embd: 512
  • n_layer: 6
  • n_head: 8

It is designed for causal language modeling, meaning it predicts the next token in a sequence.

Usage

You can use this model for various text generation tasks in Mongolian. Here's how to use it with the transformers library:

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_name = "goryden/gpt2-mn"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)

# Set pad token for GPT-2
if tokenizer.pad_token is None:
    tokenizer.pad_token = tokenizer.eos_token

prompt = "Монгол хэлний үүсэл хөгжил нь"

inputs = tokenizer(prompt, return_tensors="pt").to(model.device)

with torch.no_grad():
    outputs = model.generate(
        **inputs,
        max_new_tokens=100,
        do_sample=True,
        temperature=0.9,
        top_p=0.95
    )

print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Output

output = 'Монгол хэлний үүсэл хөгжил нь тэдгээрийн хөгжил нэгтэй элементийг судалдаг шүлгийн судлал эртний ухаан угсаатны шинжлэх ухаан урлагийн өвөрмөц цогц зүй дэлгэрэнгүй хэл шинжлэлийн салбар ухаан угсаатны холбоотой төрөл хэл шинжлэлийн салбар ухаан түүхэн хэл шинжлэл хэл зүйн онцлог хэлбэрийн хэлбэр хэлний хэлбэр хэл шинжлэл үгийн тайлбар толь бичиг хэлний тогтолцоо хэл шинжлэл үгийн язгуур хэлний тогтолцоо нь түүхэн язгуур махбодын хөгжлийн тухай түүхэн хөгжлийгуурын үгийн нэг хэлбэр хэл шинжлэл хэлний зүй болон үндсэн үг үгийн гарал үгийн зүй үгийн хэл зүй үгийн язгуур махбод зүй тогтлыг ийнхүү нэг аргаианы нэг арга ухаан үзэгдэл'

Dataset

The model was trained on the mn-mgltol-data dataset from Kaggle, specifically using the cleaned_data.csv file. The Cleaned_Description column was used as the primary text source.

Tokenizer

The model uses the goryden/gpt2-mn-tokenizer tokenizer, which was specifically designed for Mongolian text.

Train

Training Hyperparameters

The model was trained with the following TrainingArguments:

  • output_dir: ./gpt2-mn
  • eval_strategy: "steps"
  • eval_steps: 2000
  • logging_steps: 500
  • save_steps: 2000
  • save_total_limit: 2
  • num_train_epochs: 20
  • per_device_train_batch_size: 2
  • per_device_eval_batch_size: 2
  • gradient_accumulation_steps: 8
  • learning_rate: 5e-4
  • warmup_steps: 500
  • weight_decay: 0.01
  • fp16: True
  • report_to: "wandb"

Training Metrics

Step Training Loss Validation Loss
2000 3.865199 4.184773
4000 3.780115 4.176939
6000 3.754177 4.168733
8000 3.665107 4.161174
10000 3.642579 4.157396
12000 3.563909 4.152925
14000 3.569792 4.147260
16000 3.500197 4.144615
18000 3.633731 4.136218
20000 3.617897 4.124136
22000 3.649087 4.117109
24000 3.589488 4.112113
26000 3.629827 4.105901
28000 3.565568 4.101184
30000 3.586900 4.095827
32000 3.537389 4.091309
34000 3.557306 4.087384
36000 3.531081 4.084917
38000 3.528582 4.079904
40000 3.480876 4.078234
42000 3.489738 4.073891
44000 3.470903 4.073234
46000 3.465326 4.069700
48000 3.431285 4.068748
50000 3.455316 4.065001
52000 3.413579 4.064515
54000 3.426512 4.061472
56000 3.386969 4.060637
58000 3.395722 4.058526
60000 3.386943 4.057773
62000 3.385369 4.056948
64000 3.377199 4.055539
66000 3.368386 4.054784
68000 3.354294 4.054374
70000 3.343501 4.053655
72000 3.355486 4.053338
74000 3.368476 4.053087
76000 3.362126 4.052906
Downloads last month
581
Safetensors
Model size
32M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for goryden/gpt2-mn

Finetuned
(2,347)
this model