Instructions to use codeparrot/codeparrot-small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use codeparrot/codeparrot-small with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="codeparrot/codeparrot-small")# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("codeparrot/codeparrot-small") model = AutoModelForMultimodalLM.from_pretrained("codeparrot/codeparrot-small") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use codeparrot/codeparrot-small with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "codeparrot/codeparrot-small" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "codeparrot/codeparrot-small", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/codeparrot/codeparrot-small
- SGLang
How to use codeparrot/codeparrot-small 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 "codeparrot/codeparrot-small" \ --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": "codeparrot/codeparrot-small", "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 "codeparrot/codeparrot-small" \ --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": "codeparrot/codeparrot-small", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use codeparrot/codeparrot-small with Docker Model Runner:
docker model run hf.co/codeparrot/codeparrot-small
update lvwerra namespace
Browse files
README.md
CHANGED
|
@@ -9,8 +9,8 @@ You can load the CodeParrot model and tokenizer directly in `transformers`:
|
|
| 9 |
```Python
|
| 10 |
from transformers import AutoTokenizer, AutoModelWithLMHead
|
| 11 |
|
| 12 |
-
tokenizer = AutoTokenizer.from_pretrained("
|
| 13 |
-
model = AutoModelWithLMHead.from_pretrained("
|
| 14 |
|
| 15 |
inputs = tokenizer("def hello_world():", return_tensors="pt")
|
| 16 |
outputs = model(**inputs)
|
|
@@ -21,13 +21,13 @@ or with a `pipeline`:
|
|
| 21 |
```Python
|
| 22 |
from transformers import pipeline
|
| 23 |
|
| 24 |
-
pipe = pipeline("text-generation", model="
|
| 25 |
outputs = pipe("def hello_world():")
|
| 26 |
```
|
| 27 |
|
| 28 |
## Training
|
| 29 |
|
| 30 |
-
The model was trained on the cleaned [CodeParrot 🦜 dataset](https://huggingface.co/datasets/
|
| 31 |
|
| 32 |
|Config|Value|
|
| 33 |
|-------|-----|
|
|
@@ -57,6 +57,6 @@ The [pass@k metric](https://huggingface.co/metrics/code_eval) tells the probabil
|
|
| 57 |
|
| 58 |
## Resources
|
| 59 |
|
| 60 |
-
- Dataset: [full](https://huggingface.co/datasets/
|
| 61 |
- Code: [repository](https://github.com/huggingface/transformers/tree/master/examples/research_projects/codeparrot)
|
| 62 |
- Spaces: [generation](), [highlighting]()
|
|
|
|
| 9 |
```Python
|
| 10 |
from transformers import AutoTokenizer, AutoModelWithLMHead
|
| 11 |
|
| 12 |
+
tokenizer = AutoTokenizer.from_pretrained("codeparrot/codeparrot-small")
|
| 13 |
+
model = AutoModelWithLMHead.from_pretrained("codeparrot/codeparrot-small")
|
| 14 |
|
| 15 |
inputs = tokenizer("def hello_world():", return_tensors="pt")
|
| 16 |
outputs = model(**inputs)
|
|
|
|
| 21 |
```Python
|
| 22 |
from transformers import pipeline
|
| 23 |
|
| 24 |
+
pipe = pipeline("text-generation", model="codeparrot/codeparrot-small")
|
| 25 |
outputs = pipe("def hello_world():")
|
| 26 |
```
|
| 27 |
|
| 28 |
## Training
|
| 29 |
|
| 30 |
+
The model was trained on the cleaned [CodeParrot 🦜 dataset](https://huggingface.co/datasets/codeparrot/codeparrot-clean) with the following settings:
|
| 31 |
|
| 32 |
|Config|Value|
|
| 33 |
|-------|-----|
|
|
|
|
| 57 |
|
| 58 |
## Resources
|
| 59 |
|
| 60 |
+
- Dataset: [full](https://huggingface.co/datasets/codeparrot/codeparrot-clean), [train](https://huggingface.co/datasets/codeparrot/codeparrot-clean-train), [valid](https://huggingface.co/datasets/codeparrot/codeparrot-clean-valid)
|
| 61 |
- Code: [repository](https://github.com/huggingface/transformers/tree/master/examples/research_projects/codeparrot)
|
| 62 |
- Spaces: [generation](), [highlighting]()
|