Text Generation
Transformers
PyTorch
JAX
TensorBoard
Safetensors
Bengali
gpt2
text-generation-inference
Instructions to use flax-community/gpt2-bengali with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use flax-community/gpt2-bengali with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="flax-community/gpt2-bengali")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("flax-community/gpt2-bengali") model = AutoModelForCausalLM.from_pretrained("flax-community/gpt2-bengali") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use flax-community/gpt2-bengali with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "flax-community/gpt2-bengali" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "flax-community/gpt2-bengali", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/flax-community/gpt2-bengali
- SGLang
How to use flax-community/gpt2-bengali 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 "flax-community/gpt2-bengali" \ --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": "flax-community/gpt2-bengali", "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 "flax-community/gpt2-bengali" \ --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": "flax-community/gpt2-bengali", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use flax-community/gpt2-bengali with Docker Model Runner:
docker model run hf.co/flax-community/gpt2-bengali
| python run_clm_flax.py \ | |
| --output_dir="${MODEL_DIR}" \ | |
| --model_type="gpt2" \ | |
| --config_name="${MODEL_DIR}" \ | |
| --tokenizer_name="${MODEL_DIR}" \ | |
| --dataset_name="mc4" \ | |
| --dataset_config_name="bn" \ | |
| --do_train --do_eval \ | |
| --block_size="512" \ | |
| --per_device_train_batch_size="64" \ | |
| --per_device_eval_batch_size="64" \ | |
| --learning_rate="5e-3" --warmup_steps="1000" \ | |
| --adam_beta1="0.9" --adam_beta2="0.98" --weight_decay="0.01" \ | |
| --overwrite_output_dir \ | |
| --num_train_epochs="50" \ | |
| --logging_steps="500" \ | |
| --save_steps="2500" \ | |
| --eval_steps="2500" \ | |
| --preprocessing_num_workers="90" \ | |
| --push_to_hub |