Instructions to use philschmid/codegen-6B-mono-sharded-bnb with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use philschmid/codegen-6B-mono-sharded-bnb with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="philschmid/codegen-6B-mono-sharded-bnb")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("philschmid/codegen-6B-mono-sharded-bnb") model = AutoModelForCausalLM.from_pretrained("philschmid/codegen-6B-mono-sharded-bnb") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use philschmid/codegen-6B-mono-sharded-bnb with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "philschmid/codegen-6B-mono-sharded-bnb" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "philschmid/codegen-6B-mono-sharded-bnb", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/philschmid/codegen-6B-mono-sharded-bnb
- SGLang
How to use philschmid/codegen-6B-mono-sharded-bnb 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 "philschmid/codegen-6B-mono-sharded-bnb" \ --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": "philschmid/codegen-6B-mono-sharded-bnb", "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 "philschmid/codegen-6B-mono-sharded-bnb" \ --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": "philschmid/codegen-6B-mono-sharded-bnb", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use philschmid/codegen-6B-mono-sharded-bnb with Docker Model Runner:
docker model run hf.co/philschmid/codegen-6B-mono-sharded-bnb
Sharded fork of Salesforce/codegen-6B-mono with a custom pipeline.py
This repository implements a custom pipeline task for text-generation for 🤗 Inference Endpoints for LLM inference using bitsandbytes quantization. The code for the customized pipeline is in the pipeline.py.
There is also a notebook included.
expected Request payload
{
"inputs": "# load distilbert model and initialize text-classification pipeline\nmodel_id = 'distil",
"parameters": {
"top_k": 100,
"max_length": 64,
"early_stopping": true,
"do_sample": true,
"eos_token_id": 50256,
}
}
below is an example on how to run a request using Python and requests.
Run Request
import json
from typing import List
import requests as r
import base64
ENDPOINT_URL = ""
HF_TOKEN = ""
parameters={
"top_k": 100,
"max_length": 64,
"early_stopping": True,
"do_sample": True,
"eos_token_id": 50256,
}
def predict(code_snippet:str=None):
payload = {"inputs": code_snippet,"parameters": parameters}
response = r.post(
ENDPOINT_URL, headers={"Authorization": f"Bearer {HF_TOKEN}"}, json=payload
)
return response.json()
prediction = predict(
code_snippet="# load distilbert model and initialize text-classification pipeline\nmodel_id = 'distil"
)
expected output
{'generated_text': "# load distilbert model and initialize text-classification pipeline\nmodel_id = 'distilbert-base-uncased'\nmodel_url = 'https://tfhub.dev/tensorflow/small_bert/1'\n\nmodel_dir = './distilBERT'"}
- Downloads last month
- 10