Text Generation
Transformers
PyTorch
TensorFlow
code
gpt2
Code
GPyT
code generator
text-generation-inference
Instructions to use Sentdex/GPyT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Sentdex/GPyT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Sentdex/GPyT")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Sentdex/GPyT") model = AutoModelForCausalLM.from_pretrained("Sentdex/GPyT") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Sentdex/GPyT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Sentdex/GPyT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Sentdex/GPyT", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Sentdex/GPyT
- SGLang
How to use Sentdex/GPyT 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 "Sentdex/GPyT" \ --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": "Sentdex/GPyT", "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 "Sentdex/GPyT" \ --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": "Sentdex/GPyT", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Sentdex/GPyT with Docker Model Runner:
docker model run hf.co/Sentdex/GPyT
Update README.md
Browse files
README.md
CHANGED
|
@@ -12,13 +12,6 @@ GPyT is a GPT2 model trained from scratch (not fine tuned) on Python code from G
|
|
| 12 |
|
| 13 |
Newlines are replaced by `<N>`
|
| 14 |
|
| 15 |
-
Considerations:
|
| 16 |
-
|
| 17 |
-
1. This model is intended for educational and research use only. Do not trust model outputs.
|
| 18 |
-
2. Model is highly likely to regurgitate code almost exactly as it saw it. It's up to you to determine licensing if you intend to actually use the generated code.
|
| 19 |
-
3. All Python code was blindly pulled from github. This means included code is both Python 2 and 3, among other more subtle differences, such as tabs being 2 spaces in some cases and 4 in others...and more non-homologous things.
|
| 20 |
-
4. Along with the above, this means the code generated could wind up doing or suggesting just about anything. Run the generated code at own risk...it could be *anything*
|
| 21 |
-
|
| 22 |
|
| 23 |
Input to the model is code, up to the context length of 1024, with newlines replaced by `<N>`
|
| 24 |
|
|
@@ -42,5 +35,12 @@ This should give you something like:
|
|
| 42 |
|
| 43 |
...which is what the model is expecting as input.
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
|
|
|
|
| 12 |
|
| 13 |
Newlines are replaced by `<N>`
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
Input to the model is code, up to the context length of 1024, with newlines replaced by `<N>`
|
| 17 |
|
|
|
|
| 35 |
|
| 36 |
...which is what the model is expecting as input.
|
| 37 |
|
| 38 |
+
Considerations:
|
| 39 |
+
|
| 40 |
+
1. This model is intended for educational and research use only. Do not trust model outputs.
|
| 41 |
+
2. Model is highly likely to regurgitate code almost exactly as it saw it. It's up to you to determine licensing if you intend to actually use the generated code.
|
| 42 |
+
3. All Python code was blindly pulled from github. This means included code is both Python 2 and 3, among other more subtle differences, such as tabs being 2 spaces in some cases and 4 in others...and more non-homologous things.
|
| 43 |
+
4. Along with the above, this means the code generated could wind up doing or suggesting just about anything. Run the generated code at own risk...it could be *anything*
|
| 44 |
+
|
| 45 |
|
| 46 |
|