Instructions to use VladHong/llama-cpp-K2-FAST2 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 VladHong/llama-cpp-K2-FAST2 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 VladHong/llama-cpp-K2-FAST2 # Run inference directly in the terminal: llama cli -hf VladHong/llama-cpp-K2-FAST2
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf VladHong/llama-cpp-K2-FAST2 # Run inference directly in the terminal: llama cli -hf VladHong/llama-cpp-K2-FAST2
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf VladHong/llama-cpp-K2-FAST2 # Run inference directly in the terminal: ./build/bin/llama cli -hf VladHong/llama-cpp-K2-FAST2
Use Docker
docker model run hf.co/VladHong/llama-cpp-K2-FAST2
- Llama new
- LM Studio
- Jan
- Ollama
How to use VladHong/llama-cpp-K2-FAST2 with Ollama:
ollama run hf.co/VladHong/llama-cpp-K2-FAST2
- Unsloth Desktop
- Docker Model Runner
How to use VladHong/llama-cpp-K2-FAST2 with Docker Model Runner:
docker model run hf.co/VladHong/llama-cpp-K2-FAST2
- Lemonade
How to use VladHong/llama-cpp-K2-FAST2 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull VladHong/llama-cpp-K2-FAST2
Run and chat with the model
lemonade run user.llama-cpp-K2-FAST2-{{QUANT_TAG}}List all available models
lemonade list
- Atomic Chat
Download tools/cli/cli-client.cpp from VladHong/llama-cpp-K2-FAST2: direct link, hf CLI and curl.
- Browser
- Download file 5 kB
-
https://huggingface.co/VladHong/llama-cpp-K2-FAST2/resolve/main/tools/cli/cli-client.cpp
- Command line
-
hf download hf://VladHong/llama-cpp-K2-FAST2/tools/cli/cli-client.cpp
-
curl -L -o cli-client.cpp https://huggingface.co/VladHong/llama-cpp-K2-FAST2/resolve/main/tools/cli/cli-client.cpp
5 kB
| // generation can stall for a long time during prompt processing, so the | |
| // read timeout must be generous | |
| static constexpr time_t CLI_HTTP_READ_TIMEOUT_SEC = 3600; | |
| // upper bound for the accumulated response body kept for error reporting | |
| static constexpr size_t CLI_HTTP_MAX_ERROR_BODY = 1024 * 1024; | |
| // returns the path with the base url's path prefix prepended (if any) | |
| static std::string join_path(const common_http_url & parts, const std::string & path) { | |
| if (parts.path.empty() || parts.path == "/") { | |
| return path; | |
| } | |
| std::string prefix = parts.path; | |
| if (prefix.back() == '/') { | |
| prefix.pop_back(); | |
| } | |
| return prefix + path; | |
| } | |
| std::string cli_client::get(const std::string & path) { | |
| auto [cli, parts] = common_http_client(server_base); | |
| cli.set_read_timeout(CLI_HTTP_READ_TIMEOUT_SEC, 0); | |
| auto path_with_model = path + (model.empty() ? "" : ("?model=" + model)); | |
| auto res = cli.Get(join_path(parts, path_with_model)); | |
| if (!res) { | |
| throw std::runtime_error("failed to connect to " + server_base + ": " + httplib::to_string(res.error())); | |
| } | |
| if (res->status < 200 || res->status >= 300) { | |
| throw std::runtime_error("GET " + path + " failed with status " + std::to_string(res->status) + ": " + res->body); | |
| } | |
| return res->body; | |
| } | |
| std::string cli_client::post(const std::string & path, const std::string & body) { | |
| auto [cli, parts] = common_http_client(server_base); | |
| cli.set_read_timeout(CLI_HTTP_READ_TIMEOUT_SEC, 0); | |
| auto res = cli.Post(join_path(parts, path), body, "application/json"); | |
| if (!res) { | |
| throw std::runtime_error("failed to connect to " + server_base + ": " + httplib::to_string(res.error())); | |
| } | |
| if (res->status < 200 || res->status >= 300) { | |
| throw std::runtime_error("POST " + path + " failed with status " + std::to_string(res->status) + ": " + res->body); | |
| } | |
| return res->body; | |
| } | |
| std::string cli_client::post_sse(const std::string & path, | |
| const std::string & body, | |
| const std::function<bool()> & should_stop, | |
| const std::function<void(const std::string &)> & on_data) { | |
| auto [cli, parts] = common_http_client(server_base); | |
| cli.set_read_timeout(CLI_HTTP_READ_TIMEOUT_SEC, 0); | |
| std::string pending; // buffer for incomplete SSE lines | |
| std::string raw_body; // accumulated body, used only for error reporting | |
| auto receiver = [&](const char * data, size_t len) -> bool { | |
| if (should_stop()) { | |
| return false; // aborts the request | |
| } | |
| if (raw_body.size() < CLI_HTTP_MAX_ERROR_BODY) { | |
| raw_body.append(data, std::min(len, CLI_HTTP_MAX_ERROR_BODY - raw_body.size())); | |
| } | |
| pending.append(data, len); | |
| size_t pos; | |
| while ((pos = pending.find('\n')) != std::string::npos) { | |
| std::string line = pending.substr(0, pos); | |
| pending.erase(0, pos + 1); | |
| if (!line.empty() && line.back() == '\r') { | |
| line.pop_back(); | |
| } | |
| if (line.rfind("data: ", 0) != 0) { | |
| continue; | |
| } | |
| std::string payload = line.substr(6); | |
| if (payload == "[DONE]") { | |
| continue; | |
| } | |
| on_data(payload); | |
| } | |
| return true; | |
| }; | |
| httplib::Headers headers = {{"Accept", "text/event-stream"}}; | |
| auto res = cli.Post(join_path(parts, path), headers, body, "application/json", receiver); | |
| if (!res) { | |
| if (res.error() == httplib::Error::Canceled && should_stop()) { | |
| return ""; // cancelled by the user | |
| } | |
| return "failed to connect to " + server_base + ": " + httplib::to_string(res.error()); | |
| } | |
| if (res->status < 200 || res->status >= 300) { | |
| if (!raw_body.empty()) { | |
| return raw_body; | |
| } | |
| return "request failed with status " + std::to_string(res->status); | |
| } | |
| return ""; | |
| } | |
| bool cli_client::wait_health(const std::function<bool()> & is_aborted) { | |
| int connect_attempts = 0; | |
| while (!is_aborted()) { | |
| auto [cli, parts] = common_http_client(server_base); | |
| cli.set_connection_timeout(1, 0); | |
| auto res = cli.Get(join_path(parts, "/health")); | |
| if (res) { | |
| if (res->status == 200) { | |
| return true; | |
| } | |
| // any other status means the server is up but not ready yet | |
| // (e.g. 503 while the model is still loading) | |
| } else if (++connect_attempts >= 10) { | |
| last_error = "failed to connect to " + server_base + ": " + httplib::to_string(res.error()); | |
| return false; | |
| } | |
| std::this_thread::sleep_for(std::chrono::milliseconds(300)); | |
| } | |
| last_error = "aborted while waiting for the server to become ready"; | |
| return false; | |
| } | |