Text Generation
GGUF
English
llama.cpp
bitnet
ternary
1.58-bit
quantized
q4_k_m
edge
efficient-inference
cpu
tool-calling
Instructions to use Qapdex/SLM750-Edge-1.58-bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use Qapdex/SLM750-Edge-1.58-bit with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="Qapdex/SLM750-Edge-1.58-bit", filename="quantized_q4km.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Qapdex/SLM750-Edge-1.58-bit 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 Qapdex/SLM750-Edge-1.58-bit:Q4_K_M_QUANT # Run inference directly in the terminal: llama cli -hf Qapdex/SLM750-Edge-1.58-bit:Q4_K_M_QUANT
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Qapdex/SLM750-Edge-1.58-bit:Q4_K_M_QUANT # Run inference directly in the terminal: llama cli -hf Qapdex/SLM750-Edge-1.58-bit:Q4_K_M_QUANT
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 Qapdex/SLM750-Edge-1.58-bit:Q4_K_M_QUANT # Run inference directly in the terminal: ./llama-cli -hf Qapdex/SLM750-Edge-1.58-bit:Q4_K_M_QUANT
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 Qapdex/SLM750-Edge-1.58-bit:Q4_K_M_QUANT # Run inference directly in the terminal: ./build/bin/llama-cli -hf Qapdex/SLM750-Edge-1.58-bit:Q4_K_M_QUANT
Use Docker
docker model run hf.co/Qapdex/SLM750-Edge-1.58-bit:Q4_K_M_QUANT
- LM Studio
- Jan
- vLLM
How to use Qapdex/SLM750-Edge-1.58-bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Qapdex/SLM750-Edge-1.58-bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Qapdex/SLM750-Edge-1.58-bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Qapdex/SLM750-Edge-1.58-bit:Q4_K_M_QUANT
- Ollama
How to use Qapdex/SLM750-Edge-1.58-bit with Ollama:
ollama run hf.co/Qapdex/SLM750-Edge-1.58-bit:Q4_K_M_QUANT
- Unsloth Studio
How to use Qapdex/SLM750-Edge-1.58-bit 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 Qapdex/SLM750-Edge-1.58-bit 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 Qapdex/SLM750-Edge-1.58-bit to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Qapdex/SLM750-Edge-1.58-bit to start chatting
- Atomic Chat new
- Docker Model Runner
How to use Qapdex/SLM750-Edge-1.58-bit with Docker Model Runner:
docker model run hf.co/Qapdex/SLM750-Edge-1.58-bit:Q4_K_M_QUANT
- Lemonade
How to use Qapdex/SLM750-Edge-1.58-bit with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Qapdex/SLM750-Edge-1.58-bit:Q4_K_M_QUANT
Run and chat with the model
lemonade run user.SLM750-Edge-1.58-bit-Q4_K_M_QUANT
List all available models
lemonade list
| // | |
| // logging | |
| // | |
| static float frand(void) { | |
| return (float)rand()/(float)RAND_MAX; | |
| } | |
| static int irand(int n) { | |
| if (n == 0) return 0; | |
| return rand()%n; | |
| } | |
| static void get_random_dims(int64_t * dims, int ndims) { | |
| dims[0] = dims[1] = dims[2] = dims[3] = 1; | |
| for (int i = 0; i < ndims; i++) { | |
| dims[i] = 1 + irand(4); | |
| } | |
| } | |
| static struct ggml_tensor * get_random_tensor_f32( | |
| struct ggml_context * ctx0, | |
| int ndims, | |
| const int64_t ne[], | |
| float fmin, | |
| float fmax) { | |
| struct ggml_tensor * result = ggml_new_tensor(ctx0, GGML_TYPE_F32, ndims, ne); | |
| switch (ndims) { | |
| case 1: | |
| for (int i0 = 0; i0 < ne[0]; i0++) { | |
| ((float *)result->data)[i0] = frand()*(fmax - fmin) + fmin; | |
| } | |
| break; | |
| case 2: | |
| for (int i1 = 0; i1 < ne[1]; i1++) { | |
| for (int i0 = 0; i0 < ne[0]; i0++) { | |
| ((float *)result->data)[i1*ne[0] + i0] = frand()*(fmax - fmin) + fmin; | |
| } | |
| } | |
| break; | |
| case 3: | |
| for (int i2 = 0; i2 < ne[2]; i2++) { | |
| for (int i1 = 0; i1 < ne[1]; i1++) { | |
| for (int i0 = 0; i0 < ne[0]; i0++) { | |
| ((float *)result->data)[i2*ne[1]*ne[0] + i1*ne[0] + i0] = frand()*(fmax - fmin) + fmin; | |
| } | |
| } | |
| } | |
| break; | |
| case 4: | |
| for (int i3 = 0; i3 < ne[3]; i3++) { | |
| for (int i2 = 0; i2 < ne[2]; i2++) { | |
| for (int i1 = 0; i1 < ne[1]; i1++) { | |
| for (int i0 = 0; i0 < ne[0]; i0++) { | |
| ((float *)result->data)[i3*ne[2]*ne[1]*ne[0] + i2*ne[1]*ne[0] + i1*ne[0] + i0] = frand()*(fmax - fmin) + fmin; | |
| } | |
| } | |
| } | |
| } | |
| break; | |
| default: | |
| assert(false); | |
| }; | |
| return result; | |
| } | |
| static void ggml_graph_compute_helper(std::vector<uint8_t> & buf, ggml_cgraph * graph, int n_threads) { | |
| struct ggml_cplan plan = ggml_graph_plan(graph, n_threads, nullptr); | |
| if (plan.work_size > 0) { | |
| buf.resize(plan.work_size); | |
| plan.work_data = buf.data(); | |
| } | |
| ggml_graph_compute(graph, &plan); | |
| } | |
| int main(int /*argc*/, const char ** /*argv*/) { | |
| struct ggml_init_params params = { | |
| /* .mem_size = */ 128*1024*1024, | |
| /* .mem_buffer = */ NULL, | |
| /* .no_alloc = */ false, | |
| }; | |
| std::vector<uint8_t> work_buffer; | |
| struct ggml_context * ctx0 = ggml_init(params); | |
| struct ggml_tensor * x; | |
| // rope f32 | |
| for (int m = 0; m < 3; ++m) { | |
| const int ndims = 4; | |
| const int64_t n_rot = 128; | |
| const int64_t ne[4] = { 2*n_rot, 32, 73, 1 }; | |
| const int n_past_0 = 100; | |
| const int n_past_2 = 33; | |
| struct ggml_tensor * p0 = ggml_new_tensor_1d(ctx0, GGML_TYPE_I32, ne[2]); | |
| struct ggml_tensor * p1 = ggml_new_tensor_1d(ctx0, GGML_TYPE_I32, ne[2]); | |
| struct ggml_tensor * p2 = ggml_new_tensor_1d(ctx0, GGML_TYPE_I32, ne[2]); | |
| for (int i = 0; i < ne[2]; ++i) { | |
| ((int32_t *) p0->data)[i] = n_past_0 + i; | |
| ((int32_t *) p1->data)[i] = n_past_2 - n_past_0; | |
| ((int32_t *) p2->data)[i] = n_past_2 + i; | |
| } | |
| // test mode 0, 2, 4 (standard, GPT-NeoX, GLM) | |
| const int mode = m == 0 ? 0 : m == 1 ? 2 : 4; | |
| x = get_random_tensor_f32(ctx0, ndims, ne, -1.0f, 1.0f); | |
| // 100, 101, 102, ..., 172 | |
| struct ggml_tensor * r0 = ggml_rope(ctx0, x, p0, n_rot, mode); | |
| // -67, -67, -67, ..., -67 | |
| struct ggml_tensor * r1 = ggml_rope(ctx0, r0, p1, n_rot, mode); // "context swap", i.e. forget n_past_0 - n_past_2 tokens | |
| // 33, 34, 35, ..., 105 | |
| struct ggml_tensor * r2 = ggml_rope(ctx0, x, p2, n_rot, mode); | |
| ggml_cgraph * gf = ggml_new_graph(ctx0); | |
| ggml_build_forward_expand(gf, r0); | |
| ggml_build_forward_expand(gf, r1); | |
| ggml_build_forward_expand(gf, r2); | |
| ggml_graph_compute_helper(work_buffer, gf, 4); | |
| // check that r1 and r2 are the same | |
| { | |
| double sum0 = 0.0f; | |
| double sum1 = 0.0f; | |
| double diff = 0.0f; | |
| const float * r1_data = (float *) r1->data; | |
| const float * r2_data = (float *) r2->data; | |
| const int n_elements = ggml_nelements(r1); | |
| for (int i = 0; i < n_elements; ++i) { | |
| sum0 += fabs(r1_data[i]); | |
| sum1 += fabs(r2_data[i]); | |
| diff += fabs(r1_data[i] - r2_data[i]); | |
| //if (fabs(r1_data[i] - r2_data[i]) > 0.0001f) { | |
| // printf("%d: %f %f\n", i, r1_data[i], r2_data[i]); | |
| // printf("diff: %f\n", fabs(r1_data[i] - r2_data[i])); | |
| //} | |
| } | |
| //for (int i = 4096; i < 4096 + 128; ++i) { | |
| // printf("%f %f\n", r1_data[i], r2_data[i]); | |
| //} | |
| printf("mode: %d\n", mode); | |
| printf("sum0: %f\n", sum0); | |
| printf("sum1: %f\n", sum1); | |
| printf("diff: %f\n", diff); | |
| printf("rel err: %f\n", diff / sum0); | |
| printf("rel err: %f\n", diff / sum1); | |
| GGML_ASSERT(diff / sum0 < 0.0001f); | |
| GGML_ASSERT(diff / sum1 < 0.0001f); | |
| } | |
| } | |
| ggml_free(ctx0); | |
| return 0; | |
| } | |