Instructions to use akhooli/ap2023 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use akhooli/ap2023 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="akhooli/ap2023")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("akhooli/ap2023") model = AutoModelForCausalLM.from_pretrained("akhooli/ap2023") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use akhooli/ap2023 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "akhooli/ap2023" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "akhooli/ap2023", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/akhooli/ap2023
- SGLang
How to use akhooli/ap2023 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 "akhooli/ap2023" \ --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": "akhooli/ap2023", "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 "akhooli/ap2023" \ --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": "akhooli/ap2023", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use akhooli/ap2023 with Docker Model Runner:
docker model run hf.co/akhooli/ap2023
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("akhooli/ap2023")
model = AutoModelForCausalLM.from_pretrained("akhooli/ap2023")GPT2-Arabic-Poetry-2023
Model description
Fine-tuned model of Arabic poetry dataset based on aragpt2-medium.
Intended uses & limitations
How to use
Try this HF Space.
From script:
from transformers import pipeline
pipe = pipeline('text-generation', framework='pt', device=-1, model='akhooli/ap2023', tokenizer='akhooli/ap2023')
gen = pipe(prompt, max_length=96, temperature = 0.95,repetition_penalty=1.05,
num_beams=3, num_return_sequences=2, do_sample = True,
top_p = 1.0, top_k = 50, return_full_text=True)[0]["generated_text"]
poetry =""
for line in gen.split('.')[:-1]:
poetry += line
print(poetry)
Limitations and bias
Both the GPT2-small-arabic (trained on Arabic Wikipedia) and this model have several limitations in terms of coverage and training performance. Use them as demonstrations or proof of concepts but not as production code.
Training data
This pretrained model used poems from several eras with a total of around 1.4M lines (1.25M used for training). The dataset was trained (fine-tuned) based on the aragpt2-medium transformer model.
Training procedure
Training was done using HF Trainer using free GPU on Kaggle.
Eval results
Final perplexity reached was 52, eval_accuracy = 0.3704, eval_loss = 3.9513
BibTeX entry and citation info
@inproceedings{Abed Khooli,
year={2023}
}
- Downloads last month
- 1,191
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="akhooli/ap2023")