Text Generation
Transformers
PyTorch
Safetensors
code
gpt_neox
causal-lm
Eval Results (legacy)
text-generation-inference
Instructions to use stabilityai/stablecode-instruct-alpha-3b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use stabilityai/stablecode-instruct-alpha-3b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="stabilityai/stablecode-instruct-alpha-3b")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("stabilityai/stablecode-instruct-alpha-3b") model = AutoModelForCausalLM.from_pretrained("stabilityai/stablecode-instruct-alpha-3b") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use stabilityai/stablecode-instruct-alpha-3b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "stabilityai/stablecode-instruct-alpha-3b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "stabilityai/stablecode-instruct-alpha-3b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/stabilityai/stablecode-instruct-alpha-3b
- SGLang
How to use stabilityai/stablecode-instruct-alpha-3b 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 "stabilityai/stablecode-instruct-alpha-3b" \ --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": "stabilityai/stablecode-instruct-alpha-3b", "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 "stabilityai/stablecode-instruct-alpha-3b" \ --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": "stabilityai/stablecode-instruct-alpha-3b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use stabilityai/stablecode-instruct-alpha-3b with Docker Model Runner:
docker model run hf.co/stabilityai/stablecode-instruct-alpha-3b
How to instruct it to generate code or unit tests?
#4
by rewisdomai - opened
I am using the following to generate unit tests for a sample python code but all I am getting is a result of executing the code, what am I doing wrong here?
###Instruction
Generate a unit test for this code
import heapq
class Solution(object):
#:type n: integer
#:return type: integer
def nth_Ugly_Number(self, n):
ugly_num = 0
heap = []
heapq.heappush(heap, 1)
for _ in range(n):
ugly_num = heapq.heappop(heap)
if ugly_num % 2 == 0:
heapq.heappush(heap, ugly_num * 2)
elif ugly_num % 3 == 0:
heapq.heappush(heap, ugly_num * 2)
heapq.heappush(heap, ugly_num * 3)
else:
heapq.heappush(heap, ugly_num * 2)
heapq.heappush(heap, ugly_num * 3)
heapq.heappush(heap, ugly_num * 5)
return ugly_num
n = 7
S = Solution()
result = S.nth_Ugly_Number(n)
print("7th Ugly number:")
print(result)
n = 10
result = S.nth_Ugly_Number(n)
print("\n10th Ugly number:")
print(result)
###Response
Here's the result
###Instruction
Generate a unit test for this code
import heapq
class Solution(object):
#:type n: integer
#:return type: integer
def nth_Ugly_Number(self, n):
ugly_num = 0
heap = []
heapq.heappush(heap, 1)
for _ in range(n):
ugly_num = heapq.heappop(heap)
if ugly_num % 2 == 0:
heapq.heappush(heap, ugly_num * 2)
elif ugly_num % 3 == 0:
heapq.heappush(heap, ugly_num * 2)
heapq.heappush(heap, ugly_num * 3)
else:
heapq.heappush(heap, ugly_num * 2)
heapq.heappush(heap, ugly_num * 3)
heapq.heappush(heap, ugly_num * 5)
return ugly_num
n = 7
S = Solution()
result = S.nth_Ugly_Number(n)
print("7th Ugly number:")
print(result)
n = 10
result = S.nth_Ugly_Number(n)
print("\n10th Ugly number:")
print(result)
###Response:7th Ugly number: 216000
10th Ugly number: 216000
Have you solved your problem? I'm not an expert but I'd go with prompt that would point to specific test library and coding language.
I dropped this model and using ChatGPT 3.5 Turbo
rewisdomai changed discussion status to closed