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
| // coversations is stored in localStorage | |
| // format: { [convId]: { id: string, lastModified: number, messages: [...] } } | |
| import { CONFIG_DEFAULT } from '../Config'; | |
| import { Conversation, Message, TimingReport } from './types'; | |
| import Dexie, { Table } from 'dexie'; | |
| const event = new EventTarget(); | |
| type CallbackConversationChanged = (convId: string) => void; | |
| let onConversationChangedHandlers: [ | |
| CallbackConversationChanged, | |
| EventListener, | |
| ][] = []; | |
| const dispatchConversationChange = (convId: string) => { | |
| event.dispatchEvent( | |
| new CustomEvent('conversationChange', { detail: { convId } }) | |
| ); | |
| }; | |
| const db = new Dexie('LlamacppWebui') as Dexie & { | |
| conversations: Table<Conversation>; | |
| messages: Table<Message>; | |
| }; | |
| // https://dexie.org/docs/Version/Version.stores() | |
| db.version(1).stores({ | |
| // Unlike SQL, you don’t need to specify all properties but only the one you wish to index. | |
| conversations: '&id, lastModified', | |
| messages: '&id, convId, [convId+id], timestamp', | |
| }); | |
| // convId is a string prefixed with 'conv-' | |
| const StorageUtils = { | |
| /** | |
| * manage conversations | |
| */ | |
| async getAllConversations(): Promise<Conversation[]> { | |
| await migrationLStoIDB().catch(console.error); // noop if already migrated | |
| return (await db.conversations.toArray()).sort( | |
| (a, b) => b.lastModified - a.lastModified | |
| ); | |
| }, | |
| /** | |
| * can return null if convId does not exist | |
| */ | |
| async getOneConversation(convId: string): Promise<Conversation | null> { | |
| return (await db.conversations.where('id').equals(convId).first()) ?? null; | |
| }, | |
| /** | |
| * get all message nodes in a conversation | |
| */ | |
| async getMessages(convId: string): Promise<Message[]> { | |
| return await db.messages.where({ convId }).toArray(); | |
| }, | |
| /** | |
| * use in conjunction with getMessages to filter messages by leafNodeId | |
| * includeRoot: whether to include the root node in the result | |
| * if node with leafNodeId does not exist, return the path with the latest timestamp | |
| */ | |
| filterByLeafNodeId( | |
| msgs: Readonly<Message[]>, | |
| leafNodeId: Message['id'], | |
| includeRoot: boolean | |
| ): Readonly<Message[]> { | |
| const res: Message[] = []; | |
| const nodeMap = new Map<Message['id'], Message>(); | |
| for (const msg of msgs) { | |
| nodeMap.set(msg.id, msg); | |
| } | |
| let startNode: Message | undefined = nodeMap.get(leafNodeId); | |
| if (!startNode) { | |
| // if not found, we return the path with the latest timestamp | |
| let latestTime = -1; | |
| for (const msg of msgs) { | |
| if (msg.timestamp > latestTime) { | |
| startNode = msg; | |
| latestTime = msg.timestamp; | |
| } | |
| } | |
| } | |
| // traverse the path from leafNodeId to root | |
| // startNode can never be undefined here | |
| let currNode: Message | undefined = startNode; | |
| while (currNode) { | |
| if (currNode.type !== 'root' || (currNode.type === 'root' && includeRoot)) | |
| res.push(currNode); | |
| currNode = nodeMap.get(currNode.parent ?? -1); | |
| } | |
| res.sort((a, b) => a.timestamp - b.timestamp); | |
| return res; | |
| }, | |
| /** | |
| * create a new conversation with a default root node | |
| */ | |
| async createConversation(name: string): Promise<Conversation> { | |
| const now = Date.now(); | |
| const msgId = now; | |
| const conv: Conversation = { | |
| id: `conv-${now}`, | |
| lastModified: now, | |
| currNode: msgId, | |
| name, | |
| }; | |
| await db.conversations.add(conv); | |
| // create a root node | |
| await db.messages.add({ | |
| id: msgId, | |
| convId: conv.id, | |
| type: 'root', | |
| timestamp: now, | |
| role: 'system', | |
| content: '', | |
| parent: -1, | |
| children: [], | |
| }); | |
| return conv; | |
| }, | |
| /** | |
| * update the name of a conversation | |
| */ | |
| async updateConversationName(convId: string, name: string): Promise<void> { | |
| await db.conversations.update(convId, { | |
| name, | |
| lastModified: Date.now(), | |
| }); | |
| dispatchConversationChange(convId); | |
| }, | |
| /** | |
| * if convId does not exist, throw an error | |
| */ | |
| async appendMsg( | |
| msg: Exclude<Message, 'parent' | 'children'>, | |
| parentNodeId: Message['id'] | |
| ): Promise<void> { | |
| if (msg.content === null) return; | |
| const { convId } = msg; | |
| await db.transaction('rw', db.conversations, db.messages, async () => { | |
| const conv = await StorageUtils.getOneConversation(convId); | |
| const parentMsg = await db.messages | |
| .where({ convId, id: parentNodeId }) | |
| .first(); | |
| // update the currNode of conversation | |
| if (!conv) { | |
| throw new Error(`Conversation ${convId} does not exist`); | |
| } | |
| if (!parentMsg) { | |
| throw new Error( | |
| `Parent message ID ${parentNodeId} does not exist in conversation ${convId}` | |
| ); | |
| } | |
| await db.conversations.update(convId, { | |
| lastModified: Date.now(), | |
| currNode: msg.id, | |
| }); | |
| // update parent | |
| await db.messages.update(parentNodeId, { | |
| children: [...parentMsg.children, msg.id], | |
| }); | |
| // create message | |
| await db.messages.add({ | |
| ...msg, | |
| parent: parentNodeId, | |
| children: [], | |
| }); | |
| }); | |
| dispatchConversationChange(convId); | |
| }, | |
| /** | |
| * remove conversation by id | |
| */ | |
| async remove(convId: string): Promise<void> { | |
| await db.transaction('rw', db.conversations, db.messages, async () => { | |
| await db.conversations.delete(convId); | |
| await db.messages.where({ convId }).delete(); | |
| }); | |
| dispatchConversationChange(convId); | |
| }, | |
| // event listeners | |
| onConversationChanged(callback: CallbackConversationChanged) { | |
| const fn = (e: Event) => callback((e as CustomEvent).detail.convId); | |
| onConversationChangedHandlers.push([callback, fn]); | |
| event.addEventListener('conversationChange', fn); | |
| }, | |
| offConversationChanged(callback: CallbackConversationChanged) { | |
| const fn = onConversationChangedHandlers.find(([cb, _]) => cb === callback); | |
| if (fn) { | |
| event.removeEventListener('conversationChange', fn[1]); | |
| } | |
| onConversationChangedHandlers = []; | |
| }, | |
| // manage config | |
| getConfig(): typeof CONFIG_DEFAULT { | |
| const savedVal = JSON.parse(localStorage.getItem('config') || '{}'); | |
| // to prevent breaking changes in the future, we always provide default value for missing keys | |
| return { | |
| ...CONFIG_DEFAULT, | |
| ...savedVal, | |
| }; | |
| }, | |
| setConfig(config: typeof CONFIG_DEFAULT) { | |
| localStorage.setItem('config', JSON.stringify(config)); | |
| }, | |
| getTheme(): string { | |
| return localStorage.getItem('theme') || 'auto'; | |
| }, | |
| setTheme(theme: string) { | |
| if (theme === 'auto') { | |
| localStorage.removeItem('theme'); | |
| } else { | |
| localStorage.setItem('theme', theme); | |
| } | |
| }, | |
| }; | |
| export default StorageUtils; | |
| // Migration from localStorage to IndexedDB | |
| // these are old types, LS prefix stands for LocalStorage | |
| interface LSConversation { | |
| id: string; // format: `conv-{timestamp}` | |
| lastModified: number; // timestamp from Date.now() | |
| messages: LSMessage[]; | |
| } | |
| interface LSMessage { | |
| id: number; | |
| role: 'user' | 'assistant' | 'system'; | |
| content: string; | |
| timings?: TimingReport; | |
| } | |
| async function migrationLStoIDB() { | |
| if (localStorage.getItem('migratedToIDB')) return; | |
| const res: LSConversation[] = []; | |
| for (const key in localStorage) { | |
| if (key.startsWith('conv-')) { | |
| res.push(JSON.parse(localStorage.getItem(key) ?? '{}')); | |
| } | |
| } | |
| if (res.length === 0) return; | |
| await db.transaction('rw', db.conversations, db.messages, async () => { | |
| let migratedCount = 0; | |
| for (const conv of res) { | |
| const { id: convId, lastModified, messages } = conv; | |
| const firstMsg = messages[0]; | |
| const lastMsg = messages.at(-1); | |
| if (messages.length < 2 || !firstMsg || !lastMsg) { | |
| console.log( | |
| `Skipping conversation ${convId} with ${messages.length} messages` | |
| ); | |
| continue; | |
| } | |
| const name = firstMsg.content ?? '(no messages)'; | |
| await db.conversations.add({ | |
| id: convId, | |
| lastModified, | |
| currNode: lastMsg.id, | |
| name, | |
| }); | |
| const rootId = messages[0].id - 2; | |
| await db.messages.add({ | |
| id: rootId, | |
| convId: convId, | |
| type: 'root', | |
| timestamp: rootId, | |
| role: 'system', | |
| content: '', | |
| parent: -1, | |
| children: [firstMsg.id], | |
| }); | |
| for (let i = 0; i < messages.length; i++) { | |
| const msg = messages[i]; | |
| await db.messages.add({ | |
| ...msg, | |
| type: 'text', | |
| convId: convId, | |
| timestamp: msg.id, | |
| parent: i === 0 ? rootId : messages[i - 1].id, | |
| children: i === messages.length - 1 ? [] : [messages[i + 1].id], | |
| }); | |
| } | |
| migratedCount++; | |
| console.log( | |
| `Migrated conversation ${convId} with ${messages.length} messages` | |
| ); | |
| } | |
| console.log( | |
| `Migrated ${migratedCount} conversations from localStorage to IndexedDB` | |
| ); | |
| localStorage.setItem('migratedToIDB', '1'); | |
| }); | |
| } | |