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
| // Tests chat handling, including grammar generation and parsing for tool calling, for various templates. | |
| // | |
| // Also acts as a CLI to generate a Markdown summary of the formats of Jinja templates, | |
| // e.g. given Minja (http://github.com/google/minja) checked out in parent dir: | |
| // | |
| // cmake -B build && cmake --build build --parallel && ./build/bin/test-chat ../minja/build/tests/*.jinja 2>/dev/null | |
| // | |
| template <class T> | |
| static void assert_equals(const T & expected, const T & actual) { | |
| if (expected != actual) { | |
| std::cerr << "Expected: " << expected << std::endl; | |
| std::cerr << "Actual: " << actual << std::endl; | |
| std::cerr << std::flush; | |
| throw std::runtime_error("Test failed"); | |
| } | |
| } | |
| static void assert_equals(const char * expected, const std::string & actual) { | |
| return assert_equals<std::string>(expected, actual); | |
| } | |
| static void assert_throws(const std::function<void()> & fn, const std::string & expected_exception_pattern = "") { | |
| try { | |
| fn(); | |
| } catch (const std::exception & e) { | |
| if (expected_exception_pattern.empty()) { | |
| return; | |
| } | |
| std::regex expected_exception_regex(expected_exception_pattern); | |
| std::string actual_message = e.what(); | |
| if (std::regex_search(actual_message, expected_exception_regex)) { | |
| return; | |
| } | |
| throw std::runtime_error("Exception doesn't match expected pattern: " + actual_message + " (pattern: " + expected_exception_pattern + ")"); | |
| throw std::runtime_error("Exception of unexpected type: " + std::string(e.what())); | |
| } | |
| throw std::runtime_error("Exception was expected but not thrown"); | |
| } | |
| static void test_reasoning() { | |
| { | |
| common_chat_msg_parser builder("<tnk>Cogito</tnk>Ergo sum", /* is_partial= */ false, { | |
| /* .format = */ COMMON_CHAT_FORMAT_CONTENT_ONLY, | |
| /* .reasoning_format = */ COMMON_REASONING_FORMAT_NONE, | |
| /* .reasoning_in_content = */ false, | |
| /* .thinking_forced_open = */ false, | |
| }); | |
| assert_equals(false, builder.try_parse_reasoning("<tnk>", "</tnk>")); | |
| assert_equals("<tnk>Cogito</tnk>Ergo sum", builder.consume_rest()); | |
| } | |
| { | |
| common_chat_msg_parser builder("<tnk>Cogito</tnk>Ergo sum", /* is_partial= */ false, { | |
| /* .format = */ COMMON_CHAT_FORMAT_CONTENT_ONLY, | |
| /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK, | |
| /* .reasoning_in_content = */ false, | |
| /* .thinking_forced_open = */ false, | |
| }); | |
| assert_equals(true, builder.try_parse_reasoning("<tnk>", "</tnk>")); | |
| assert_equals(std::string("Cogito"), builder.result().reasoning_content); | |
| assert_equals("Ergo sum", builder.consume_rest()); | |
| } | |
| { | |
| common_chat_msg_parser builder("Cogito</tnk>Ergo sum", /* is_partial= */ false, { | |
| /* .format = */ COMMON_CHAT_FORMAT_CONTENT_ONLY, | |
| /* .reasoning_format = */ COMMON_REASONING_FORMAT_NONE, | |
| /* .reasoning_in_content = */ false, | |
| /* .thinking_forced_open = */ false, | |
| }); | |
| assert_equals(false, builder.try_parse_reasoning("<tnk>", "</tnk>")); | |
| assert_equals("Cogito</tnk>Ergo sum", builder.consume_rest()); | |
| } | |
| { | |
| common_chat_msg_parser builder("Cogito</tnk>Ergo sum", /* is_partial= */ false, { | |
| /* .format = */ COMMON_CHAT_FORMAT_CONTENT_ONLY, | |
| /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK, | |
| /* .reasoning_in_content = */ false, | |
| /* .thinking_forced_open = */ true, | |
| }); | |
| assert_equals(true, builder.try_parse_reasoning("<tnk>", "</tnk>")); | |
| assert_equals(std::string("Cogito"), builder.result().reasoning_content); | |
| assert_equals("Ergo sum", builder.consume_rest()); | |
| } | |
| { | |
| common_chat_msg_parser builder("Cogito</tnk>Ergo sum", /* is_partial= */ false, { | |
| /* .format = */ COMMON_CHAT_FORMAT_CONTENT_ONLY, | |
| /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK, | |
| /* .reasoning_in_content = */ true, | |
| /* .thinking_forced_open = */ true, | |
| }); | |
| assert_equals(true, builder.try_parse_reasoning("<tnk>", "</tnk>")); | |
| assert_equals("<think>Cogito</think>", builder.result().content); | |
| assert_equals("Ergo sum", builder.consume_rest()); | |
| } | |
| } | |
| static void test_regex() { | |
| auto test_throws = [](const std::string & input, const std::string & regex, const std::string & expected_exception_pattern = "") { | |
| common_chat_msg_parser builder(input, /* is_partial= */ false, {}); | |
| assert_throws([&]() { builder.consume_regex(common_regex(regex)); }, expected_exception_pattern); | |
| }; | |
| test_throws("Hello, world!", "abc", "^abc$"); | |
| test_throws("Hello, world!", "e", "^e$"); | |
| { | |
| common_chat_msg_parser builder("Hello, world!", /* is_partial= */ false, {}); | |
| builder.consume_regex(common_regex("Hello")); | |
| assert_equals(", world!", builder.consume_rest()); | |
| } | |
| { | |
| // When in non partial mode, we can say whether the regex was consumed or not. | |
| common_chat_msg_parser builder("Hello,", /* is_partial= */ false, {}); | |
| assert_equals(false, builder.try_consume_regex(common_regex("Hello, world!")).has_value()); | |
| } | |
| { | |
| common_chat_msg_parser builder("Hello,", /* is_partial= */ false, {}); | |
| auto res = builder.try_consume_regex(common_regex("H(el)l(?:o, world!)?")); | |
| assert_equals(true, res.has_value()); | |
| // Verify captures | |
| assert_equals<size_t>(2, res->groups.size()); | |
| assert_equals("Hell", builder.str(res->groups[0])); | |
| assert_equals("el", builder.str(res->groups[1])); | |
| // Verify position is after the match | |
| assert_equals<size_t>(4, builder.pos()); | |
| assert_equals("o,", builder.consume_rest()); | |
| } | |
| { | |
| // But in partial mode, we have a partial final match / can't decide, so we throw a partial exception. | |
| common_chat_msg_parser builder("Hello,", /* is_partial= */ true, {}); | |
| assert_throws([&]() { | |
| builder.try_consume_regex(common_regex("Hello, world!")); | |
| }, "^Hello, world!$"); | |
| } | |
| // Now regardless of the mode, we can tell these aren't a match. | |
| for (const auto is_partial : {false, true}) { | |
| common_chat_msg_parser builder("Hello,", is_partial, {}); | |
| assert_equals(false, builder.try_consume_regex(common_regex("a(b|c)(d|e)f")).has_value()); | |
| } | |
| for (const auto is_partial : {false, true}) { | |
| common_chat_msg_parser builder("Hello,", is_partial, {}); | |
| assert_equals(false, builder.try_consume_literal("Oh")); | |
| } | |
| } | |
| const std::vector<std::string> barely_healable_jsons = { | |
| "{", | |
| "{\"", | |
| "{\"\\", | |
| "{\"n", | |
| "{\"name\"", | |
| "{\"name\":", | |
| "{\"name\":\"", | |
| "{\"name\":\"\\", | |
| "{\"name\":\"python", | |
| "{\"name\":\"python\\", | |
| "{\",", | |
| "{\":", | |
| "{\"[", | |
| "{\"]", | |
| "{\"{", | |
| "{\"}", | |
| "{\"1", | |
| "{\"name\":\",", | |
| "{\"name\":\":", | |
| "{\"name\":\"[", | |
| "{\"name\":\"]", | |
| "{\"name\":\"{", | |
| "{\"name\":\"}", | |
| "{\"name\":\"1", | |
| }; | |
| static void test(const std::string & input, bool is_partial, const std::vector<std::vector<std::string>> & args_paths, const std::vector<std::vector<std::string>> & content_paths, const std::string & expected) { | |
| common_chat_msg_parser builder(input, is_partial, {}); | |
| auto js = builder.try_consume_json_with_dumped_args(args_paths, content_paths); | |
| assert_equals(true, js.has_value()); | |
| assert_equals(is_partial, js->is_partial); | |
| assert_equals(expected, args_paths.size() == 1 && args_paths[0].empty() ? js->value.get<std::string>() : js->value.dump()); | |
| } | |
| static void test_with_args(const std::string & input, const std::string & expected, bool parse_as_partial = true, bool is_partial = true) { | |
| common_chat_msg_parser builder(input, parse_as_partial, {}); | |
| auto js = builder.try_consume_json_with_dumped_args({{"args"}}, {}); | |
| assert_equals(true, js.has_value()); | |
| assert_equals(is_partial, js->is_partial); | |
| assert_equals(expected, js->value.dump()); | |
| } | |
| static void test_json_with_dumped_args_no_args() { | |
| // Normal JSON, nothing to heal, nothing to dump | |
| test("{\"name\": \"python\"}", false, {}, {}, "{\"name\":\"python\"}"); | |
| // Full json is args | |
| test("{\"name\": \"python\"}", false, {{}}, {}, "{\"name\":\"python\"}"); | |
| // If the arguments are further down, don't heal partial content. | |
| for (const auto & src : barely_healable_jsons) { | |
| test(src, true, {{"arguments"}}, {}, "{}"); | |
| } | |
| // But heal content that isn't partial. | |
| test("{\"name\": \"python\"", true, {{"arguments"}}, {}, "{\"name\":\"python\"}"); | |
| } | |
| static void test_json_with_dumped_args() { | |
| // Partial content. | |
| test("{\"content\": \"t", true, {}, {{"content"}}, "{\"content\":\"t\"}"); | |
| test("{\"content\": \"", true, {}, {{"content"}}, "{\"content\":\"\"}"); | |
| test("{\"content\": ", true, {}, {{"content"}}, "{}"); | |
| // If the entire JSON is the arguments, healing it them dumping it produces the same output as the input (just reformatted). | |
| test("{\"name\": \"python", true, {{}}, {}, "{\"name\":\"python"); | |
| for (const auto & src : barely_healable_jsons) { | |
| test(src, true, {{}}, {}, src); | |
| } | |
| // Full JSON w/ args | |
| for (auto parse_as_partial : {true, false}) { | |
| test_with_args( | |
| R"({"name": "python", "args": {"arg1": 1}})", | |
| R"({"name":"python","args":"{\"arg1\":1}"})", | |
| parse_as_partial, | |
| /* is_partial= */ false | |
| ); | |
| } | |
| // Partial JSON w/ partial args | |
| test_with_args( | |
| R"({"foo": "bar", "args": {")", | |
| R"({"foo":"bar","args":"{\""})" | |
| ); | |
| // Partial args broken in object key | |
| test_with_args( | |
| R"({"foo": "bar", "args": {"ar)", | |
| R"({"foo":"bar","args":"{\"ar"})" | |
| ); | |
| // Partial args broken after object key | |
| test_with_args( | |
| R"({"foo": "bar", "args": {"arg1")", | |
| R"({"foo":"bar","args":"{\"arg1\""})" | |
| ); | |
| // Partial args broken before object value | |
| test_with_args( | |
| R"({"foo": "bar", "args": {"arg1":)", | |
| R"({"foo":"bar","args":"{\"arg1\":"})" | |
| ); | |
| // Partial args broken before object value (space) | |
| test_with_args( | |
| R"({"foo": "bar", "args": {"arg1": )", | |
| R"({"foo":"bar","args":"{\"arg1\":"})" | |
| ); | |
| // Partial args broken in object value that may not be complete (int) | |
| test_with_args( | |
| R"({"foo": "bar", "args": {"arg1": 1)", | |
| R"({"foo":"bar","args":"{\"arg1\":"})" | |
| ); | |
| // Partial args broken in object value that is complete (int) | |
| test_with_args( | |
| R"({"foo": "bar", "args": {"arg1": 1 )", | |
| R"({"foo":"bar","args":"{\"arg1\":1"})" | |
| ); | |
| // Partial args broken in object value that is incomplete (string) | |
| test_with_args( | |
| R"({"foo": "bar", "args": {"arg1": ")", | |
| R"({"foo":"bar","args":"{\"arg1\":\""})" | |
| ); | |
| // Partial args broken in object value that is complete (string) | |
| test_with_args( | |
| R"({"foo": "bar", "args": {"arg1": "1")", | |
| R"({"foo":"bar","args":"{\"arg1\":\"1\""})" | |
| ); | |
| // Partial args broken on array opening | |
| test_with_args( | |
| R"({"foo": "bar", "args": [)", | |
| R"({"foo":"bar","args":"["})" | |
| ); | |
| // Partial args broken on array value that is incomplete (int) | |
| test_with_args( | |
| R"({"foo": "bar", "args": [1)", | |
| R"({"foo":"bar","args":"["})" | |
| ); | |
| // Partial args broken on array value that is complete (int) | |
| test_with_args( | |
| R"({"foo": "bar", "args": [1 )", | |
| R"({"foo":"bar","args":"[1"})" | |
| ); | |
| // Partial args broken on array value that is complete (string) | |
| test_with_args( | |
| R"({"foo": "bar", "args": ["1")", | |
| R"({"foo":"bar","args":"[\"1\""})" | |
| ); | |
| // Partial args broken after array value | |
| test_with_args( | |
| R"({"foo": "bar", "args": [1,)", | |
| R"({"foo":"bar","args":"[1,"})" | |
| ); | |
| // Partial args broken on nested array | |
| test_with_args( | |
| R"({"foo": "bar", "args": {"arg1": [)", | |
| R"({"foo":"bar","args":"{\"arg1\":["})" | |
| ); | |
| } | |
| static void test_positions() { | |
| { | |
| common_chat_msg_parser builder("Hello, world!", /* is_partial= */ false, {}); | |
| assert_equals<size_t>(0, builder.pos()); | |
| assert_throws([&]() { builder.move_to(100); }); | |
| assert_equals<size_t>(0, builder.pos()); | |
| assert_throws([&]() { builder.move_back(1); }); | |
| assert_equals<size_t>(0, builder.pos()); | |
| builder.move_to(8); | |
| assert_equals<size_t>(8, builder.pos()); | |
| builder.move_back(1); | |
| assert_equals<size_t>(7, builder.pos()); | |
| assert_equals("world!", builder.consume_rest()); | |
| builder.move_to(0); | |
| assert_equals<size_t>(0, builder.pos()); | |
| assert_throws([&]() { builder.finish(); }); | |
| assert_equals<size_t>(0, builder.pos()); | |
| builder.move_to(builder.input().size()); | |
| builder.finish(); | |
| } | |
| { | |
| common_chat_msg_parser builder("Hello, world!", /* is_partial= */ true, {}); | |
| builder.move_to(builder.input().size()); | |
| assert_equals<size_t>(builder.input().size(), builder.pos()); | |
| builder.finish(); | |
| } | |
| } | |
| int main() { | |
| test_positions(); | |
| test_json_with_dumped_args_no_args(); | |
| test_json_with_dumped_args(); | |
| test_reasoning(); | |
| test_regex(); | |
| std::cout << "All tests passed!\n"; | |
| return 0; | |
| } | |