Instructions to use himanshu-dutta/pycoder-gpt2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use himanshu-dutta/pycoder-gpt2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="himanshu-dutta/pycoder-gpt2")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("himanshu-dutta/pycoder-gpt2") model = AutoModelForCausalLM.from_pretrained("himanshu-dutta/pycoder-gpt2") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use himanshu-dutta/pycoder-gpt2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "himanshu-dutta/pycoder-gpt2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "himanshu-dutta/pycoder-gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/himanshu-dutta/pycoder-gpt2
- SGLang
How to use himanshu-dutta/pycoder-gpt2 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 "himanshu-dutta/pycoder-gpt2" \ --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": "himanshu-dutta/pycoder-gpt2", "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 "himanshu-dutta/pycoder-gpt2" \ --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": "himanshu-dutta/pycoder-gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use himanshu-dutta/pycoder-gpt2 with Docker Model Runner:
docker model run hf.co/himanshu-dutta/pycoder-gpt2
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
PyCoder is a tool to generate python code out of a few given topics and a description. It uses GPT-2 language model as its engine. Pycoder poses writing Python code as a conditional-Causal Language Modelling(c-CLM). It has been trained on millions of lines of Python code written by all of us. At the current stage and state of training, it produces sensible code with few lines of description, but the scope of improvement for the model is limitless.
Pycoder has been developed as a Command-Line tool (CLI), an API endpoint, as well as a python package (yet to be deployed to PyPI). This repository acts as a framework for anyone who either wants to try to build Pycoder from scratch or turn Pycoder into maybe a CPPCoder or JSCoder 😃. A blog post about the development of the project will be released soon.
To use Pycoder as a CLI utility, clone the repository as normal, and install the package with:
foo@bar:❯ pip install pycoder
After this the package could be verified and accessed as either a native CLI tool or a python package with:
foo@bar:❯ python -m pycoder --version
Or directly as:
foo@bar:❯ pycoder --version
On installation the CLI can be used directly, such as:
foo@bar:❯ pycoder -t pytorch -t torch -d "a trainer class to train vision model" -ml 120
The API endpoint is deployed using FastAPI. Once all the requirements have been installed for the project, the API can be accessed with:
foo@bar:❯ pycoder --endpoint PORT_NUMBER
Or
foo@bar:❯ pycoder -e PORT_NUMBER
Tech Stack
Tested Platforms
BibTeX
If you want to cite the framework feel free to use this:
@article{dutta2021pycoder,
title={Pycoder},
author={Dutta, H},
journal={GitHub. Note: https://github.com/himanshu-dutta/pycoder},
year={2021}
}
- Downloads last month
- 4
docker model run hf.co/himanshu-dutta/pycoder-gpt2