Text Generation
Transformers
PyTorch
Safetensors
English
gpt2
code
autocomplete
text-generation-inference
Instructions to use shibing624/code-autocomplete-gpt2-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use shibing624/code-autocomplete-gpt2-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="shibing624/code-autocomplete-gpt2-base")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("shibing624/code-autocomplete-gpt2-base") model = AutoModelForCausalLM.from_pretrained("shibing624/code-autocomplete-gpt2-base", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use shibing624/code-autocomplete-gpt2-base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "shibing624/code-autocomplete-gpt2-base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "shibing624/code-autocomplete-gpt2-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/shibing624/code-autocomplete-gpt2-base
- SGLang
How to use shibing624/code-autocomplete-gpt2-base 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 "shibing624/code-autocomplete-gpt2-base" \ --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": "shibing624/code-autocomplete-gpt2-base", "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 "shibing624/code-autocomplete-gpt2-base" \ --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": "shibing624/code-autocomplete-gpt2-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use shibing624/code-autocomplete-gpt2-base with Docker Model Runner:
docker model run hf.co/shibing624/code-autocomplete-gpt2-base
Commit ·
9a23788
1
Parent(s): 07a5a56
Update README.md
Browse files
README.md
CHANGED
|
@@ -13,11 +13,11 @@ license: "apache-2.0"
|
|
| 13 |
# GPT2 for Code AutoComplete Model
|
| 14 |
code-autocomplete, a code completion plugin for Python.
|
| 15 |
|
| 16 |
-
**code-autocomplete**
|
| 17 |
|
| 18 |
## Usage
|
| 19 |
|
| 20 |
-
|
| 21 |
|
| 22 |
```python
|
| 23 |
from autocomplete.gpt2 import Infer
|
|
@@ -26,7 +26,7 @@ i = m.predict('import torch.nn as')
|
|
| 26 |
print(i)
|
| 27 |
```
|
| 28 |
|
| 29 |
-
|
| 30 |
|
| 31 |
*Please use 'GPT2' related functions to load this model!*
|
| 32 |
|
|
@@ -111,7 +111,7 @@ Process finished with exit code 0
|
|
| 111 |
|
| 112 |
```
|
| 113 |
|
| 114 |
-
|
| 115 |
```
|
| 116 |
code-autocomplete-gpt2-base
|
| 117 |
├── config.json
|
|
@@ -122,8 +122,8 @@ code-autocomplete-gpt2-base
|
|
| 122 |
└── vocab.json
|
| 123 |
```
|
| 124 |
|
| 125 |
-
###
|
| 126 |
-
#### pytorch_awesome
|
| 127 |
|
| 128 |
download [code-autocomplete](https://github.com/shibing624/code-autocomplete),
|
| 129 |
```shell
|
|
@@ -131,7 +131,7 @@ cd autocomplete
|
|
| 131 |
python create_dataset.py
|
| 132 |
```
|
| 133 |
|
| 134 |
-
|
| 135 |
|
| 136 |
|
| 137 |
### About GPT2
|
|
|
|
| 13 |
# GPT2 for Code AutoComplete Model
|
| 14 |
code-autocomplete, a code completion plugin for Python.
|
| 15 |
|
| 16 |
+
**code-autocomplete** can Automatic completion of code line granularity and block granularity.
|
| 17 |
|
| 18 |
## Usage
|
| 19 |
|
| 20 |
+
Open source repo:[code-autocomplete](https://github.com/shibing624/code-autocomplete),support GPT2 model, usage:
|
| 21 |
|
| 22 |
```python
|
| 23 |
from autocomplete.gpt2 import Infer
|
|
|
|
| 26 |
print(i)
|
| 27 |
```
|
| 28 |
|
| 29 |
+
Also, use huggingface/transformers:
|
| 30 |
|
| 31 |
*Please use 'GPT2' related functions to load this model!*
|
| 32 |
|
|
|
|
| 111 |
|
| 112 |
```
|
| 113 |
|
| 114 |
+
Model files:
|
| 115 |
```
|
| 116 |
code-autocomplete-gpt2-base
|
| 117 |
├── config.json
|
|
|
|
| 122 |
└── vocab.json
|
| 123 |
```
|
| 124 |
|
| 125 |
+
### Train data
|
| 126 |
+
#### pytorch_awesome projects source code
|
| 127 |
|
| 128 |
download [code-autocomplete](https://github.com/shibing624/code-autocomplete),
|
| 129 |
```shell
|
|
|
|
| 131 |
python create_dataset.py
|
| 132 |
```
|
| 133 |
|
| 134 |
+
If you want train code-autocomplete GPT2 model,refer [https://github.com/shibing624/code-autocomplete/blob/main/autocomplete/gpt2.py](https://github.com/shibing624/code-autocomplete/blob/main/autocomplete/gpt2.py)
|
| 135 |
|
| 136 |
|
| 137 |
### About GPT2
|