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
| import base64 | |
| import struct | |
| import pytest | |
| from openai import OpenAI | |
| from utils import * | |
| server = ServerPreset.bert_bge_small() | |
| EPSILON = 1e-3 | |
| def create_server(): | |
| global server | |
| server = ServerPreset.bert_bge_small() | |
| def test_embedding_single(): | |
| global server | |
| server.pooling = 'last' | |
| server.start() | |
| res = server.make_request("POST", "/v1/embeddings", data={ | |
| "input": "I believe the meaning of life is", | |
| }) | |
| assert res.status_code == 200 | |
| assert len(res.body['data']) == 1 | |
| assert 'embedding' in res.body['data'][0] | |
| assert len(res.body['data'][0]['embedding']) > 1 | |
| # make sure embedding vector is normalized | |
| assert abs(sum([x ** 2 for x in res.body['data'][0]['embedding']]) - 1) < EPSILON | |
| def test_embedding_multiple(): | |
| global server | |
| server.pooling = 'last' | |
| server.start() | |
| res = server.make_request("POST", "/v1/embeddings", data={ | |
| "input": [ | |
| "I believe the meaning of life is", | |
| "Write a joke about AI from a very long prompt which will not be truncated", | |
| "This is a test", | |
| "This is another test", | |
| ], | |
| }) | |
| assert res.status_code == 200 | |
| assert len(res.body['data']) == 4 | |
| for d in res.body['data']: | |
| assert 'embedding' in d | |
| assert len(d['embedding']) > 1 | |
| def test_embedding_multiple_with_fa(): | |
| server = ServerPreset.bert_bge_small_with_fa() | |
| server.pooling = 'last' | |
| server.start() | |
| # one of these should trigger the FA branch (i.e. context size % 256 == 0) | |
| res = server.make_request("POST", "/v1/embeddings", data={ | |
| "input": [ | |
| "a "*253, | |
| "b "*254, | |
| "c "*255, | |
| "d "*256, | |
| ], | |
| }) | |
| assert res.status_code == 200 | |
| assert len(res.body['data']) == 4 | |
| for d in res.body['data']: | |
| assert 'embedding' in d | |
| assert len(d['embedding']) > 1 | |
| def test_embedding_mixed_input(input, is_multi_prompt: bool): | |
| global server | |
| server.start() | |
| res = server.make_request("POST", "/v1/embeddings", data={"input": input}) | |
| assert res.status_code == 200 | |
| data = res.body['data'] | |
| if is_multi_prompt: | |
| assert len(data) == len(input) | |
| for d in data: | |
| assert 'embedding' in d | |
| assert len(d['embedding']) > 1 | |
| else: | |
| assert 'embedding' in data[0] | |
| assert len(data[0]['embedding']) > 1 | |
| def test_embedding_pooling_none(): | |
| global server | |
| server.pooling = 'none' | |
| server.start() | |
| res = server.make_request("POST", "/embeddings", data={ | |
| "input": "hello hello hello", | |
| }) | |
| assert res.status_code == 200 | |
| assert 'embedding' in res.body[0] | |
| assert len(res.body[0]['embedding']) == 5 # 3 text tokens + 2 special | |
| # make sure embedding vector is not normalized | |
| for x in res.body[0]['embedding']: | |
| assert abs(sum([x ** 2 for x in x]) - 1) > EPSILON | |
| def test_embedding_pooling_none_oai(): | |
| global server | |
| server.pooling = 'none' | |
| server.start() | |
| res = server.make_request("POST", "/v1/embeddings", data={ | |
| "input": "hello hello hello", | |
| }) | |
| # /v1/embeddings does not support pooling type 'none' | |
| assert res.status_code == 400 | |
| assert "error" in res.body | |
| def test_embedding_openai_library_single(): | |
| global server | |
| server.pooling = 'last' | |
| server.start() | |
| client = OpenAI(api_key="dummy", base_url=f"http://{server.server_host}:{server.server_port}/v1") | |
| res = client.embeddings.create(model="text-embedding-3-small", input="I believe the meaning of life is") | |
| assert len(res.data) == 1 | |
| assert len(res.data[0].embedding) > 1 | |
| def test_embedding_openai_library_multiple(): | |
| global server | |
| server.pooling = 'last' | |
| server.start() | |
| client = OpenAI(api_key="dummy", base_url=f"http://{server.server_host}:{server.server_port}/v1") | |
| res = client.embeddings.create(model="text-embedding-3-small", input=[ | |
| "I believe the meaning of life is", | |
| "Write a joke about AI from a very long prompt which will not be truncated", | |
| "This is a test", | |
| "This is another test", | |
| ]) | |
| assert len(res.data) == 4 | |
| for d in res.data: | |
| assert len(d.embedding) > 1 | |
| def test_embedding_error_prompt_too_long(): | |
| global server | |
| server.pooling = 'last' | |
| server.start() | |
| res = server.make_request("POST", "/v1/embeddings", data={ | |
| "input": "This is a test " * 512, | |
| }) | |
| assert res.status_code != 200 | |
| assert "too large" in res.body["error"]["message"] | |
| def test_same_prompt_give_same_result(): | |
| server.pooling = 'last' | |
| server.start() | |
| res = server.make_request("POST", "/v1/embeddings", data={ | |
| "input": [ | |
| "I believe the meaning of life is", | |
| "I believe the meaning of life is", | |
| "I believe the meaning of life is", | |
| "I believe the meaning of life is", | |
| "I believe the meaning of life is", | |
| ], | |
| }) | |
| assert res.status_code == 200 | |
| assert len(res.body['data']) == 5 | |
| for i in range(1, len(res.body['data'])): | |
| v0 = res.body['data'][0]['embedding'] | |
| vi = res.body['data'][i]['embedding'] | |
| for x, y in zip(v0, vi): | |
| assert abs(x - y) < EPSILON | |
| def test_embedding_usage_single(content, n_tokens): | |
| global server | |
| server.start() | |
| res = server.make_request("POST", "/v1/embeddings", data={"input": content}) | |
| assert res.status_code == 200 | |
| assert res.body['usage']['prompt_tokens'] == res.body['usage']['total_tokens'] | |
| assert res.body['usage']['prompt_tokens'] == n_tokens | |
| def test_embedding_usage_multiple(): | |
| global server | |
| server.start() | |
| res = server.make_request("POST", "/v1/embeddings", data={ | |
| "input": [ | |
| "I believe the meaning of life is", | |
| "I believe the meaning of life is", | |
| ], | |
| }) | |
| assert res.status_code == 200 | |
| assert res.body['usage']['prompt_tokens'] == res.body['usage']['total_tokens'] | |
| assert res.body['usage']['prompt_tokens'] == 2 * 9 | |
| def test_embedding_openai_library_base64(): | |
| server.start() | |
| test_input = "Test base64 embedding output" | |
| # get embedding in default format | |
| res = server.make_request("POST", "/v1/embeddings", data={ | |
| "input": test_input | |
| }) | |
| assert res.status_code == 200 | |
| vec0 = res.body["data"][0]["embedding"] | |
| # get embedding in base64 format | |
| res = server.make_request("POST", "/v1/embeddings", data={ | |
| "input": test_input, | |
| "encoding_format": "base64" | |
| }) | |
| assert res.status_code == 200 | |
| assert "data" in res.body | |
| assert len(res.body["data"]) == 1 | |
| embedding_data = res.body["data"][0] | |
| assert "embedding" in embedding_data | |
| assert isinstance(embedding_data["embedding"], str) | |
| # Verify embedding is valid base64 | |
| decoded = base64.b64decode(embedding_data["embedding"]) | |
| # Verify decoded data can be converted back to float array | |
| float_count = len(decoded) // 4 # 4 bytes per float | |
| floats = struct.unpack(f'{float_count}f', decoded) | |
| assert len(floats) > 0 | |
| assert all(isinstance(x, float) for x in floats) | |
| assert len(floats) == len(vec0) | |
| # make sure the decoded data is the same as the original | |
| for x, y in zip(floats, vec0): | |
| assert abs(x - y) < EPSILON | |