As Good as New. How to Successfully Recycle English GPT-2 to Make Models for Other Languages
Paper β’ 2012.05628 β’ Published
How to use GroNLP/gpt2-small-italian-embeddings with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="GroNLP/gpt2-small-italian-embeddings") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("GroNLP/gpt2-small-italian-embeddings")
model = AutoModelForCausalLM.from_pretrained("GroNLP/gpt2-small-italian-embeddings")How to use GroNLP/gpt2-small-italian-embeddings with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "GroNLP/gpt2-small-italian-embeddings"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "GroNLP/gpt2-small-italian-embeddings",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/GroNLP/gpt2-small-italian-embeddings
How to use GroNLP/gpt2-small-italian-embeddings with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "GroNLP/gpt2-small-italian-embeddings" \
--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": "GroNLP/gpt2-small-italian-embeddings",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "GroNLP/gpt2-small-italian-embeddings" \
--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": "GroNLP/gpt2-small-italian-embeddings",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use GroNLP/gpt2-small-italian-embeddings with Docker Model Runner:
docker model run hf.co/GroNLP/gpt2-small-italian-embeddings
Wietse de Vries β’ Malvina Nissim
This model is based on the small OpenAI GPT-2 (gpt2) model.
The Transformer layer weights in this model are identical to the original English, model but the lexical layer has been retrained for an Italian vocabulary.
For details, check out our paper on arXiv and the code on Github.
gpt2-small-dutch-embeddings: Small model size with only retrained lexical embeddings.gpt2-small-dutch: Small model size with retrained lexical embeddings and additional fine-tuning of the full model. (Recommended)gpt2-medium-dutch-embeddings: Medium model size with only retrained lexical embeddings.gpt2-small-italian-embeddings: Small model size with only retrained lexical embeddings.gpt2-small-italian: Small model size with retrained lexical embeddings and additional fine-tuning of the full model. (Recommended)gpt2-medium-italian-embeddings: Medium model size with only retrained lexical embeddings.from transformers import pipeline
pipe = pipeline("text-generation", model="GroNLP/gpt2-small-italian-embeddings")
from transformers import AutoTokenizer, AutoModel, TFAutoModel
tokenizer = AutoTokenizer.from_pretrained("GroNLP/gpt2-small-italian-embeddings")
model = AutoModel.from_pretrained("GroNLP/gpt2-small-italian-embeddings") # PyTorch
model = TFAutoModel.from_pretrained("GroNLP/gpt2-small-italian-embeddings") # Tensorflow
@misc{devries2020good,
title={As good as new. How to successfully recycle English GPT-2 to make models for other languages},
author={Wietse de Vries and Malvina Nissim},
year={2020},
eprint={2012.05628},
archivePrefix={arXiv},
primaryClass={cs.CL}
}