Instructions to use danyaljj/gpt2_question_generation_given_paragraph_answer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use danyaljj/gpt2_question_generation_given_paragraph_answer with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="danyaljj/gpt2_question_generation_given_paragraph_answer")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("danyaljj/gpt2_question_generation_given_paragraph_answer") model = AutoModelForCausalLM.from_pretrained("danyaljj/gpt2_question_generation_given_paragraph_answer") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use danyaljj/gpt2_question_generation_given_paragraph_answer with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "danyaljj/gpt2_question_generation_given_paragraph_answer" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "danyaljj/gpt2_question_generation_given_paragraph_answer", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/danyaljj/gpt2_question_generation_given_paragraph_answer
- SGLang
How to use danyaljj/gpt2_question_generation_given_paragraph_answer 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 "danyaljj/gpt2_question_generation_given_paragraph_answer" \ --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": "danyaljj/gpt2_question_generation_given_paragraph_answer", "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 "danyaljj/gpt2_question_generation_given_paragraph_answer" \ --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": "danyaljj/gpt2_question_generation_given_paragraph_answer", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use danyaljj/gpt2_question_generation_given_paragraph_answer with Docker Model Runner:
docker model run hf.co/danyaljj/gpt2_question_generation_given_paragraph_answer
:w:q
Browse files:q
erge branch 'main' of https://huggingface.co/danyaljj/gpt2_question_generation_given_paragraph_answer into main
README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Sample usage:
|
| 2 |
+
```python
|
| 3 |
+
tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
|
| 4 |
+
model = GPT2LMHeadModel.from_pretrained("danyaljj/gpt2_question_generation_given_paragraph_answer")
|
| 5 |
+
input_ids = tokenizer.encode("There are two apples on the counter. A: apples Q:", return_tensors="pt")
|
| 6 |
+
outputs = model.generate(input_ids)
|
| 7 |
+
print("Generated:", tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 8 |
+
```
|
| 9 |
+
Which should produce this:
|
| 10 |
+
```
|
| 11 |
+
Generated: There are two apples on the counter. A: apples Q: What is the name of the counter
|
| 12 |
+
```
|