File size: 4,318 Bytes
1e9a541
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# Sixpert K2 - Complete Usage Guide

## Quick Start

### Option 1: Ollama (Easiest)

```bash
# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh

# Create and run
ollama create sixpert-k2 -f OllamaModelfile

# Chat
ollama run sixpert-k2
```

### Option 2: llama-cpp-python (Python)

```bash
pip install llama-cpp-python
python examples/generate.py --prompt "Explain quantum computing in depth"
```

### Option 3: API Server

```bash
pip install llama-cpp-python
python examples/api_server.py --model SixpertK2.gguf
```

### Option 4: LM Studio

1. Download LM Studio from https://lmstudio.ai
2. Import `SixpertK2.gguf`
3. Chat with the Sixpert K2 preset

## Chat Format

Sixpert K2 uses the following chat template:

```
<|im_start|>system
You are a helpful assistant.<|im_end|>
<|im_start|>user
What is quantum computing?<|im_end|>
<|im_start|>assistant
Quantum computing uses quantum mechanical phenomena...<|im_end|>
```

## Recommended Settings

| Parameter | Value | Notes |
|---|---|---|
| temperature | 0.6 | Slightly lower for reasoning tasks |
| top_p | 0.85 | Nucleus sampling |
| top_k | 50 | Limit token selection |
| repeat_penalty | 1.08 | Prevent repetition |
| max_tokens | 16384 | Extended output for deep reasoning |
| context_size | 131072 | Full context window |

## MoE-Specific Tips

### When to Use K2 vs K1

| Task Type | Best Model | Reason |
|---|---|---|
| Fast responses | K1 (Dense) | Predictable latency |
| Deep reasoning | K2 (MoE) | Specialized reasoning experts |
| Long documents | K2 (MoE) | Better long-context handling |
| Code generation | Either | K2 slightly better |
| Math proofs | K2 (MoE) | Math expert specialization |
| Simple Q&A | K1 (Dense) | Faster, sufficient quality |
| Agentic tasks | K2 (MoE) | Better tool orchestration |
| Vision tasks | Either | Both support multimodal |

### Long-Context Usage

K2 is optimized for long-context understanding. For documents exceeding 32K tokens:

```python
llm = Llama(
    model_path="SixpertK2.gguf",
    n_ctx=131072,  # Full context window
    n_gpu_layers=-1,
)

# Feed entire documents
response = llm.create_chat_completion(
    messages=[{
        "role": "user",
        "content": f"Based on the following document, answer my question:\n\n{full_document}\n\nQuestion: What are the key findings?"
    }],
    max_tokens=4096,
)
```

## Function Calling

See `examples/function_calling.py` for a complete agentic implementation.

## Vision / Multimodal

See `examples/vision_example.py` for image analysis examples.

## Integration Examples

### OpenAI-Compatible Client

```python
from openai import OpenAI

client = OpenAI(base_url="http://localhost:8000/v1", api_key="not-needed")

response = client.chat.completions.create(
    model="sixpert-k2",
    messages=[{"role": "user", "content": "Prove that sqrt(2) is irrational"}],
    temperature=0.6,
    max_tokens=4096,
)
print(response.choices[0].message.content)
```

### LangChain Integration

```python
from langchain.llms import LlamaCpp

llm = LlamaCpp(
    model_path="SixpertK2.gguf",
    temperature=0.6,
    n_ctx=131072,
    n_gpu_layers=-1,
)

result = llm.invoke("Explain the theory of relativity in detail")
print(result)
```

### AutoGen Integration

```python
from autogen import AssistantAgent

assistant = AssistantAgent(
    name="sixpert_k2",
    llm_config={"config_list": [{"model": "sixpert-k2", "base_url": "http://localhost:8000/v1", "api_key": "not-needed"}]},
    system_message="You are Sixpert K2, a deep reasoning engine.",
)
```

## Performance Tips

1. **GPU Offloading**: Set `n_gpu_layers=-1` for full GPU offload (fits in 8GB VRAM)
2. **Temperature**: Use 0.3-0.5 for mathematical proofs, 0.6-0.7 for creative tasks
3. **Context Size**: Start with 32768, increase to 131072 for long documents
4. **Batch Inference**: Use the API server for batch processing
5. **Quantization**: Q4_K_M is recommended; Q6_K for higher quality

## Troubleshooting

| Issue | Solution |
|---|---|
| Slow generation | Ensure GPU offloading is enabled |
| Out of memory | Reduce context size to 32768 or 8192 |
| Repetitive output | Increase `repeat_penalty` to 1.1-1.15 |
| Shallow reasoning | Lower temperature to 0.3-0.5 |
| Long response needed | Set `max_tokens` to 8192 or 16384 |
| Context overflow | Use 4096 context for testing |