Instructions to use Madhour/gpt2-eli5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Madhour/gpt2-eli5 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Madhour/gpt2-eli5")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Madhour/gpt2-eli5") model = AutoModelForCausalLM.from_pretrained("Madhour/gpt2-eli5") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Madhour/gpt2-eli5 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Madhour/gpt2-eli5" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Madhour/gpt2-eli5", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Madhour/gpt2-eli5
- SGLang
How to use Madhour/gpt2-eli5 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 "Madhour/gpt2-eli5" \ --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": "Madhour/gpt2-eli5", "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 "Madhour/gpt2-eli5" \ --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": "Madhour/gpt2-eli5", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Madhour/gpt2-eli5 with Docker Model Runner:
docker model run hf.co/Madhour/gpt2-eli5
| language: en | |
| tags: | |
| - ELI5 | |
| license: gpl-3.0 | |
| datasets: | |
| - eli5 | |
| Task: Summarization | |
| widget: | |
| - text: "<|BOS|><|SEP|>Consulting,business,Fraud<|SEP|>" | |
| inference: | |
| parameters: | |
| temperature: 0.9 | |
| return_full_text: False | |
| repetition_penalty: 1 | |
| # Conditional ELI5 Generator | |
| Given a few keywords, it generates an Eli5 question with a corresponding answer. | |
| The model is mainly used for [SeemsPhishy](https://github.com/madhour/seemsphishy) to auto generate newsletters for phishing/penetration-testing. | |
| # How to use | |
| ```Python | |
| from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM | |
| from torch import tensor | |
| tokenizer = AutoTokenizer.from_pretrained("Madhour/gpt2-eli5") | |
| model = AutoModelForCausalLM.from_pretrained("Madhour/gpt2-eli5") | |
| prompt = <|BOS|> +"I have a question."+ <|SEP|> + "keyword1,keyword2,keyword3" + <|SEP|> | |
| prompt = tensor(tokenizer.encode(prompt)).unsqueeze(0) | |
| text = model.generate(prompt, | |
| do_sample=True, | |
| min_length=50, | |
| max_length=768, | |
| top_k=30, | |
| top_p=0.7, | |
| temperature=0.9, | |
| repetition_penalty=2.0, | |
| num_return_sequences=3) | |
| ``` |