Instructions to use AJKADZ/PHI_CODER with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use AJKADZ/PHI_CODER with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf AJKADZ/PHI_CODER:Q4_K_M # Run inference directly in the terminal: llama cli -hf AJKADZ/PHI_CODER:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf AJKADZ/PHI_CODER:Q4_K_M # Run inference directly in the terminal: llama cli -hf AJKADZ/PHI_CODER: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 AJKADZ/PHI_CODER:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf AJKADZ/PHI_CODER: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 AJKADZ/PHI_CODER:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf AJKADZ/PHI_CODER:Q4_K_M
Use Docker
docker model run hf.co/AJKADZ/PHI_CODER:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use AJKADZ/PHI_CODER with Ollama:
ollama run hf.co/AJKADZ/PHI_CODER:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use AJKADZ/PHI_CODER with Docker Model Runner:
docker model run hf.co/AJKADZ/PHI_CODER:Q4_K_M
- Lemonade
How to use AJKADZ/PHI_CODER with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull AJKADZ/PHI_CODER:Q4_K_M
Run and chat with the model
lemonade run user.PHI_CODER-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Download phi-coder-hf/llama.cpp/common/ngram-cache.h from AJKADZ/PHI_CODER: direct link, hf CLI and curl.
- Browser
- Download file 4.24 kB
-
https://huggingface.co/AJKADZ/PHI_CODER/resolve/main/phi-coder-hf/llama.cpp/common/ngram-cache.h
- Command line
-
hf download hf://AJKADZ/PHI_CODER/phi-coder-hf/llama.cpp/common/ngram-cache.h
-
curl -L -o ngram-cache.h https://huggingface.co/AJKADZ/PHI_CODER/resolve/main/phi-coder-hf/llama.cpp/common/ngram-cache.h
4.24 kB
| // Data structures to map n-grams to empirical token probabilities: | |
| struct common_ngram { | |
| llama_token tokens[LLAMA_NGRAM_MAX]; | |
| common_ngram() { | |
| for (int i = 0; i < LLAMA_NGRAM_MAX; ++i) { | |
| tokens[i] = LLAMA_TOKEN_NULL; | |
| } | |
| } | |
| common_ngram(const llama_token * input, const int ngram_size) { | |
| for (int i = 0; i < LLAMA_NGRAM_MAX; ++i) { | |
| tokens[i] = i < ngram_size ? input[i] : LLAMA_TOKEN_NULL; | |
| } | |
| } | |
| bool operator==(const common_ngram & other) const { | |
| for (int i = 0; i < LLAMA_NGRAM_MAX; ++i) { | |
| if (tokens[i] != other.tokens[i]) { | |
| return false; | |
| } | |
| } | |
| return true; | |
| } | |
| }; | |
| struct common_token_hash_function { | |
| size_t operator()(const llama_token token) const { | |
| // see https://probablydance.com/2018/06/16/fibonacci-hashing-the-optimization-that-the-world-forgot-or-a-better-alternative-to-integer-modulo/ | |
| return token * 11400714819323198485llu; | |
| } | |
| }; | |
| struct common_ngram_hash_function { | |
| size_t operator()(const common_ngram & ngram) const { | |
| size_t hash = common_token_hash_function{}(ngram.tokens[0]); | |
| for (int i = 1; i < LLAMA_NGRAM_MAX; ++i) { | |
| hash ^= common_token_hash_function{}(ngram.tokens[i]); | |
| } | |
| return hash; | |
| } | |
| }; | |
| // token -> number of times token has been seen | |
| typedef std::unordered_map<llama_token, int32_t> common_ngram_cache_part; | |
| // n-gram -> empirical distribution of following tokens | |
| typedef std::unordered_map<common_ngram, common_ngram_cache_part, common_ngram_hash_function> common_ngram_cache; | |
| // Update an ngram cache with tokens. | |
| // ngram_cache: the cache to modify. | |
| // ngram_min/ngram_max: the min/max size of the ngrams to extract from inp_data. | |
| // inp_data: the token sequence with which to update ngram_cache. | |
| // nnew: how many new tokens have been appended to inp_data since the last call to this function. | |
| // print_progress: whether to print progress to stderr. | |
| // | |
| // In order to get correct results inp_data can ONLY BE APPENDED TO. | |
| // Changes in the middle need a complete rebuild. | |
| void common_ngram_cache_update( | |
| common_ngram_cache & ngram_cache, int ngram_min, int ngram_max, std::vector<llama_token> & inp_data, int nnew, bool print_progress); | |
| // Try to draft tokens from ngram caches. | |
| // inp: the tokens generated so far. | |
| // draft: the token sequence to draft. Expected to initially contain the previously sampled token. | |
| // n_draft: maximum number of tokens to add to draft. | |
| // ngram_min/gram_max: the min/max size of the ngrams in nc_context and nc_dynamic. | |
| // nc_context: ngram cache based on current context. | |
| // nc_dynamic: ngram cache based on previous user generations. | |
| // nc_static: ngram cache generated from a large text corpus, used for validation. | |
| void common_ngram_cache_draft( | |
| std::vector<llama_token> & inp, std::vector<llama_token> & draft, int n_draft, int ngram_min, int ngram_max, | |
| common_ngram_cache & nc_context, common_ngram_cache & nc_dynamic, common_ngram_cache & nc_static); | |
| // Save an ngram cache to a file. | |
| // ngram_cache: the ngram cache to save. | |
| // filename: the path under which to save the ngram cache. | |
| void common_ngram_cache_save(common_ngram_cache & ngram_cache, std::string & filename); | |
| // Load an ngram cache saved with common_ngram_cache_save. | |
| // filename: the path from which to load the ngram cache. | |
| // returns: an ngram cache containing the information saved to filename. | |
| common_ngram_cache common_ngram_cache_load(std::string & filename); | |
| // Merge two ngram caches. | |
| // ngram_cache_target: the ngram cache to which to add the information from ngram_cache_add. | |
| // ngram_cache_add: the ngram cache to add to ngram_cache_target. | |
| void common_ngram_cache_merge(common_ngram_cache & ngram_cache_target, common_ngram_cache & ngram_cache_add); | |