Hugging Face's logo Hugging Face
  • Models
  • Datasets
  • Spaces
  • Buckets new
  • Docs
  • Enterprise
  • Pricing
    • Website
      • Tasks
      • HuggingChat
      • Collections
      • Languages
      • Organizations
    • Community
      • Blog
      • Posts
      • Daily Papers
      • Learn
      • Discord
      • Forum
      • GitHub
    • Solutions
      • Team & Enterprise
      • Hugging Face PRO
      • Enterprise Support
      • Inference Providers
      • Inference Endpoints
      • Storage Buckets

  • Log In
  • Sign Up

flax-community
/
gpt2-medium-persian

Text Generation
Transformers
PyTorch
google-tensorflow TensorFlow
JAX
TensorBoard
Persian
gpt2
text-generation-inference
Model card Files Files and versions
xet
Metrics Training metrics Community
32

Instructions to use flax-community/gpt2-medium-persian with libraries, inference providers, notebooks, and local apps. Follow these links to get started.

  • Libraries
  • Transformers

    How to use flax-community/gpt2-medium-persian with Transformers:

    # Use a pipeline as a high-level helper
    from transformers import pipeline
    
    pipe = pipeline("text-generation", model="flax-community/gpt2-medium-persian")
    # Load model directly
    from transformers import AutoTokenizer, AutoModelForCausalLM
    
    tokenizer = AutoTokenizer.from_pretrained("flax-community/gpt2-medium-persian")
    model = AutoModelForCausalLM.from_pretrained("flax-community/gpt2-medium-persian")
  • Notebooks
  • Google Colab
  • Kaggle
  • Local Apps
  • vLLM

    How to use flax-community/gpt2-medium-persian with vLLM:

    Install from pip and serve model
    # Install vLLM from pip:
    pip install vllm
    # Start the vLLM server:
    vllm serve "flax-community/gpt2-medium-persian"
    # 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-medium-persian",
    		"prompt": "Once upon a time,",
    		"max_tokens": 512,
    		"temperature": 0.5
    	}'
    Use Docker
    docker model run hf.co/flax-community/gpt2-medium-persian
  • SGLang

    How to use flax-community/gpt2-medium-persian 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-medium-persian" \
        --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-medium-persian",
    		"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-medium-persian" \
            --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-medium-persian",
    		"prompt": "Once upon a time,",
    		"max_tokens": 512,
    		"temperature": 0.5
    	}'
  • Docker Model Runner

    How to use flax-community/gpt2-medium-persian with Docker Model Runner:

    docker model run hf.co/flax-community/gpt2-medium-persian
gpt2-medium-persian / src
99.3 kB
Ctrl+K
Ctrl+K
  • 3 contributors
History: 23 commits
m3hrdadfi's picture
m3hrdadfi
Add pytorch, tf version
c5a9149 almost 5 years ago
  • __pycache__
    Add dataset creation script almost 5 years ago
  • regexes
    Add dataset creation script almost 5 years ago
  • convert_flax_to_pytorch.py
    846 Bytes
    Add pytorch, tf version almost 5 years ago
  • convert_flax_to_tf.py
    647 Bytes
    Add pytorch, tf version almost 5 years ago
  • create_config.py
    2.32 kB
    Hello gpt2-persian almost 5 years ago
  • create_dataset.py
    4.34 kB
    Add dataset creation script almost 5 years ago
  • data_utils.py
    1.12 kB
    Add dataset creation script almost 5 years ago
  • dictionary.py
    2.3 kB
    Refine saied code almost 5 years ago
  • normalizer.py
    4.2 kB
    pushing tokenizer almost 5 years ago
  • requirements.txt
    85 Bytes
    Add normalization steps, fix som bugs, add tfboard tracker almost 5 years ago
  • run.sh
    2.32 kB
    Fix some bugs almost 5 years ago
  • run_clm_flax.py
    30.1 kB
    Fix some bugs almost 5 years ago
  • run_clm_flax_with_ckpts.py
    28.9 kB
    Add training script with checkpoint and preprocessing + merge scripts almost 5 years ago
  • run_config.sh
    340 Bytes
    pushing tokenizer almost 5 years ago
  • run_dataset.sh
    327 Bytes
    Add dataset creation script almost 5 years ago
  • run_tokenizer.sh
    785 Bytes
    pushing tokenizer almost 5 years ago
  • train_tokenizer.py
    5.46 kB
    Add runner, fix some bugs almost 5 years ago