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
| set -euo pipefail | |
| cd "$(dirname "$0")/.." || exit | |
| if [[ -z "${PROMPT_CACHE_FILE+x}" || -z "${CHAT_SAVE_DIR+x}" ]]; then | |
| echo >&2 "error: PROMPT_CACHE_FILE and CHAT_SAVE_DIR must be provided" | |
| exit 1 | |
| fi | |
| MODEL="${MODEL:-./models/llama-13b/ggml-model-q4_0.gguf}" | |
| PROMPT_TEMPLATE="${PROMPT_TEMPLATE:-./prompts/chat.txt}" | |
| USER_NAME="${USER_NAME:-User}" | |
| AI_NAME="${AI_NAME:-ChatLLaMa}" | |
| DATE_TIME="$(date +%H:%M)" | |
| DATE_YEAR="$(date +%Y)" | |
| LOG="${CHAT_SAVE_DIR}/main.log" | |
| LOG_BG="${CHAT_SAVE_DIR}/main-bg.log" | |
| CUR_PROMPT_FILE="${CHAT_SAVE_DIR}/current-prompt.txt" | |
| CUR_PROMPT_CACHE="${CHAT_SAVE_DIR}/current-cache.bin" | |
| NEXT_PROMPT_FILE="${CHAT_SAVE_DIR}/next-prompt.txt" | |
| NEXT_PROMPT_CACHE="${CHAT_SAVE_DIR}/next-cache.bin" | |
| SESSION_AND_SAMPLE_PATTERN='main: session file matches [[:digit:]]+ / [[:digit:]]+'\ | |
| '|'\ | |
| 'sampling time =[[:space:]]+[[:digit:]]+.[[:digit:]]+ ms /[[:space:]]+[[:digit:]]+' | |
| SED_DELETE_MESSAGES="/^(${USER_NAME}:|${AI_NAME}:|\\.\\.\\.)/,\$d" | |
| CTX_SIZE=2048 | |
| CTX_ROTATE_POINT=$((CTX_SIZE * 3 / 5)) # REVIEW | |
| OPTS=(--model "$MODEL" --ctx_size "$CTX_SIZE" --repeat_last_n 256 "$@") | |
| # An unbuffered `tail -c+N` | |
| skip_bytes() { | |
| LANG=C IFS= read -r -n "$1" -d '' c | |
| while LANG=C IFS= read -r -n 1 -d '' c; do | |
| printf '%s' "$c" | |
| done | |
| } | |
| mkdir -p "$CHAT_SAVE_DIR" | |
| echo >"$LOG" | |
| trap "tail -n100 ${LOG}" EXIT | |
| if [[ ! -e "$CUR_PROMPT_FILE" ]]; then | |
| sed -e "s/\[\[USER_NAME\]\]/${USER_NAME}/g" \ | |
| -e "s/\[\[AI_NAME\]\]/${AI_NAME}/g" \ | |
| -e "s/\[\[DATE_TIME\]\]/${DATE_TIME}/g" \ | |
| -e "s/\[\[DATE_YEAR\]\]/${DATE_YEAR}/g" \ | |
| "$PROMPT_TEMPLATE" >"$CUR_PROMPT_FILE" | |
| fi | |
| if [[ ! -e "$NEXT_PROMPT_FILE" ]]; then | |
| sed -r "$SED_DELETE_MESSAGES" "$CUR_PROMPT_FILE" >"$NEXT_PROMPT_FILE" | |
| fi | |
| if [[ "$(tail -c4 "$NEXT_PROMPT_FILE")" != "..." ]]; then | |
| echo '...' >>"$NEXT_PROMPT_FILE" | |
| fi | |
| if [[ ! -e "$PROMPT_CACHE_FILE" ]]; then | |
| echo 'Prompt cache does not exist, building...' | |
| # Default batch_size to 64 here for better user feedback during initial prompt processing | |
| ./llama-cli 2>>"$LOG" \ | |
| --batch_size 64 \ | |
| "${OPTS[@]}" \ | |
| --prompt-cache "$PROMPT_CACHE_FILE" \ | |
| --file "$CUR_PROMPT_FILE" \ | |
| --n_predict 1 | |
| echo | |
| echo 'Done!' | |
| fi | |
| if [[ ! -e "$CUR_PROMPT_CACHE" ]]; then | |
| cp "$PROMPT_CACHE_FILE" "$CUR_PROMPT_CACHE" | |
| fi | |
| if [[ ! -e "$NEXT_PROMPT_CACHE" ]]; then | |
| cp "$PROMPT_CACHE_FILE" "$NEXT_PROMPT_CACHE" | |
| fi | |
| printf '%s ' "$(< "$CUR_PROMPT_FILE")" | |
| n_tokens=0 | |
| while read -e line; do | |
| # Limit generation to remaining context, with a buffer and estimating 2 chars/token for input | |
| n_predict=$((CTX_SIZE - n_tokens - ${#line} / 2 - 32)) | |
| # Swap prompts when we're about to run out of context | |
| if ((n_predict <= 0)); then | |
| wait # for background main (below) to finish with next prompt | |
| mv "$NEXT_PROMPT_FILE" "$CUR_PROMPT_FILE" | |
| mv "$NEXT_PROMPT_CACHE" "$CUR_PROMPT_CACHE" | |
| sed -r "$SED_DELETE_MESSAGES" "$CUR_PROMPT_FILE" >"$NEXT_PROMPT_FILE" | |
| echo '...' >>"$NEXT_PROMPT_FILE" | |
| cp "$PROMPT_CACHE_FILE" "$NEXT_PROMPT_CACHE" | |
| n_tokens=0 | |
| n_predict=$((CTX_SIZE / 2)) | |
| fi | |
| echo " ${line}" >>"$CUR_PROMPT_FILE" | |
| if ((n_tokens > CTX_ROTATE_POINT)); then | |
| echo " ${line}" >>"$NEXT_PROMPT_FILE" | |
| fi | |
| n_prompt_len_pre=$(($(wc -c <"$CUR_PROMPT_FILE"))) | |
| printf '%s: ' "$AI_NAME" >>"$CUR_PROMPT_FILE" | |
| ./llama-cli 2>>"$LOG" "${OPTS[@]}" \ | |
| --prompt-cache "$CUR_PROMPT_CACHE" \ | |
| --prompt-cache-all \ | |
| --file "$CUR_PROMPT_FILE" \ | |
| --reverse-prompt "${USER_NAME}:" \ | |
| --n_predict "$n_predict" | | |
| skip_bytes 1 | # skip BOS token added by ./llama-cli | |
| tee "$CUR_PROMPT_FILE.tmp" | # save prompt + generation to tmp file | |
| skip_bytes "$n_prompt_len_pre" # print generation | |
| mv "$CUR_PROMPT_FILE.tmp" "$CUR_PROMPT_FILE" | |
| # if we hit n_predict instead of reverse-prompt, we need to add the prompt | |
| if [[ "$(tail -n1 "$CUR_PROMPT_FILE")" != "${USER_NAME}:" ]]; then | |
| printf '\n%s:' "$USER_NAME" | |
| printf '\n%s:' "$USER_NAME" >> "$CUR_PROMPT_FILE" | |
| fi | |
| printf ' ' | |
| if ! session_and_sample_msg=$(tail -n30 "$LOG" | grep -oE "$SESSION_AND_SAMPLE_PATTERN"); then | |
| echo >&2 "Couldn't get number of tokens from ./llama-cli output!" | |
| exit 1 | |
| fi | |
| n_tokens=$(awk '{sum+=$1} END {print sum}' <<< "$(cut -d/ -f2 <<< "$session_and_sample_msg")") | |
| if ((n_tokens > CTX_ROTATE_POINT)); then | |
| tail -c+$((n_prompt_len_pre + 1)) "$CUR_PROMPT_FILE" >>"$NEXT_PROMPT_FILE" | |
| fi | |
| # Update cache for next prompt in background, ideally during user input | |
| ./llama-cli >>"$LOG_BG" 2>&1 "${OPTS[@]}" \ | |
| --prompt-cache "$NEXT_PROMPT_CACHE" \ | |
| --file "$NEXT_PROMPT_FILE" \ | |
| --n_predict 1 & | |
| done | |