Text Generation
Transformers
PyTorch
codegen
How to use from
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 "SarthakBhatore/codegen-350M-mono-18k-alpaca-python" \
    --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": "SarthakBhatore/codegen-350M-mono-18k-alpaca-python",
		"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 "SarthakBhatore/codegen-350M-mono-18k-alpaca-python" \
        --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": "SarthakBhatore/codegen-350M-mono-18k-alpaca-python",
		"prompt": "Once upon a time,",
		"max_tokens": 512,
		"temperature": 0.5
	}'
Quick Links

CodeGen-350M-mono-18k-Alpaca-Python

Hugging Face Model GitHub Stars License

This repository contains a fine-tuned language model, "CodeGen-350M-mono-18k-Alpaca-Python," which is based on the Salesforce-codegen-350M model and fine-tuned on the "iamtarun/python_code_instructions_18k_alpaca" dataset. This model is designed to assist developers in generating Python code instructions and snippets based on natural language prompts.

Model Details Model Name: CodeGen-350M-mono-18k-Alpaca-Python Base Model: Salesforce-codegen-350M Dataset: iamtarun/python_code_instructions_18k_alpaca Model Size: 350 million parameters Usage You can use this model in various NLP tasks that involve generating Python code from natural language prompts. Below is an example of how to use this model with the Hugging Face Transformers library in Python:

python Copy code from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "your-username/codegen-350M-mono-18k-alpaca-python" tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForCausalLM.from_pretrained(model_name)

Input text

text = "Create a function that calculates the factorial of a number in Python."

Tokenize the text

input_ids = tokenizer.encode(text, return_tensors="pt")

Generate Python code

output = model.generate(input_ids, max_length=100, num_return_sequences=1, no_repeat_ngram_size=2)

Decode and print the generated code

generated_code = tokenizer.decode(output[0], skip_special_tokens=True) print(generated_code) For more information on using Hugging Face models, refer to the official documentation.

Fine-Tuning Details The CodeGen-350M-mono-18k-Alpaca-Python model was fine-tuned on the "iamtarun/python_code_instructions_18k_alpaca" dataset using the Hugging Face Transformers library. The fine-tuning process involved adapting the base Salesforce-codegen-350M model to generate Python code instructions specifically for the provided dataset.

Downloads last month
8
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train SarthakBhatore/codegen-350M-mono-18k-alpaca-python