Instructions to use Norod78/distilgpt2-base-pretrained-he with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Norod78/distilgpt2-base-pretrained-he with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Norod78/distilgpt2-base-pretrained-he")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Norod78/distilgpt2-base-pretrained-he") model = AutoModelForCausalLM.from_pretrained("Norod78/distilgpt2-base-pretrained-he") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Norod78/distilgpt2-base-pretrained-he with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Norod78/distilgpt2-base-pretrained-he" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Norod78/distilgpt2-base-pretrained-he", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Norod78/distilgpt2-base-pretrained-he
- SGLang
How to use Norod78/distilgpt2-base-pretrained-he 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 "Norod78/distilgpt2-base-pretrained-he" \ --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": "Norod78/distilgpt2-base-pretrained-he", "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 "Norod78/distilgpt2-base-pretrained-he" \ --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": "Norod78/distilgpt2-base-pretrained-he", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Norod78/distilgpt2-base-pretrained-he with Docker Model Runner:
docker model run hf.co/Norod78/distilgpt2-base-pretrained-he
distilgpt2-base-pretrained-he
A tiny GPT2 based Hebrew text generation model initially trained on a TPUv3-8 which was made avilable to me via the TPU Research Cloud Program. Then was further fine-tuned on GPU.
Dataset
oscar (unshuffled deduplicated he) - Homepage | Dataset Permalink
The Open Super-large Crawled ALMAnaCH coRpus is a huge multilingual corpus obtained by language classification and filtering of the Common Crawl corpus using the goclassy architecture.
CC-100 (he) - HomePage
This corpus comprises of monolingual data for 100+ languages and also includes data for romanized languages. This was constructed using the urls and paragraph indices provided by the CC-Net repository by processing January-December 2018 Commoncrawl snapshots. Each file comprises of documents separated by double-newlines and paragraphs within the same document separated by a newline. The data is generated using the open source CC-Net repository.
Misc
- Hebrew Twitter
- Wikipedia
- Various other sources
Training
- Done on a TPUv3-8 VM using Huggingface's clm-flax example script
- I have made a list of items which might make it easier for other to use this script. The list was posted to This discussion forum
- Further training was performed on GPU
Usage
Simple usage sample code
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
def main():
model_name="Norod78/distilgpt2-base-pretrained-he"
prompt_text = "שלום, קוראים לי"
generated_max_length = 192
print("Loading model...")
model = AutoModelForCausalLM.from_pretrained(model_name)
print('Loading Tokenizer...')
tokenizer = AutoTokenizer.from_pretrained(model_name)
text_generator = pipeline(task="text-generation", model=model, tokenizer=tokenizer)
print("Generating text...")
result = text_generator(prompt_text, num_return_sequences=1, batch_size=1, do_sample=True, top_k=40, top_p=0.92, temperature = 1, repetition_penalty=5.0, max_length = generated_max_length)
print("result = " + str(result))
if __name__ == '__main__':
main()
- Downloads last month
- 1,856