Instructions to use sahil2801/instruct-codegen-16B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sahil2801/instruct-codegen-16B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sahil2801/instruct-codegen-16B")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("sahil2801/instruct-codegen-16B") model = AutoModelForCausalLM.from_pretrained("sahil2801/instruct-codegen-16B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use sahil2801/instruct-codegen-16B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sahil2801/instruct-codegen-16B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sahil2801/instruct-codegen-16B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/sahil2801/instruct-codegen-16B
- SGLang
How to use sahil2801/instruct-codegen-16B 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 "sahil2801/instruct-codegen-16B" \ --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": "sahil2801/instruct-codegen-16B", "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 "sahil2801/instruct-codegen-16B" \ --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": "sahil2801/instruct-codegen-16B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use sahil2801/instruct-codegen-16B with Docker Model Runner:
docker model run hf.co/sahil2801/instruct-codegen-16B
| license: bsd-3-clause | |
| metrics: | |
| - code_eval | |
| pipeline_tag: text-generation | |
| tags: | |
| - code | |
| model-index: | |
| - name: instruct-codegen-16B | |
| results: | |
| - task: | |
| type: code-generation | |
| dataset: | |
| type: openai_humaneval | |
| name: HumanEval | |
| metrics: | |
| - name: pass@1 | |
| type: pass@1 | |
| value: 0.371 | |
| verified: false | |
| # Model Card for instruct-codegen-16B | |
| <!-- Provide a quick summary of what the model is/does. --> | |
| Instruct-codegen-16B is an instruction following codegen model based on [Salesforce codegen-16B-multi](https://huggingface.co/Salesforce/codegen-16B-multi) , finetuned on a dataset of 250k instruction-following samples in the alpaca format. | |
| The data was not generated using any commercial LLM api. | |
| The model achieves a result of 37.1% pass@1 on the HumanEval benchmark. | |
| ## Generation | |
| ```python | |
| # pip install -q transformers | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| checkpoint = "sahil2801/instruct-codegen-16B" | |
| device = "cuda" | |
| tokenizer = AutoTokenizer.from_pretrained(checkpoint) | |
| model = AutoModelForCausalLM.from_pretrained(checkpoint).half().to(device) | |
| instruction = "Write a function to scrape hacker news." | |
| prompt = f"Below is an instruction that describes a task.\n Write a response that appropriately completes the request.\n\n ### Instruction:\n{instruction}\n\n### Response:" | |
| inputs = tokenizer(prompt, return_tensors="pt").to(device) | |
| outputs = model.generate(**inputs,temperature=0.3,do_sample=True,max_new_tokens=256) | |
| print(tokenizer.decode(outputs[0],skip_special_tokens=True)) | |
| ``` |