Text Generation
Transformers
Safetensors
GGUF
llama
chatbot
multilingual
arabic
french
tamazight
english
conversational
text-generation-inference
4-bit precision
bitsandbytes
Instructions to use kaisser/LLM-Maroc with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kaisser/LLM-Maroc with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="kaisser/LLM-Maroc") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("kaisser/LLM-Maroc") model = AutoModelForCausalLM.from_pretrained("kaisser/LLM-Maroc", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use kaisser/LLM-Maroc 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 kaisser/LLM-Maroc:BF16 # Run inference directly in the terminal: llama cli -hf kaisser/LLM-Maroc:BF16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf kaisser/LLM-Maroc:BF16 # Run inference directly in the terminal: llama cli -hf kaisser/LLM-Maroc:BF16
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 kaisser/LLM-Maroc:BF16 # Run inference directly in the terminal: ./llama-cli -hf kaisser/LLM-Maroc:BF16
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 kaisser/LLM-Maroc:BF16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf kaisser/LLM-Maroc:BF16
Use Docker
docker model run hf.co/kaisser/LLM-Maroc:BF16
- LM Studio
- Jan
- vLLM
How to use kaisser/LLM-Maroc with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "kaisser/LLM-Maroc" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kaisser/LLM-Maroc", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/kaisser/LLM-Maroc:BF16
- SGLang
How to use kaisser/LLM-Maroc with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "kaisser/LLM-Maroc" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kaisser/LLM-Maroc", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "kaisser/LLM-Maroc" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kaisser/LLM-Maroc", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use kaisser/LLM-Maroc with Ollama:
ollama run hf.co/kaisser/LLM-Maroc:BF16
- Unsloth Studio
How to use kaisser/LLM-Maroc 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 kaisser/LLM-Maroc 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 kaisser/LLM-Maroc to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for kaisser/LLM-Maroc to start chatting
- Docker Model Runner
How to use kaisser/LLM-Maroc with Docker Model Runner:
docker model run hf.co/kaisser/LLM-Maroc:BF16
- Lemonade
How to use kaisser/LLM-Maroc with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull kaisser/LLM-Maroc:BF16
Run and chat with the model
lemonade run user.LLM-Maroc-BF16
List all available models
lemonade list
- Atomic Chat
| namespace fs = std::filesystem; | |
| // NOTE: this is copied from common.cpp to avoid linking with libcommon | |
| // returns true if successful, false otherwise | |
| static bool fs_create_directory_with_parents(const std::string & path) { | |
| std::wstring_convert<std::codecvt_utf8<wchar_t>> converter; | |
| std::wstring wpath = converter.from_bytes(path); | |
| // if the path already exists, check whether it's a directory | |
| const DWORD attributes = GetFileAttributesW(wpath.c_str()); | |
| if ((attributes != INVALID_FILE_ATTRIBUTES) && (attributes & FILE_ATTRIBUTE_DIRECTORY)) { | |
| return true; | |
| } | |
| size_t pos_slash = 0; | |
| // process path from front to back, procedurally creating directories | |
| while ((pos_slash = path.find('\\', pos_slash)) != std::string::npos) { | |
| const std::wstring subpath = wpath.substr(0, pos_slash); | |
| const wchar_t * test = subpath.c_str(); | |
| const bool success = CreateDirectoryW(test, NULL); | |
| if (!success) { | |
| const DWORD error = GetLastError(); | |
| // if the path already exists, ensure that it's a directory | |
| if (error == ERROR_ALREADY_EXISTS) { | |
| const DWORD attributes = GetFileAttributesW(subpath.c_str()); | |
| if (attributes == INVALID_FILE_ATTRIBUTES || !(attributes & FILE_ATTRIBUTE_DIRECTORY)) { | |
| return false; | |
| } | |
| } else { | |
| return false; | |
| } | |
| } | |
| pos_slash += 1; | |
| } | |
| return true; | |
| // if the path already exists, check whether it's a directory | |
| struct stat info; | |
| if (stat(path.c_str(), &info) == 0) { | |
| return S_ISDIR(info.st_mode); | |
| } | |
| size_t pos_slash = 1; // skip leading slashes for directory creation | |
| // process path from front to back, procedurally creating directories | |
| while ((pos_slash = path.find('/', pos_slash)) != std::string::npos) { | |
| const std::string subpath = path.substr(0, pos_slash); | |
| struct stat info; | |
| // if the path already exists, ensure that it's a directory | |
| if (stat(subpath.c_str(), &info) == 0) { | |
| if (!S_ISDIR(info.st_mode)) { | |
| return false; | |
| } | |
| } else { | |
| // create parent directories | |
| const int ret = mkdir(subpath.c_str(), 0755); | |
| if (ret != 0) { | |
| return false; | |
| } | |
| } | |
| pos_slash += 1; | |
| } | |
| return true; | |
| } | |
| // NOTE: this is copied from common.cpp to avoid linking with libcommon | |
| static std::string fs_get_cache_directory() { | |
| std::string cache_directory = ""; | |
| auto ensure_trailing_slash = [](std::string p) { | |
| // Make sure to add trailing slash | |
| if (p.back() != DIRECTORY_SEPARATOR) { | |
| p += DIRECTORY_SEPARATOR; | |
| } | |
| return p; | |
| }; | |
| if (getenv("LLAMA_CACHE")) { | |
| cache_directory = std::getenv("LLAMA_CACHE"); | |
| } else { | |
| if (std::getenv("XDG_CACHE_HOME")) { | |
| cache_directory = std::getenv("XDG_CACHE_HOME"); | |
| } else { | |
| cache_directory = std::getenv("HOME") + std::string("/.cache/"); | |
| } | |
| cache_directory = std::getenv("HOME") + std::string("/Library/Caches/"); | |
| cache_directory = std::getenv("LOCALAPPDATA"); | |
| cache_directory = ensure_trailing_slash(cache_directory); | |
| cache_directory += "llama.cpp"; | |
| } | |
| return ensure_trailing_slash(cache_directory); | |
| } | |
| struct rpc_server_params { | |
| std::string host = "127.0.0.1"; | |
| int port = 50052; | |
| size_t backend_mem = 0; | |
| bool use_cache = false; | |
| int n_threads = std::max(1U, std::thread::hardware_concurrency()/2); | |
| std::string device; | |
| }; | |
| static void print_usage(int /*argc*/, char ** argv, rpc_server_params params) { | |
| fprintf(stderr, "Usage: %s [options]\n\n", argv[0]); | |
| fprintf(stderr, "options:\n"); | |
| fprintf(stderr, " -h, --help show this help message and exit\n"); | |
| fprintf(stderr, " -t, --threads number of threads for the CPU backend (default: %d)\n", params.n_threads); | |
| fprintf(stderr, " -d DEV, --device device to use\n"); | |
| fprintf(stderr, " -H HOST, --host HOST host to bind to (default: %s)\n", params.host.c_str()); | |
| fprintf(stderr, " -p PORT, --port PORT port to bind to (default: %d)\n", params.port); | |
| fprintf(stderr, " -m MEM, --mem MEM backend memory size (in MB)\n"); | |
| fprintf(stderr, " -c, --cache enable local file cache\n"); | |
| fprintf(stderr, "\n"); | |
| } | |
| static bool rpc_server_params_parse(int argc, char ** argv, rpc_server_params & params) { | |
| std::string arg; | |
| for (int i = 1; i < argc; i++) { | |
| arg = argv[i]; | |
| if (arg == "-H" || arg == "--host") { | |
| if (++i >= argc) { | |
| return false; | |
| } | |
| params.host = argv[i]; | |
| } else if (arg == "-t" || arg == "--threads") { | |
| if (++i >= argc) { | |
| return false; | |
| } | |
| params.n_threads = std::stoi(argv[i]); | |
| if (params.n_threads <= 0) { | |
| fprintf(stderr, "error: invalid number of threads: %d\n", params.n_threads); | |
| return false; | |
| } | |
| } else if (arg == "-d" || arg == "--device") { | |
| if (++i >= argc) { | |
| return false; | |
| } | |
| params.device = argv[i]; | |
| if (ggml_backend_dev_by_name(params.device.c_str()) == nullptr) { | |
| fprintf(stderr, "error: unknown device: %s\n", params.device.c_str()); | |
| fprintf(stderr, "available devices:\n"); | |
| for (size_t i = 0; i < ggml_backend_dev_count(); i++) { | |
| auto * dev = ggml_backend_dev_get(i); | |
| size_t free, total; | |
| ggml_backend_dev_memory(dev, &free, &total); | |
| printf(" %s: %s (%zu MiB, %zu MiB free)\n", ggml_backend_dev_name(dev), ggml_backend_dev_description(dev), total / 1024 / 1024, free / 1024 / 1024); | |
| } | |
| return false; | |
| } | |
| } else if (arg == "-p" || arg == "--port") { | |
| if (++i >= argc) { | |
| return false; | |
| } | |
| params.port = std::stoi(argv[i]); | |
| if (params.port <= 0 || params.port > 65535) { | |
| return false; | |
| } | |
| } else if (arg == "-c" || arg == "--cache") { | |
| params.use_cache = true; | |
| } else if (arg == "-m" || arg == "--mem") { | |
| if (++i >= argc) { | |
| return false; | |
| } | |
| params.backend_mem = std::stoul(argv[i]) * 1024 * 1024; | |
| } else if (arg == "-h" || arg == "--help") { | |
| print_usage(argc, argv, params); | |
| exit(0); | |
| } else { | |
| fprintf(stderr, "error: unknown argument: %s\n", arg.c_str()); | |
| print_usage(argc, argv, params); | |
| exit(0); | |
| } | |
| } | |
| return true; | |
| } | |
| static ggml_backend_t create_backend(const rpc_server_params & params) { | |
| ggml_backend_t backend = nullptr; | |
| if (!params.device.empty()) { | |
| ggml_backend_dev_t dev = ggml_backend_dev_by_name(params.device.c_str()); | |
| if (dev) { | |
| backend = ggml_backend_dev_init(dev, nullptr); | |
| if (!backend) { | |
| fprintf(stderr, "Failed to create backend for device %s\n", params.device.c_str()); | |
| return nullptr; | |
| } | |
| } | |
| } | |
| // try to initialize a GPU backend first | |
| if (!backend) { | |
| backend = ggml_backend_init_by_type(GGML_BACKEND_DEVICE_TYPE_GPU, nullptr); | |
| } | |
| // if there aren't GPU backends fallback to CPU backend | |
| if (!backend) { | |
| backend = ggml_backend_init_by_type(GGML_BACKEND_DEVICE_TYPE_CPU, nullptr); | |
| } | |
| if (backend) { | |
| fprintf(stderr, "%s: using %s backend\n", __func__, ggml_backend_name(backend)); | |
| // set the number of threads | |
| ggml_backend_dev_t dev = ggml_backend_get_device(backend); | |
| ggml_backend_reg_t reg = dev ? ggml_backend_dev_backend_reg(dev) : nullptr; | |
| if (reg) { | |
| auto ggml_backend_set_n_threads_fn = (ggml_backend_set_n_threads_t) ggml_backend_reg_get_proc_address(reg, "ggml_backend_set_n_threads"); | |
| if (ggml_backend_set_n_threads_fn) { | |
| ggml_backend_set_n_threads_fn(backend, params.n_threads); | |
| } | |
| } | |
| } | |
| return backend; | |
| } | |
| static void get_backend_memory(ggml_backend_t backend, size_t * free_mem, size_t * total_mem) { | |
| ggml_backend_dev_t dev = ggml_backend_get_device(backend); | |
| GGML_ASSERT(dev != nullptr); | |
| ggml_backend_dev_memory(dev, free_mem, total_mem); | |
| } | |
| int main(int argc, char * argv[]) { | |
| ggml_backend_load_all(); | |
| rpc_server_params params; | |
| if (!rpc_server_params_parse(argc, argv, params)) { | |
| fprintf(stderr, "Invalid parameters\n"); | |
| return 1; | |
| } | |
| if (params.host != "127.0.0.1") { | |
| fprintf(stderr, "\n"); | |
| fprintf(stderr, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); | |
| fprintf(stderr, "WARNING: Host ('%s') is != '127.0.0.1'\n", params.host.c_str()); | |
| fprintf(stderr, " Never expose the RPC server to an open network!\n"); | |
| fprintf(stderr, " This is an experimental feature and is not secure!\n"); | |
| fprintf(stderr, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); | |
| fprintf(stderr, "\n"); | |
| } | |
| ggml_backend_t backend = create_backend(params); | |
| if (!backend) { | |
| fprintf(stderr, "Failed to create backend\n"); | |
| return 1; | |
| } | |
| std::string endpoint = params.host + ":" + std::to_string(params.port); | |
| size_t free_mem, total_mem; | |
| if (params.backend_mem > 0) { | |
| free_mem = params.backend_mem; | |
| total_mem = params.backend_mem; | |
| } else { | |
| get_backend_memory(backend, &free_mem, &total_mem); | |
| } | |
| const char * cache_dir = nullptr; | |
| std::string cache_dir_str; | |
| if (params.use_cache) { | |
| cache_dir_str = fs_get_cache_directory() + "rpc/"; | |
| if (!fs_create_directory_with_parents(cache_dir_str)) { | |
| fprintf(stderr, "Failed to create cache directory: %s\n", cache_dir_str.c_str()); | |
| return 1; | |
| } | |
| cache_dir = cache_dir_str.c_str(); | |
| } | |
| ggml_backend_reg_t reg = ggml_backend_reg_by_name("RPC"); | |
| if (!reg) { | |
| fprintf(stderr, "Failed to find RPC backend\n"); | |
| return 1; | |
| } | |
| auto start_server_fn = (decltype(ggml_backend_rpc_start_server)*) ggml_backend_reg_get_proc_address(reg, "ggml_backend_rpc_start_server"); | |
| if (!start_server_fn) { | |
| fprintf(stderr, "Failed to obtain RPC backend start server function\n"); | |
| return 1; | |
| } | |
| start_server_fn(backend, endpoint.c_str(), cache_dir, free_mem, total_mem); | |
| ggml_backend_free(backend); | |
| return 0; | |
| } | |