Instructions to use andrijdavid/phi-2-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use andrijdavid/phi-2-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="andrijdavid/phi-2-GGUF", filename="ggml-model-Q2_K.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use andrijdavid/phi-2-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf andrijdavid/phi-2-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf andrijdavid/phi-2-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 andrijdavid/phi-2-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf andrijdavid/phi-2-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 andrijdavid/phi-2-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf andrijdavid/phi-2-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 andrijdavid/phi-2-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf andrijdavid/phi-2-GGUF:Q4_K_M
Use Docker
docker model run hf.co/andrijdavid/phi-2-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use andrijdavid/phi-2-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "andrijdavid/phi-2-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "andrijdavid/phi-2-GGUF", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/andrijdavid/phi-2-GGUF:Q4_K_M
- Ollama
How to use andrijdavid/phi-2-GGUF with Ollama:
ollama run hf.co/andrijdavid/phi-2-GGUF:Q4_K_M
- Unsloth Studio new
How to use andrijdavid/phi-2-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 andrijdavid/phi-2-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 andrijdavid/phi-2-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for andrijdavid/phi-2-GGUF to start chatting
- Docker Model Runner
How to use andrijdavid/phi-2-GGUF with Docker Model Runner:
docker model run hf.co/andrijdavid/phi-2-GGUF:Q4_K_M
- Lemonade
How to use andrijdavid/phi-2-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull andrijdavid/phi-2-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.phi-2-GGUF-Q4_K_M
List all available models
lemonade list
This repository contains GGUF format model files for Microsoft's Phi 2.
Model Summary
Phi-2 is a Transformer with 2.7 billion parameters. It was trained using the same data sources as Phi-1.5, augmented with a new data source that consists of various NLP synthetic texts and filtered websites (for safety and educational value). When assessed against benchmarks testing common sense, language understanding, and logical reasoning, Phi-2 showcased a nearly state-of-the-art performance among models with less than 13 billion parameters.
This hasn't been fine-tuned through reinforcement learning from human feedback. The intention behind crafting this open-source model is to provide the research community with a non-restricted small model to explore vital safety challenges, such as reducing toxicity, understanding societal biases, enhancing controllability, and more.
QA Format:
You can provide the prompt as a standalone question as follows:
Write a detailed analogy between mathematics and a lighthouse.
where the model generates the text after "." . To encourage the model to write more concise answers, you can also try the following QA format using "Instruct: <prompt>\nOutput:"
Instruct: Write a detailed analogy between mathematics and a lighthouse.
Output: Mathematics is like a lighthouse. Just as a lighthouse guides ships safely to shore, mathematics provides a guiding light in the world of numbers and logic. It helps us navigate through complex problems and find solutions. Just as a lighthouse emits a steady beam of light, mathematics provides a consistent framework for reasoning and problem-solving. It illuminates the path to understanding and helps us make sense of the world around us.
where the model generates the text after "Output:".
Chat Format:
Alice: I don't know why, I'm struggling to maintain focus while studying. Any suggestions?
Bob: Well, have you tried creating a study schedule and sticking to it?
Alice: Yes, I have, but it doesn't seem to help much.
Bob: Hmm, maybe you should try studying in a quiet environment, like the library.
Alice: ...
where the model generates the text after the first "Bob:".
Code Format:
def print_prime(n):
"""
Print all primes between 1 and n
"""
primes = []
for num in range(2, n+1):
is_prime = True
for i in range(2, int(math.sqrt(num))+1):
if num % i == 0:
is_prime = False
break
if is_prime:
primes.append(num)
print(primes)
where the model generates the text after the comments.
Notes:
- Phi-2 is intended for research purposes. The model-generated text/code should be treated as a starting point rather than a definitive solution for potential use cases. Users should be cautious when employing these models in their applications.
- Direct adoption for production tasks is out of the scope of this research project. As a result, the Phi-2 model has not been tested to ensure that it performs adequately for any production-level application. Please refer to the limitation sections of this document for more details.
- If you are using
transformers>=4.36.0, always load the model withtrust_remote_code=Trueto prevent side-effects.
- Downloads last month
- 29
2-bit
3-bit
4-bit
5-bit
6-bit
8-bit
16-bit
Model tree for andrijdavid/phi-2-GGUF
Base model
microsoft/phi-2