Instructions to use hakanbogan/gpt2-turkish-cased with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hakanbogan/gpt2-turkish-cased with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="hakanbogan/gpt2-turkish-cased")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("hakanbogan/gpt2-turkish-cased") model = AutoModelForCausalLM.from_pretrained("hakanbogan/gpt2-turkish-cased") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use hakanbogan/gpt2-turkish-cased with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hakanbogan/gpt2-turkish-cased" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hakanbogan/gpt2-turkish-cased", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/hakanbogan/gpt2-turkish-cased
- SGLang
How to use hakanbogan/gpt2-turkish-cased 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 "hakanbogan/gpt2-turkish-cased" \ --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": "hakanbogan/gpt2-turkish-cased", "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 "hakanbogan/gpt2-turkish-cased" \ --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": "hakanbogan/gpt2-turkish-cased", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use hakanbogan/gpt2-turkish-cased with Docker Model Runner:
docker model run hf.co/hakanbogan/gpt2-turkish-cased
🇹🇷 Turkish GPT-2 Model
In this repository I release GPT-2 model, that was trained on various texts for Turkish.
The model is meant to be an entry point for fine-tuning on other texts.
Training corpora
I used a Turkish corpora that is taken from oscar-corpus.
It was possible to create byte-level BPE with Tokenizers library of Huggingface.
With the Tokenizers library, I created a 52K byte-level BPE vocab based on the training corpora.
After creating the vocab, I could train the GPT-2 for Turkish on two 2080TI over the complete training corpus (five epochs).
Logs during training: https://tensorboard.dev/experiment/3AWKv8bBTaqcqZP5frtGkw/#scalars
Model weights
Both PyTorch and Tensorflow compatible weights are available.
| Model | Downloads |
|---|---|
hakanbogan/gpt2-turkish-cased |
config.json • merges.txt • pytorch_model.bin • special_tokens_map.json • tf_model.h5 • tokenizer_config.json • traning_args.bin • vocab.json |
Using the model
The model itself can be used in this way:
from transformers import AutoTokenizer, AutoModelWithLMHead
tokenizer = AutoTokenizer.from_pretrained("hakanbogan/gpt2-turkish-cased")
model = AutoModelWithLMHead.from_pretrained("hakanbogan/gpt2-turkish-cased")
Here's an example that shows how to use the great Transformers Pipelines for generating text:
from transformers import pipeline
pipe = pipeline('text-generation', model="hakanbogan/gpt2-turkish-cased",
tokenizer="hakanbogan/gpt2-turkish-cased", config={'max_length':800})
text = pipe("Akşamüstü yolda ilerlerken, ")[0]["generated_text"]
print(text)
How to clone the model repo?
git lfs install
git clone https://huggingface.co/hakanbogan/gpt2-turkish-cased
Contact (Bugs, Feedback, Contribution and more)
For questions about the GPT2-Turkish model, just open an issue here 🤗
- Downloads last month
- 3,777