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.
- 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
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 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
- Llama new
- 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 Desktop
- 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
- Atomic Chat
File size: 3,158 Bytes
0863006 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | #include "llama.h"
#include "common.h" // Hilfsfunktionen aus dem llama.cpp Repository
#include <iostream>
#include <string>
#include <vector>
// GBNF Grammatik-Definition, die das Modell auf exakte JSON-Tool-Calls zwingt
const std::string JSON_GRAMMAR =
"root ::= object\n"
"object ::= \"{\n \\\"action\\\": \\\"\" name \"\\\",\n \\\"parameters\\\": \" params \"\n}\"\n"
"name ::= [a-zA-Z0-9_]+\n"
"params ::= \"{\n \" pair ( \",\n \" pair )* \"\n }\"\n"
"pair ::= \"\\\"\" [a-zA-Z0-9_]+ \"\\\": \\\"\" [^\"]* \"\\\"\"";
int main(int argc, char ** argv) {
// 1. Hardware-Parameter für Smartphone-SoCs initialisieren
llama_model_params model_params = llama_model_default_params();
#if defined(__ARM_NEON) || defined(__APPLE__)
model_params.use_mmap = true; // Direktes Mapping in den RAM (schont die Batterie)
model_params.main_gpu = 0; // Nutze GPU/NPU falls via Metal/Vulkan kompiliert
#endif
// 2. Das kompakte 300MB Modell laden
std::string model_path = "slm750_edge_q4_k.gguf";
llama_model * model = llama_load_model_from_file(model_path.c_str(), model_params);
if (!model) {
std::cerr << "Fehler: Modell konnte nicht geladen werden!" << std::endl;
return 1;
}
// 3. Kontext für hocheffizientes Batch-Processing aufsetzen
llama_context_params ctx_params = llama_context_default_params();
ctx_params.n_ctx = 2048; // Gleiche Kontext-Länge wie im Trainings-Skript von Neo
ctx_params.n_batch = 512;
ctx_params.n_threads = 4; // Optimal für die "Big-Cores" moderner Smartphone-CPUs
llama_context * ctx = llama_new_context_with_model(model, ctx_params);
// 4. Grammatik-Parser initialisieren (Der "Wow-Effekt" Garant für 100% JSON-Validität)
auto grammar = llama_grammar_init(JSON_GRAMMAR.c_str());
// 5. Prompt für den Tool-Call vorbereiten
std::string prompt = "User: Erstelle eine neue Stellenausschreibung für einen Senior App Developer.\nAgent:";
std::vector<llama_token> tokens = llama_tokenize(ctx, prompt, true);
// Prompt in den KV-Cache evaluieren
llama_decode(ctx, llama_batch_get_one(tokens.data(), tokens.size(), 0, 0));
std::cout << "Generiere ultraschnellen Tool-Call...\n" << std::endl;
// 6. Token-Generierungs-Schleife mit Grammatik-Zwang
for (int i = 0; i < 200; ++i) {
auto candidates = llama_sampler_get_candidates(ctx);
// Zwinge das Modell, nur Tokens zu wählen, die zur JSON-Grammatik passen
llama_grammar_sample(grammar, ctx, &candidates);
llama_token token = llama_sampler_sample(ctx, &candidates);
// Abbruch bei End-of-Token
if (token == llama_token_eos(model)) break;
// Token sofort auf dem Bildschirm ausgeben
std::cout << llama_token_to_piece(ctx, token);
std::flush(std::cout);
// Nächstes Token verarbeiten
llama_decode(ctx, llama_batch_get_one(&token, 1, i + tokens.size(), 0));
}
// Speicherbereinigung
llama_grammar_free(grammar);
llama_free(ctx);
llama_free_model(model);
return 0;
}
|