Instructions to use thesven/Phi-nut-Butter-Codebagel-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use thesven/Phi-nut-Butter-Codebagel-v1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="thesven/Phi-nut-Butter-Codebagel-v1", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("thesven/Phi-nut-Butter-Codebagel-v1", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("thesven/Phi-nut-Butter-Codebagel-v1", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use thesven/Phi-nut-Butter-Codebagel-v1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "thesven/Phi-nut-Butter-Codebagel-v1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thesven/Phi-nut-Butter-Codebagel-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/thesven/Phi-nut-Butter-Codebagel-v1
- SGLang
How to use thesven/Phi-nut-Butter-Codebagel-v1 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 "thesven/Phi-nut-Butter-Codebagel-v1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thesven/Phi-nut-Butter-Codebagel-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "thesven/Phi-nut-Butter-Codebagel-v1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thesven/Phi-nut-Butter-Codebagel-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use thesven/Phi-nut-Butter-Codebagel-v1 with Docker Model Runner:
docker model run hf.co/thesven/Phi-nut-Butter-Codebagel-v1
Phi-nut-Butter-Codebagel-v1
Model Details
Model Name: Phi-nut-Butter-Codebagel-v1
Base Model: microsoft/Phi-3-mini-128k-instruct
Fine-tuning Method: Supervised Fine-Tuning (SFT)
Dataset: Code Bagel
Training Data: 75,000 randomly selected rows from Code Bagel dataset
Training Duration: 23 hours
Hardware: Nvidia RTX A4500
Epochs: 3
Training Procedure
This model was fine-tuned to provide better instructions on code.
The training was conducted using PEFT and SFTTrainer on the Code Bagel dataset. Training was completed in 3 epochs over a span of 23 hours on an Nvidia A4500 GPU.
Intended Use
This model is designed to improve instruction-following capabilities, particularly for code-related tasks.
Getting Started
Instruct Template
<|system|>
{system_message} <|end|>
<|user|>
{Prompt) <|end|>
<|assistant|>
Transfromers
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
model_name_or_path = "thesven/Phi-nut-Butter-Codebagel-v1"
# BitsAndBytesConfig for loading the model in 4-bit precision
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype="float16",
)
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
model = AutoModelForCausalLM.from_pretrained(
model_name_or_path,
device_map="auto",
trust_remote_code=False,
revision="main",
quantization_config=bnb_config
)
model.pad_token = model.config.eos_token_id
prompt_template = '''
<|system|>
You are an expert developer. Please help me with any coding questions.<|end|>
<|user|>
Create a function to get the total sum from an array of ints.<|end|>
<|assistant|>
'''
input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
output = model.generate(inputs=input_ids, temperature=0.1, do_sample=True, top_p=0.95, top_k=40, max_new_tokens=256)
generated_text = tokenizer.decode(output[0, len(input_ids[0]):], skip_special_tokens=True)
print(generated_text)
- Downloads last month
- 5
