iamtarun/python_code_instructions_18k_alpaca
Viewer • Updated • 18.6k • 23.7k • 347
How to use damerajee/codellama2-finetuned-alpaca-18k-fin with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="damerajee/codellama2-finetuned-alpaca-18k-fin") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("damerajee/codellama2-finetuned-alpaca-18k-fin")
model = AutoModelForCausalLM.from_pretrained("damerajee/codellama2-finetuned-alpaca-18k-fin", device_map="auto")How to use damerajee/codellama2-finetuned-alpaca-18k-fin with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "damerajee/codellama2-finetuned-alpaca-18k-fin"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "damerajee/codellama2-finetuned-alpaca-18k-fin",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/damerajee/codellama2-finetuned-alpaca-18k-fin
How to use damerajee/codellama2-finetuned-alpaca-18k-fin with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "damerajee/codellama2-finetuned-alpaca-18k-fin" \
--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": "damerajee/codellama2-finetuned-alpaca-18k-fin",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "damerajee/codellama2-finetuned-alpaca-18k-fin" \
--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": "damerajee/codellama2-finetuned-alpaca-18k-fin",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use damerajee/codellama2-finetuned-alpaca-18k-fin with Docker Model Runner:
docker model run hf.co/damerajee/codellama2-finetuned-alpaca-18k-fin
This model is a fine-tuned version of codellama/CodeLlama-7b-hf on the iamtarun/python_code_instructions_18k_alpaca dataset.
More information needed
More information needed
from transformers import AutoTokenizer
from transformers import pipeline
import torch
tokenizer = AutoTokenizer.from_pretrained("damerajee/codellama2-finetuned-alpaca-18k-fin")
pipe = pipeline(
"text-generation",
model="damerajee/codellama2-finetuned-alpaca-18k-fin",
torch_dtype=torch.float16,
device_map="auto",
)
text = "write a function that takes in print out each individual characters in a string"
sequences = pipe(
text,
do_sample=True,
temperature=0.1,
top_p=0.7,
num_return_sequences=1,
eos_token_id=tokenizer.eos_token_id,
max_length=70,
)
for seq in sequences:
print(f"Result: {seq['generated_text']}")
| Step | Training Loss |
|---|---|
| 10 | 0.792200 |
| 20 | 0.416100 |
| 30 | 0.348600 |
| 40 | 0.323200 |
| 50 | 0.316300 |
| 60 | 0.317500 |
| 70 | 0.333600 |
| 80 | 0.329500 |
| 90 | 0.333400 |
| 100 | 0.309900 |
The following hyperparameters were used during training: