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")# 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
Update README.md
Browse files
README.md
CHANGED
|
@@ -37,10 +37,13 @@ model = AutoModelForCausalLM.from_pretrained("KennethTM/gpt2-small-danish")
|
|
| 37 |
|
| 38 |
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.
|
| 39 |
|
| 40 |
-
The model
|
| 41 |
|
| 42 |
Initially, only the word token embeddings are trained using 50.000 samples. Finally, the whole model is trained using 1.000.000 samples.
|
| 43 |
|
|
|
|
|
|
|
|
|
|
| 44 |
Model training is carried out on an 8 GB GPU.
|
| 45 |
|
| 46 |
# Notes
|
|
|
|
| 37 |
|
| 38 |
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.
|
| 39 |
|
| 40 |
+
The model weights are initialized 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).
|
| 41 |
|
| 42 |
Initially, only the word token embeddings are trained using 50.000 samples. Finally, the whole model is trained using 1.000.000 samples.
|
| 43 |
|
| 44 |
+
For reference, the model achieves a perplexity of 33.5 on 5.000 random validation samples.
|
| 45 |
+
|
| 46 |
+
|
| 47 |
Model training is carried out on an 8 GB GPU.
|
| 48 |
|
| 49 |
# Notes
|