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
| int main() | |
| { | |
| llama_grammar_parser parsed_grammar; | |
| std::vector<std::pair<std::string, uint32_t>> expected = { | |
| {"expr", 2}, | |
| {"expr_6", 6}, | |
| {"expr_7", 7}, | |
| {"ident", 8}, | |
| {"ident_10", 10}, | |
| {"num", 9}, | |
| {"num_11", 11}, | |
| {"root", 0}, | |
| {"root_1", 1}, | |
| {"root_5", 5}, | |
| {"term", 4}, | |
| {"ws", 3}, | |
| {"ws_12", 12}, | |
| }; | |
| std::vector<std::vector<llama_grammar_element>> expected_rules = { | |
| {{LLAMA_GRETYPE_RULE_REF, 5}, {LLAMA_GRETYPE_END, 0}}, | |
| { | |
| {LLAMA_GRETYPE_RULE_REF, 2}, | |
| {LLAMA_GRETYPE_CHAR, 61}, | |
| {LLAMA_GRETYPE_RULE_REF, 3}, | |
| {LLAMA_GRETYPE_RULE_REF, 4}, | |
| {LLAMA_GRETYPE_CHAR, 10}, | |
| {LLAMA_GRETYPE_END, 0}, | |
| }, | |
| {{LLAMA_GRETYPE_RULE_REF, 4}, {LLAMA_GRETYPE_RULE_REF, 7}, {LLAMA_GRETYPE_END, 0}}, | |
| {{LLAMA_GRETYPE_RULE_REF, 12}, {LLAMA_GRETYPE_END, 0}}, | |
| { | |
| {LLAMA_GRETYPE_RULE_REF, 8}, | |
| {LLAMA_GRETYPE_ALT, 0}, | |
| {LLAMA_GRETYPE_RULE_REF, 9}, | |
| {LLAMA_GRETYPE_ALT, 0}, | |
| {LLAMA_GRETYPE_CHAR, 40}, | |
| {LLAMA_GRETYPE_RULE_REF, 3}, | |
| {LLAMA_GRETYPE_RULE_REF, 2}, | |
| {LLAMA_GRETYPE_CHAR, 41}, | |
| {LLAMA_GRETYPE_RULE_REF, 3}, | |
| {LLAMA_GRETYPE_END, 0}, | |
| }, | |
| {{LLAMA_GRETYPE_RULE_REF, 1}, {LLAMA_GRETYPE_RULE_REF, 5}, {LLAMA_GRETYPE_ALT, 0}, {LLAMA_GRETYPE_RULE_REF, 1}, {LLAMA_GRETYPE_END, 0}}, | |
| { | |
| {LLAMA_GRETYPE_CHAR, 45}, | |
| {LLAMA_GRETYPE_CHAR_ALT, 43}, | |
| {LLAMA_GRETYPE_CHAR_ALT, 42}, | |
| {LLAMA_GRETYPE_CHAR_ALT, 47}, | |
| {LLAMA_GRETYPE_RULE_REF, 4}, | |
| {LLAMA_GRETYPE_END, 0}, | |
| }, | |
| {{LLAMA_GRETYPE_RULE_REF, 6}, {LLAMA_GRETYPE_RULE_REF, 7}, {LLAMA_GRETYPE_ALT, 0}, {LLAMA_GRETYPE_END, 0}}, | |
| { | |
| {LLAMA_GRETYPE_CHAR, 97}, | |
| {LLAMA_GRETYPE_CHAR_RNG_UPPER, 122}, | |
| {LLAMA_GRETYPE_RULE_REF, 10}, | |
| {LLAMA_GRETYPE_RULE_REF, 3}, | |
| {LLAMA_GRETYPE_END, 0}, | |
| }, | |
| {{LLAMA_GRETYPE_RULE_REF, 11}, {LLAMA_GRETYPE_RULE_REF, 3}, {LLAMA_GRETYPE_END, 0}}, | |
| { | |
| {LLAMA_GRETYPE_CHAR, 97}, | |
| {LLAMA_GRETYPE_CHAR_RNG_UPPER, 122}, | |
| {LLAMA_GRETYPE_CHAR_ALT, 48}, | |
| {LLAMA_GRETYPE_CHAR_RNG_UPPER, 57}, | |
| {LLAMA_GRETYPE_CHAR_ALT, 95}, | |
| {LLAMA_GRETYPE_RULE_REF, 10}, | |
| {LLAMA_GRETYPE_ALT, 0}, | |
| {LLAMA_GRETYPE_END, 0}, | |
| }, | |
| { | |
| {LLAMA_GRETYPE_CHAR, 48}, | |
| {LLAMA_GRETYPE_CHAR_RNG_UPPER, 57}, | |
| {LLAMA_GRETYPE_RULE_REF, 11}, | |
| {LLAMA_GRETYPE_ALT, 0}, | |
| {LLAMA_GRETYPE_CHAR, 48}, | |
| {LLAMA_GRETYPE_CHAR_RNG_UPPER, 57}, | |
| {LLAMA_GRETYPE_END, 0}, | |
| }, | |
| { | |
| {LLAMA_GRETYPE_CHAR, 32}, | |
| {LLAMA_GRETYPE_CHAR_ALT, 9}, | |
| {LLAMA_GRETYPE_CHAR_ALT, 10}, | |
| {LLAMA_GRETYPE_RULE_REF, 12}, | |
| {LLAMA_GRETYPE_ALT, 0}, | |
| {LLAMA_GRETYPE_END, 0}, | |
| }, | |
| }; | |
| for (auto pair : expected) | |
| { | |
| parsed_grammar.symbol_ids[pair.first] = pair.second; | |
| } | |
| for (auto rule : expected_rules) | |
| { | |
| parsed_grammar.rules.emplace_back(); | |
| for (auto element : rule) | |
| { | |
| parsed_grammar.rules.back().push_back(element); | |
| } | |
| } | |
| std::vector<const llama_grammar_element *> grammar_rules(parsed_grammar.c_rules()); | |
| llama_grammar * grammar = llama_grammar_init_impl(nullptr, grammar_rules.data(), grammar_rules.size(), parsed_grammar.symbol_ids.at("root")); | |
| if (grammar == nullptr) { | |
| throw std::runtime_error("Failed to initialize llama_grammar"); | |
| } | |
| std::vector<std::vector<llama_grammar_element>> expected_stacks = { | |
| { | |
| {LLAMA_GRETYPE_RULE_REF, 5}, | |
| {LLAMA_GRETYPE_CHAR, 61}, | |
| {LLAMA_GRETYPE_RULE_REF, 7}, | |
| {LLAMA_GRETYPE_CHAR, 97}, | |
| }, | |
| { | |
| {LLAMA_GRETYPE_RULE_REF, 5}, | |
| {LLAMA_GRETYPE_CHAR, 61}, | |
| {LLAMA_GRETYPE_RULE_REF, 7}, | |
| {LLAMA_GRETYPE_RULE_REF, 3}, | |
| {LLAMA_GRETYPE_CHAR, 48}, | |
| }, | |
| { | |
| {LLAMA_GRETYPE_RULE_REF, 5}, | |
| {LLAMA_GRETYPE_CHAR, 61}, | |
| {LLAMA_GRETYPE_RULE_REF, 7}, | |
| {LLAMA_GRETYPE_RULE_REF, 3}, | |
| {LLAMA_GRETYPE_CHAR, 48}, | |
| }, | |
| { | |
| {LLAMA_GRETYPE_RULE_REF, 5}, | |
| {LLAMA_GRETYPE_CHAR, 61}, | |
| {LLAMA_GRETYPE_RULE_REF, 7}, | |
| {LLAMA_GRETYPE_CHAR, 40}, | |
| }, | |
| { | |
| {LLAMA_GRETYPE_CHAR, 61}, | |
| {LLAMA_GRETYPE_RULE_REF, 7}, | |
| {LLAMA_GRETYPE_CHAR, 97}, | |
| }, | |
| { | |
| {LLAMA_GRETYPE_CHAR, 61}, | |
| {LLAMA_GRETYPE_RULE_REF, 7}, | |
| {LLAMA_GRETYPE_RULE_REF, 3}, | |
| {LLAMA_GRETYPE_CHAR, 48}, | |
| }, | |
| { | |
| {LLAMA_GRETYPE_CHAR, 61}, | |
| {LLAMA_GRETYPE_RULE_REF, 7}, | |
| {LLAMA_GRETYPE_RULE_REF, 3}, | |
| {LLAMA_GRETYPE_CHAR, 48}, | |
| }, | |
| { | |
| {LLAMA_GRETYPE_CHAR, 61}, | |
| {LLAMA_GRETYPE_RULE_REF, 7}, | |
| {LLAMA_GRETYPE_CHAR, 40}, | |
| }}; | |
| auto index = 0; | |
| for (const llama_grammar_stack & stack : llama_grammar_get_stacks(grammar)) | |
| { | |
| // compare stack to expected_stack | |
| for (uint32_t i = 0; i < stack.size(); i++) | |
| { | |
| const llama_grammar_element * element = stack[i]; | |
| const llama_grammar_element & expected_element = expected_stacks[index][i]; | |
| // pretty print error message before asserting | |
| if (expected_element.type != element->type || expected_element.value != element->value) | |
| { | |
| fprintf(stderr, "index: %d\n", index); | |
| fprintf(stderr, "expected_element: %d, %u\n", expected_element.type, expected_element.value); | |
| fprintf(stderr, "actual_element: %d, %u\n", element->type, element->value); | |
| fprintf(stderr, "expected_element != actual_element\n"); | |
| } | |
| assert(expected_element.type == element->type && expected_element.value == element->value); | |
| } | |
| index++; | |
| } | |
| std::vector<llama_grammar_candidate> next_candidates; | |
| next_candidates.resize(24); | |
| for (size_t i = 0; i < 24; ++i) | |
| { | |
| uint32_t *cp = new uint32_t[2]; // dynamically allocate memory for code_point | |
| cp[0] = 37 + i; | |
| cp[1] = 0; | |
| next_candidates[i] = {i, cp, {}}; | |
| } | |
| std::vector<std::vector<std::pair<uint32_t, uint16_t>>> expected_reject = { | |
| { | |
| {0, 37}, | |
| {1, 38}, | |
| {2, 39}, | |
| {3, 40}, | |
| {4, 41}, | |
| {5, 42}, | |
| {6, 43}, | |
| {7, 44}, | |
| {8, 45}, | |
| {9, 46}, | |
| {10, 47}, | |
| {11, 48}, | |
| {12, 49}, | |
| {13, 50}, | |
| {14, 51}, | |
| {15, 52}, | |
| {16, 53}, | |
| {17, 54}, | |
| {18, 55}, | |
| {19, 56}, | |
| {20, 57}, | |
| {21, 58}, | |
| {22, 59}, | |
| {23, 60}, | |
| }, | |
| { | |
| {0, 37}, | |
| {1, 38}, | |
| {2, 39}, | |
| {3, 40}, | |
| {4, 41}, | |
| {5, 42}, | |
| {6, 43}, | |
| {7, 44}, | |
| {8, 45}, | |
| {9, 46}, | |
| {10, 47}, | |
| {21, 58}, | |
| {22, 59}, | |
| {23, 60}, | |
| }, | |
| { | |
| {0, 37}, | |
| {1, 38}, | |
| {2, 39}, | |
| {3, 40}, | |
| {4, 41}, | |
| {5, 42}, | |
| {6, 43}, | |
| {7, 44}, | |
| {8, 45}, | |
| {9, 46}, | |
| {10, 47}, | |
| {21, 58}, | |
| {22, 59}, | |
| {23, 60}, | |
| }, | |
| { | |
| {0, 37}, | |
| {1, 38}, | |
| {2, 39}, | |
| {4, 41}, | |
| {5, 42}, | |
| {6, 43}, | |
| {7, 44}, | |
| {8, 45}, | |
| {9, 46}, | |
| {10, 47}, | |
| {11, 48}, | |
| {12, 49}, | |
| {13, 50}, | |
| {14, 51}, | |
| {15, 52}, | |
| {16, 53}, | |
| {17, 54}, | |
| {18, 55}, | |
| {19, 56}, | |
| {20, 57}, | |
| {21, 58}, | |
| {22, 59}, | |
| {23, 60}, | |
| }, | |
| { | |
| {0, 37}, | |
| {1, 38}, | |
| {2, 39}, | |
| {3, 40}, | |
| {4, 41}, | |
| {5, 42}, | |
| {6, 43}, | |
| {7, 44}, | |
| {8, 45}, | |
| {9, 46}, | |
| {10, 47}, | |
| {11, 48}, | |
| {12, 49}, | |
| {13, 50}, | |
| {14, 51}, | |
| {15, 52}, | |
| {16, 53}, | |
| {17, 54}, | |
| {18, 55}, | |
| {19, 56}, | |
| {20, 57}, | |
| {21, 58}, | |
| {22, 59}, | |
| {23, 60}, | |
| }, | |
| { | |
| {0, 37}, | |
| {1, 38}, | |
| {2, 39}, | |
| {3, 40}, | |
| {4, 41}, | |
| {5, 42}, | |
| {6, 43}, | |
| {7, 44}, | |
| {8, 45}, | |
| {9, 46}, | |
| {10, 47}, | |
| {21, 58}, | |
| {22, 59}, | |
| {23, 60}, | |
| }, | |
| { | |
| {0, 37}, | |
| {1, 38}, | |
| {2, 39}, | |
| {3, 40}, | |
| {4, 41}, | |
| {5, 42}, | |
| {6, 43}, | |
| {7, 44}, | |
| {8, 45}, | |
| {9, 46}, | |
| {10, 47}, | |
| {21, 58}, | |
| {22, 59}, | |
| {23, 60}, | |
| }, | |
| { | |
| {0, 37}, | |
| {1, 38}, | |
| {2, 39}, | |
| {4, 41}, | |
| {5, 42}, | |
| {6, 43}, | |
| {7, 44}, | |
| {8, 45}, | |
| {9, 46}, | |
| {10, 47}, | |
| {11, 48}, | |
| {12, 49}, | |
| {13, 50}, | |
| {14, 51}, | |
| {15, 52}, | |
| {16, 53}, | |
| {17, 54}, | |
| {18, 55}, | |
| {19, 56}, | |
| {20, 57}, | |
| {21, 58}, | |
| {22, 59}, | |
| {23, 60}, | |
| }, | |
| }; | |
| std::vector<llama_grammar_candidate> rejects = llama_grammar_reject_candidates_for_stack(llama_grammar_get_rules(grammar), llama_grammar_get_stacks(grammar)[0], next_candidates); | |
| std::vector<std::vector<llama_grammar_candidate>> all_rejects; | |
| for (std::size_t count = 0; count < llama_grammar_get_stacks(grammar).size(); ++count) | |
| { | |
| rejects = llama_grammar_reject_candidates_for_stack(llama_grammar_get_rules(grammar), llama_grammar_get_stacks(grammar)[count], next_candidates); | |
| all_rejects.push_back(rejects); | |
| } | |
| index = 0; | |
| for (auto rej : all_rejects) | |
| { | |
| for (uint32_t i = 0; i < rej.size(); i++) | |
| { | |
| auto element = rej[i]; | |
| auto expected_element = expected_reject[index][i]; | |
| assert(element.index == expected_element.first && *element.code_points == expected_element.second); | |
| } | |
| index++; | |
| } | |
| for (auto &candidate : next_candidates) | |
| { | |
| delete[] candidate.code_points; | |
| candidate.code_points = nullptr; | |
| } | |
| llama_grammar_free_impl(grammar); | |
| return 0; | |
| } | |