Instructions to use nold/Phi-3-mini-4k-instruct-function-calling-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use nold/Phi-3-mini-4k-instruct-function-calling-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="nold/Phi-3-mini-4k-instruct-function-calling-GGUF", filename="Phi-3-mini-4k-instruct-function-calling_Q2_K.gguf", )
llm.create_chat_completion( messages = "No input example has been defined for this model task." )
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use nold/Phi-3-mini-4k-instruct-function-calling-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf nold/Phi-3-mini-4k-instruct-function-calling-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf nold/Phi-3-mini-4k-instruct-function-calling-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf nold/Phi-3-mini-4k-instruct-function-calling-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf nold/Phi-3-mini-4k-instruct-function-calling-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf nold/Phi-3-mini-4k-instruct-function-calling-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf nold/Phi-3-mini-4k-instruct-function-calling-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf nold/Phi-3-mini-4k-instruct-function-calling-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf nold/Phi-3-mini-4k-instruct-function-calling-GGUF:Q4_K_M
Use Docker
docker model run hf.co/nold/Phi-3-mini-4k-instruct-function-calling-GGUF:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use nold/Phi-3-mini-4k-instruct-function-calling-GGUF with Ollama:
ollama run hf.co/nold/Phi-3-mini-4k-instruct-function-calling-GGUF:Q4_K_M
- Unsloth Studio new
How to use nold/Phi-3-mini-4k-instruct-function-calling-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for nold/Phi-3-mini-4k-instruct-function-calling-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for nold/Phi-3-mini-4k-instruct-function-calling-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for nold/Phi-3-mini-4k-instruct-function-calling-GGUF to start chatting
- Docker Model Runner
How to use nold/Phi-3-mini-4k-instruct-function-calling-GGUF with Docker Model Runner:
docker model run hf.co/nold/Phi-3-mini-4k-instruct-function-calling-GGUF:Q4_K_M
- Lemonade
How to use nold/Phi-3-mini-4k-instruct-function-calling-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull nold/Phi-3-mini-4k-instruct-function-calling-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.Phi-3-mini-4k-instruct-function-calling-GGUF-Q4_K_M
List all available models
lemonade list
Model
Fine-tuned the Phi3 instruction model for function calling via MLX-LM using https://huggingface.co/datasets/mzbac/function-calling-phi-3-format-v1.1
Usage
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "mzbac/Phi-3-mini-4k-instruct-function-calling"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
)
tool = {
"name": "search_web",
"description": "Perform a web search for a given search terms.",
"parameter": {
"type": "object",
"properties": {
"search_terms": {
"type": "array",
"items": {"type": "string"},
"description": "The search queries for which the search is performed.",
"required": True,
}
},
},
}
messages = [
{
"role": "user",
"content": f"You are a helpful assistant with access to the following functions. Use them if required - {str(tool)}",
},
{"role": "user", "content": "Any news in Melbourne today, May 7, 2024?"},
]
input_ids = tokenizer.apply_chat_template(
messages, add_generation_prompt=True, return_tensors="pt"
).to(model.device)
terminators = [tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<|end|>")]
outputs = model.generate(
input_ids,
max_new_tokens=256,
eos_token_id=terminators,
do_sample=True,
temperature=0.1,
)
response = outputs[0]
print(tokenizer.decode(response))
# <s><|user|> You are a helpful assistant with access to the following functions. Use them if required - {'name': 'search_web', 'description': 'Perform a web search for a given search terms.', 'parameter': {'type': 'object', 'properties': {'search_terms': {'type': 'array', 'items': {'type': 'string'}, 'description': 'The search queries for which the search is performed.', 'required': True}}}}<|end|><|assistant|>
# <|user|> Any news in Melbourne today, May 7, 2024?<|end|>
# <|assistant|> <functioncall> {"name": "search_web", "arguments": {"search_terms": ["news", "Melbourne", "May 7, 2024"]}}<|end|>
Training hyperparameters
lora_config.yaml
# The path to the local model directory or Hugging Face repo.
model: "microsoft/Phi-3-mini-4k-instruct"
# Whether or not to train (boolean)
train: true
# Directory with {train, valid, test}.jsonl files
data: "data"
# The PRNG seed
seed: 0
# Number of layers to fine-tune
lora_layers: 32
# Minibatch size.
batch_size: 1
# Iterations to train for.
iters: 111000
# Number of validation batches, -1 uses the entire validation set.
val_batches: -1
# Adam learning rate.
learning_rate: 1e-6
# Number of training steps between loss reporting.
steps_per_report: 10
# Number of training steps between validations.
steps_per_eval: 200
# Load path to resume training with the given adapter weights.
# resume_adapter_file: "adapters/adapters.safetensors"
# Save/load path for the trained adapter weights.
adapter_path: "adapters"
# Save the model every N iterations.
save_every: 1000
# Evaluate on the test set after training
test: false
# Number of test set batches, -1 uses the entire test set.
test_batches: 100
# Maximum sequence length.
max_seq_length: 4096
# Use gradient checkpointing to reduce memory use.
grad_checkpoint: false
# LoRA parameters can only be specified in a config file
lora_parameters:
# The layer keys to apply LoRA to.
# These will be applied for the last lora_layers
keys: ['mlp.down_proj','mlp.gate_up_proj','self_attn.qkv_proj','self_attn.o_proj']
rank: 128
alpha: 256
scale: 10.0
dropout: 0.05
Quantization of Model mzbac/Phi-3-mini-4k-instruct-function-calling. Created using llm-quantizer Pipeline
- Downloads last month
- 180
2-bit
3-bit
4-bit
5-bit
6-bit
8-bit