Instructions to use KennethTM/gpt2-small-danish with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use KennethTM/gpt2-small-danish with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="KennethTM/gpt2-small-danish")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("KennethTM/gpt2-small-danish") model = AutoModelForCausalLM.from_pretrained("KennethTM/gpt2-small-danish", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use KennethTM/gpt2-small-danish with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "KennethTM/gpt2-small-danish" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "KennethTM/gpt2-small-danish", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/KennethTM/gpt2-small-danish
- SGLang
How to use KennethTM/gpt2-small-danish 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 "KennethTM/gpt2-small-danish" \ --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": "KennethTM/gpt2-small-danish", "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 "KennethTM/gpt2-small-danish" \ --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": "KennethTM/gpt2-small-danish", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use KennethTM/gpt2-small-danish with Docker Model Runner:
docker model run hf.co/KennethTM/gpt2-small-danish
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
datasets:
|
| 3 |
+
- oscar
|
| 4 |
+
language:
|
| 5 |
+
- da
|
| 6 |
+
widget:
|
| 7 |
+
- text: Der var engang
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# What is this?
|
| 11 |
+
|
| 12 |
+
GPT-2 model (small version, 124 M parameters) for Danish text generation.
|
| 13 |
+
|
| 14 |
+
# Model training
|
| 15 |
+
|
| 16 |
+
The model is trained using the Danish part of the [oscar dataset](https://huggingface.co/datasets/oscar) ('unshuffled_deduplicated_da') and a context length of 1024 tokens.
|
| 17 |
+
|
| 18 |
+
The model is initilized from the English [GPT-2 small model](https://huggingface.co/gpt2) with new word token embeddings created for Danish using [WECHSEL](https://github.com/CPJKU/wechsel).
|
| 19 |
+
|
| 20 |
+
Initially, only the word token embeddings are trained using 50.000 samples. Finally, the whole model is trained using 1.000.000 samples.
|
| 21 |
+
|
| 22 |
+
Model training is carried out on a 8 GB GPU.
|
| 23 |
+
|
| 24 |
+
# Notes
|
| 25 |
+
|
| 26 |
+
This is a pre-trained model, for optimal performance it should be finetuned for new tasks.
|