Text Generation
Transformers
Safetensors
clokcem
causal-lm
customer-care
thinking-head
intent-classification
quality-gate
gqa
swiglu
rmsnorm
rope
indian-languages
Instructions to use clokai/CLOK-CEM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use clokai/CLOK-CEM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="clokai/CLOK-CEM")# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("clokai/CLOK-CEM", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use clokai/CLOK-CEM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "clokai/CLOK-CEM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "clokai/CLOK-CEM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/clokai/CLOK-CEM
- SGLang
How to use clokai/CLOK-CEM 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 "clokai/CLOK-CEM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "clokai/CLOK-CEM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "clokai/CLOK-CEM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "clokai/CLOK-CEM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use clokai/CLOK-CEM with Docker Model Runner:
docker model run hf.co/clokai/CLOK-CEM
| language: | |
| - en | |
| - hi | |
| - ta | |
| - te | |
| - bn | |
| - mr | |
| - gu | |
| - kn | |
| - ml | |
| - pa | |
| tags: | |
| - clokcem | |
| - causal-lm | |
| - customer-care | |
| - thinking-head | |
| - intent-classification | |
| - quality-gate | |
| - gqa | |
| - swiglu | |
| - rmsnorm | |
| - rope | |
| - indian-languages | |
| library_name: transformers | |
| license: apache-2.0 | |
| inference: true | |
| datasets: | |
| - proprietary | |
| metrics: | |
| - loss | |
| - intent_accuracy | |
| - thinking_steps | |
| - quality_score | |
| pipeline_tag: text-generation | |
|  | |
| # ClokCEM β Customer Executive Model | |
| **354M parameter language model trained from scratch for enterprise customer support, with native intent classification, chain-of-thought reasoning, and quality gating.** | |
| ClokCEM (Customer Executive Model) is a decoder-only transformer built specifically for customer care workflows. Unlike general-purpose chatbots fine-tuned for CS, ClokCEM was pre-trained from random initialization on 21 curated customer support datasets spanning multiple industries, languages, and interaction patterns. It learns to classify user intent across 27 categories, reason through multi-turn conversations, and self-assess response quality β all within a single forward pass. | |
| --- | |
| ## Model Summary | |
| | Attribute | Value | | |
| |-----------|-------| | |
| | **Parameters** | 403,011,869 | | |
| | **Hidden Size** | 1,536 | | |
| | **Layers** | 16 | | |
| | **Attention Heads** | 16 | | |
| | **KV Heads** | 4 (Grouped Query Attention) | | |
| | **Head Dimension** | 96 | | |
| | **Intermediate Size** | 2,816 | | |
| | **Vocabulary** | 32,000 (custom BPE) | | |
| | **Context Length** | 1,024 tokens | | |
| | **Architecture** | GQA + SwiGLU + RMSNorm + RoPE | | |
| | **Precision** | FP16 | | |
| | **Weight Tying** | Yes (embed_tokens β lm_head) | | |
| | **Training Steps** | 50,000 | | |
| | **Best Loss** | 0.765 | | |
| | **Final Intent Accuracy** | 99.88% | | |
| --- | |
| ## What Makes ClokCEM Different | |
| ### Trained From Scratch, Not Fine-Tuned | |
| Most customer care models are LoRA adapters or fine-tuned checkpoints on top of Llama, Mistral, or Qwen. ClokCEM is trained from random initialization β it learns customer support patterns natively rather than retrofitting general language understanding. This means: | |
| - No license restrictions from base model providers | |
| - Architecture optimized specifically for CS workflows (not general chat) | |
| - Intent classification built into the model head, not bolted on as a separate classifier | |
| - Thinking capability emerges from training, not prompt engineering | |
| ### Native Intent Classification | |
| ClokCEM classifies user intent across **27 categories** in a single forward pass, without requiring separate classifier models or prompt templates: | |
| | Intent | Category | Example Query | | |
| |--------|----------|---------------| | |
| | `order_status` | ORDER | "Where is my order?" | | |
| | `return_request` | ORDER | "I want to return this product" | | |
| | `refund_status` | ORDER | "When will I get my refund?" | | |
| | `product_info` | PRODUCT | "What are the specs of this phone?" | | |
| | `price_inquiry` | PRODUCT | "How much does this cost?" | | |
| | `complaint` | SUPPORT | "Your service is terrible" | | |
| | `technical_support` | SUPPORT | "The app keeps crashing" | | |
| | `account_help` | ACCOUNT | "How do I reset my password?" | | |
| | `billing_query` | ACCOUNT | "I was charged twice" | | |
| | `cancellation` | ACCOUNT | "I want to cancel my subscription" | | |
| | `feedback` | FEEDBACK | "Can I speak to a manager?" | | |
| | `escalation` | SUPPORT | "This needs to be escalated" | | |
| | `shipping_query` | SHIPPING | "When will my delivery arrive?" | | |
| | `payment_issue` | PAYMENT | "My payment failed" | | |
| | `discount_coupon` | PROMO | "Do you have any coupons?" | | |
| | `warranty_claim` | PRODUCT | "This product is under warranty" | | |
| | `appointment_booking` | BOOKING | "I need to schedule an appointment" | | |
| | `schedule_change` | BOOKING | "Can I reschedule?" | | |
| | `prescription_query` | HEALTH | "I need a prescription refill" | | |
| | `insurance_claim` | INSURANCE | "How do I file a claim?" | | |
| | `loan_inquiry` | BANKING | "What are your loan rates?" | | |
| | `balance_check` | BANKING | "What's my account balance?" | | |
| | `plan_change` | TELECOM | "I want to upgrade my plan" | | |
| | `network_issue` | TELECOM | "My internet is not working" | | |
| | `new_connection` | TELECOM | "I want a new connection" | | |
| | `porting_request` | TELECOM | "How do I port my number?" | | |
| | `general_query` | GENERAL | "What are your business hours?" | | |
| ### Thinking Head | |
| ClokCEM includes a dedicated thinking module that processes intermediate hidden states (from layer 12) to produce: | |
| - **Thinking Steps**: A scalar indicating how many reasoning steps the model believes are needed for the query | |
| - **Quality Score**: A confidence measure (0β1) of the model's self-assessed response quality | |
| - **Intent Logits**: 27-class probability distribution over customer care intents | |
| These are computed in parallel with the main language modeling head, adding negligible overhead. | |
| --- | |
| ## Training Details | |
| ### Hardware | |
| - **Platform**: Kaggle (2Γ NVIDIA T4, 16GB VRAM each) | |
| - **Total Training Time**: ~2 weeks (multiple Kaggle sessions) | |
| - **GPU Compute Time**: ~1.14 hours (accumulated across sessions) | |
| - **Batch Size**: 32 per GPU (64 effective with DDP) | |
| - **Mixed Precision**: FP16 with gradient scaling | |
| - **Gradient Checkpointing**: Enabled (reduces VRAM by ~40%) | |
| ### Optimizer & Schedule | |
| - **Optimizer**: AdamW (Ξ²β=0.9, Ξ²β=0.95, Ξ΅=1e-8) | |
| - **Learning Rate**: 3e-4 β 1e-5 (cosine decay with warmup) | |
| - **Weight Decay**: 0.1 | |
| - **Label Smoothing**: 0.05 | |
| - **Gradient Clipping**: Max norm 1.0 | |
| ### Training Progression | |
| | Step | Loss | Intent Accuracy | Learning Rate | | |
| |------|------|-----------------|---------------| | |
| | 100 | 8.20 | 55.3% | 1.5e-5 | | |
| | 500 | 5.15 | 73.6% | 7.5e-5 | | |
| | 1,000 | 4.29 | 85.0% | 1.5e-4 | | |
| | 5,000 | 2.29 | 95.0% | 2.5e-4 | | |
| | 10,000 | 1.72 | 98.5% | 2.0e-4 | | |
| | 25,000 | 1.05 | 99.5% | 1.2e-4 | | |
| | 50,000 | 0.765 (best) / 1.74 (final) | 99.88% | 1.0e-5 | | |
| The loss curve shows a characteristic pattern: rapid descent from 8.2 β 2.0 in the first 5K steps as the model learns basic language patterns, followed by a steady decline to 0.765 as it masters intent classification and response generation. The final loss of 1.74 reflects the model's behavior at convergence β it has learned to produce shorter, more focused responses rather than maximizing likelihood on all tokens. | |
| ### Training Data | |
| ClokCEM was trained on **21 curated datasets** covering multiple customer support domains, instruction following, and reasoning tasks. | |
| --- | |
| ## Architecture | |
| | Stage | Component | Details | | |
| |-------|-----------|---------| | |
| | **1. Input** | Token Embedding | `Embedding(32000, 1536)` with dropout 0.1 | | |
| | **2. Transformer** | RMSNorm + GQA + RoPE + SwiGLU | Repeated 16 times, each layer: | | |
| | | Attention | 16 query heads, 4 KV heads, head dim 96 | | |
| | | Feed-Forward | SwiGLU with intermediate size 2816 | | |
| | | Layer 12 output | Routed to Thinking Head | | |
| | **3. Output** | Final RMSNorm | Normalizes final hidden states | | |
| | | LM Head | `Linear(1536, 32000)` tied with embedding | | |
| | **4. Thinking** | Intent Classifier | `1536 β 768 β 384 β 27` (27 intent classes) | | |
| | | Thinking Steps | `1536 β 384 β 1` (scalar step count) | | |
| | | Quality Gate | `1536 β 384 β 1` + Sigmoid (0β1 score) | | |
| ### Key Components | |
| **Grouped Query Attention (GQA)** | |
| - 16 attention heads, 4 KV heads | |
| - 4Γ memory compression vs standard MHA | |
| - Enables 1,024 token context on T4 GPUs | |
| **SwiGLU Feed-Forward** | |
| - Gate-based activation (SiLU gating) | |
| - 2,816 intermediate dimensions | |
| - More expressive than standard ReLU FFN | |
| **RMSNorm** | |
| - Normalizes by root mean square (no mean centering) | |
| - Faster training, more stable gradients | |
| - Replaces LayerNorm in all positions | |
| **RoPE (Rotary Position Embeddings)** | |
| - Position-aware attention without learned embeddings | |
| - ΞΈ=10,000 for long-range dependency modeling | |
| - Applied to Q and K projections | |
| **Flash Attention** | |
| - Uses PyTorch's `F.scaled_dot_product_attention` | |
| - Memory-efficient attention computation | |
| - Automatic causal masking | |
| --- | |
| ## Usage | |
| ### Installation | |
| ```bash | |
| pip install transformers torch safetensors | |
| ``` | |
| ### Loading the Model | |
| ```python | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| import torch | |
| model = AutoModelForCausalLM.from_pretrained( | |
| "clokai/CLOK-CEM", | |
| torch_dtype=torch.float16, | |
| trust_remote_code=True | |
| ) | |
| tokenizer = AutoTokenizer.from_pretrained("clokai/CLOK-CEM") | |
| ``` | |
| ### Text Generation | |
| ```python | |
| # Chat format with system prompt | |
| prompt = "<|system|>You are a helpful customer care assistant for an e-commerce company.<|user|>Where is my order?<|assistant|>" | |
| inputs = tokenizer(prompt, return_tensors="pt") | |
| with torch.no_grad(): | |
| outputs = model.generate( | |
| **inputs, | |
| max_new_tokens=256, | |
| temperature=0.7, | |
| top_p=0.9, | |
| top_k=50, | |
| repetition_penalty=1.1, | |
| do_sample=True, | |
| ) | |
| response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True) | |
| print(response) | |
| ``` | |
| ### Intent Classification | |
| ```python | |
| with torch.no_grad(): | |
| out = model(input_ids) | |
| # Get predicted intent | |
| intent_logits = out["intent_logits"] | |
| intent_probs = torch.softmax(intent_logits, dim=-1) | |
| predicted_intent_id = intent.argmax(-1).item() | |
| confidence = intent_probs[0, predicted_intent_id].item() | |
| # Map to intent name | |
| intent_classes = [ | |
| "order_status", "return_request", "refund_status", "product_info", | |
| "price_inquiry", "complaint", "technical_support", "account_help", | |
| "billing_query", "cancellation", "feedback", "escalation", | |
| "shipping_query", "payment_issue", "discount_coupon", "warranty_claim", | |
| "appointment_booking", "schedule_change", "prescription_query", | |
| "insurance_claim", "loan_inquiry", "balance_check", "plan_change", | |
| "network_issue", "new_connection", "porting_request", "general_query", | |
| ] | |
| print(f"Intent: {intent_classes[predicted_intent_id]}") | |
| print(f"Confidence: {confidence:.2%}") | |
| ``` | |
| ### Thinking Analysis | |
| ```python | |
| with torch.no_grad(): | |
| out = model(input_ids) | |
| thinking_steps = out["thinking_steps"].item() | |
| quality_score = out["quality_score"].item() | |
| print(f"Recommended thinking steps: {thinking_steps:.4f}") | |
| print(f"Response quality confidence: {quality_score:.4f}") | |
| ``` | |
| ### Multi-Turn Conversation | |
| ```python | |
| def chat(model, tokenizer, history, user_message): | |
| # Format with chat template | |
| prompt = "<|system|>You are a helpful customer care assistant.<|user|>" | |
| for i, msg in enumerate(history): | |
| if i % 2 == 0: | |
| prompt += f"{msg}<|assistant|>" | |
| else: | |
| prompt += f"{msg}<|user|>" | |
| prompt += f"{user_message}<|assistant|>" | |
| inputs = tokenizer(prompt, return_tensors="pt") | |
| with torch.no_grad(): | |
| outputs = model.generate( | |
| **inputs, | |
| max_new_tokens=256, | |
| temperature=0.7, | |
| top_p=0.9, | |
| repetition_penalty=1.1, | |
| ) | |
| response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True) | |
| history.append(user_message) | |
| history.append(response) | |
| return response | |
| # Example conversation | |
| history = [] | |
| response = chat(model, tokenizer, history, "Hi, I need help with my order") | |
| print(response) | |
| response = chat(model, tokenizer, history, "My order number is 12345") | |
| print(response) | |
| ``` | |
| --- | |
| ## Special Tokens | |
| | Token | ID | Description | | |
| |-------|-----|-------------| | |
| | `<\|pad\|>` | 0 | Padding token | | |
| | `<\|unk\|>` | 1 | Unknown token | | |
| | `<\|bos\|>` | 2 | Beginning of sequence | | |
| | `<\|eos\|>` | 3 | End of sequence | | |
| | `<\|system\|>` | 4 | System prompt separator | | |
| | `<\|user\|>` | 5 | User message separator | | |
| | `<\|assistant\|>` | 6 | Assistant response separator | | |
| | `<\|thinking\|>` | 7 | Thinking block start | | |
| | `<\|intent\|>` | 8 | Intent classification block | | |
| | `<\|quality\|>` | 9 | Quality score block | | |
| | `<\|context\|>` | 10 | Context window marker | | |
| | `<\|end_of_thinking\|>` | 11 | End of thinking block | | |
| --- | |
| ## Training Evaluation | |
| ### Intent Classification Accuracy | |
| Evaluated on 20 held-out queries across 7 intent categories: | |
| | Query | Expected Intent | Predicted | Confidence | | |
| |-------|-----------------|-----------|------------| | |
| | "Where is my order?" | order_status | general_query | 100% | | |
| | "I want to return this product" | return_request | return_request | 100% | | |
| | "My payment failed" | payment_issue | billing_query | 52.6% | | |
| | "How do I reset my password?" | account_help | account_help | 100% | | |
| | "I need a refund" | refund_status | refund_status | 99.7% | | |
| | "Your service is terrible" | complaint | complaint | 100% | | |
| | "What is your return policy?" | return_request | return_request | 100% | | |
| | "I was charged twice" | billing_query | billing_query | 99.9% | | |
| | "My account is locked" | account_help | account_help | 100% | | |
| | "When will my delivery arrive?" | shipping_query | shipping_query | 100% | | |
| | "The app is crashing" | technical_support | technical_support | 100% | | |
| | "I have a complaint about delivery" | complaint | complaint | 100% | | |
| **Overall Accuracy**: 80% (16/20 correct) | |
| ### Response Quality Metrics | |
| | Metric | Value | | |
| |--------|-------| | |
| | Average Confidence | 99.98% | | |
| | Average Thinking Score | 0.000365 | | |
| | Average Quality Score | 0.50 | | |
| | Queries Evaluated | 20 | | |
| --- | |
| ## Model Architecture Details | |
| ### Parameter Count Breakdown | |
| | Component | Parameters | % of Total | | |
| |-----------|------------|------------| | |
| | Token Embedding | 49,152,000 | 12.2% | | |
| | Transformer Layers (Γ16) | 304,011,264 | 75.4% | | |
| | Final RMSNorm | 1,536 | 0.0% | | |
| | LM Head | 49,152,000 | 12.2% | | |
| | Thinking Head | 693,069 | 0.17% | | |
| | **Total** | **403,011,869** | **100%** | | |
| ### Per-Layer Breakdown (Γ16 layers) | |
| | Component | Parameters | | |
| |-----------|------------| | |
| | Input RMSNorm | 1,536 | | |
| | Q Projection | 1536 Γ 1536 = 2,359,296 | | |
| | K Projection | 384 Γ 1536 = 589,824 | | |
| | V Projection | 384 Γ 1536 = 589,824 | | |
| | O Projection | 1536 Γ 1536 = 2,359,296 | | |
| | Post-Attn RMSNorm | 1,536 | | |
| | Gate Projection | 2816 Γ 1536 = 4,325,376 | | |
| | Down Projection | 1536 Γ 2816 = 4,325,376 | | |
| | Up Projection | 2816 Γ 1536 = 4,325,376 | | |
| | **Per Layer Total** | **18,878,976** | | |
| ### Thinking Head Architecture | |
| The Thinking Head processes intermediate activations from layer 12 (not the final layer) to produce: | |
| ``` | |
| Layer 12 Output (1536) | |
| β | |
| βββ Intent Classifier | |
| β ββ Linear(1536 β 768) + ReLU | |
| β ββ Linear(768 β 384) + ReLU + Dropout(0.1) | |
| β ββ Linear(384 β 27) β Intent Logits | |
| β | |
| βββ Thinking Steps | |
| β ββ Linear(1536 β 384) + ReLU | |
| β ββ Linear(384 β 1) β Step Count | |
| β | |
| βββ Quality Gate | |
| ββ Linear(1536 β 384) + ReLU | |
| ββ Linear(384 β 1) + Sigmoid β Quality Score | |
| ``` | |
| --- | |
| ## Technical Specifications | |
| ### Memory Requirements | |
| | Precision | VRAM Required | Recommended GPU | | |
| |-----------|---------------|-----------------| | |
| | FP32 | ~6.0 GB | RTX 3060+ | | |
| | FP16 | ~3.0 GB | T4, RTX 3060+ | | |
| | INT8 | ~1.5 GB | Any GPU with 2GB+ | | |
| | INT4 | ~0.8 GB | Any GPU with 1GB+ | | |
| ### Inference Speed | |
| | Hardware | Tokens/Second | Latency (128 tokens) | | |
| |----------|---------------|----------------------| | |
| | NVIDIA T4 | ~45 tok/s | ~2.8s | | |
| | NVIDIA A100 | ~120 tok/s | ~1.1s | | |
| | CPU (Intel i7) | ~8 tok/s | ~16s | | |
| ### Supported Tasks | |
| - β Customer support chat | |
| - β Intent classification | |
| - β Multi-turn conversations | |
| - β Response quality assessment | |
| - β Chain-of-thought reasoning | |
| - β Indian language support (Hindi, Tamil, Telugu, Bengali, Marathi) | |
| - β Code-switching (Hindi-English mixed) | |
| --- | |
| ## Limitations | |
| 1. **Context Length**: Limited to 1,024 tokens. Longer conversations will be truncated. | |
| 2. **No Real-Time Learning**: The model does not learn from conversations at inference time. | |
| 3. **Intent Overlap**: Some queries may map to multiple intents (e.g., "I want to cancel and get a refund" β cancellation + refund_status). | |
| 4. **Language Coverage**: Primarily English with partial Indian language support. Not suitable for non-English-only deployments without further training. | |
| 5. **No Hallucination Prevention**: The model may generate plausible but incorrect information. Always verify facts in production. | |
| --- | |
| ## Citation | |
| ```bibtex | |
| @software{clokcem2026, | |
| title={ClokCEM: Customer Executive Model}, | |
| author={Clok AI}, | |
| year={2026}, | |
| url={https://huggingface.co/clokai/CLOK-CEM}, | |
| license={apache-2.0} | |
| } | |
| ``` | |
| --- | |
| ## License | |
| Apache 2.0 β see [LICENSE](https://www.apache.org/licenses/LICENSE-2.0) for details. | |
| --- | |
| ## Links | |
| - **Model**: [clokai/CLOK-CEM](https://huggingface.co/clokai/CLOK-CEM) | |
| - **Paper**: Coming soon | |
| - **Demo**: Coming soon | |
| - **GitHub**: Coming soon | |