Instructions to use NLPForUA/gpt2-large-uk-title-generation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NLPForUA/gpt2-large-uk-title-generation with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NLPForUA/gpt2-large-uk-title-generation")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("NLPForUA/gpt2-large-uk-title-generation") model = AutoModelForCausalLM.from_pretrained("NLPForUA/gpt2-large-uk-title-generation") - PEFT
How to use NLPForUA/gpt2-large-uk-title-generation with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NLPForUA/gpt2-large-uk-title-generation with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NLPForUA/gpt2-large-uk-title-generation" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NLPForUA/gpt2-large-uk-title-generation", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/NLPForUA/gpt2-large-uk-title-generation
- SGLang
How to use NLPForUA/gpt2-large-uk-title-generation with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "NLPForUA/gpt2-large-uk-title-generation" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NLPForUA/gpt2-large-uk-title-generation", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "NLPForUA/gpt2-large-uk-title-generation" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NLPForUA/gpt2-large-uk-title-generation", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use NLPForUA/gpt2-large-uk-title-generation with Docker Model Runner:
docker model run hf.co/NLPForUA/gpt2-large-uk-title-generation
NLPForUA/gpt2-large-uk-title-generation
📌 Educational release (Lab work)
This model was trained and published as part of an educational lab assignment on news title generation using GPT-2 + LoRA fine-tuning.
The full training notebook (data prep → fine-tuning → evaluation) is available here:
NLPForUA/gpt2-large-uk-title-generation generates Ukrainian-style news headlines from article text.
It is designed for experimenting with prompting, decoding strategies, and parameter-efficient fine-tuning (LoRA).
What this model does
Given a Ukrainian news article (or its first paragraph), the model generates a short candidate title/headline.
Recommended prompt pattern:
- article text
- blank line
Назва:- generation
Model details
- Architecture: GPT-2 Large (decoder-only causal LM)
- Parameters: ~774M (GPT-2 Large class)
- Language: Ukrainian (
uk) - Task: title / headline generation
- Fine-tuning: PEFT LoRA (parameter-efficient adaptation)
Training data
The model was fine-tuned on Ukrainian news articles with associated headlines from:
- Dataset:
FIdo-AI/ua-news
Typical categories include politics, economy, sports, tech, society, etc.
Intended use
✅ Good for
- Headline suggestions for Ukrainian text
- Generating multiple candidate titles for editorial review
- Educational demos of LoRA fine-tuning and decoding
- Dataset prototyping / augmentation (with human filtering)
❌ Not intended for
- Fully automated publishing without a human editor
- High-stakes applications requiring guaranteed factual accuracy
- Legal/medical/safety-critical content generation
Usage (Transformers)
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
model_id = "NLPForUA/gpt2-large-uk-title-generation"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
articles = [
"Уряд України розглядає нові зміни до податкового законодавства. Експерти прогнозують вплив на малий бізнес та ІТ-сектор..."
]
def predict_title(model, inputs: list, postprocess=False, temperature=0.6, max_new_tokens=48) -> list:
outputs = []
with torch.no_grad():
for idx, row in enumerate(inputs):
if (idx+1) % 100 == 0:
print(f"Generated {idx+1} titles\n")
prompt = row + "\n Назва:"
batch = tokenizer([prompt], return_tensors='pt').to(device)
output_tokens = model.generate(
**batch,
max_new_tokens=max_new_tokens,
do_sample=True,
temperature=temperature,
pad_token_id=tokenizer.eos_token_id,
bos_token_id=tokenizer.bos_token_id,
eos_token_id=tokenizer.eos_token_id,
)
output = tokenizer.decode(output_tokens[0], skip_special_tokens=True)
if postprocess:
output = output.split("\n Назва:")[1]
outputs.append(output.strip())
return outputs
predicted_titles = predict_title(model, articles, postprocess=True)
for row in predicted_titles:
print(row, '\n\n')
- Downloads last month
- 46
Model tree for NLPForUA/gpt2-large-uk-title-generation
Base model
benjamin/gpt2-large-wechsel-ukrainian