Text Generation
GGUF
sixpert_moe
self-improving
self-scaffolding
reinforcement-learning
ornith
GRPO
conversational
reasoning
uncensored
multimodal
vision
function-calling
agentic
long-context
1m-context
cybersecurity
biomedical
trading
finance
coding
open-source
Instructions to use SixpertAI/SixpertK2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use SixpertAI/SixpertK2 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 SixpertAI/SixpertK2:Q4_K_M # Run inference directly in the terminal: llama cli -hf SixpertAI/SixpertK2:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf SixpertAI/SixpertK2:Q4_K_M # Run inference directly in the terminal: llama cli -hf SixpertAI/SixpertK2:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf SixpertAI/SixpertK2:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf SixpertAI/SixpertK2:Q4_K_M
Use Docker
docker model run hf.co/SixpertAI/SixpertK2:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use SixpertAI/SixpertK2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "SixpertAI/SixpertK2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SixpertAI/SixpertK2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/SixpertAI/SixpertK2:Q4_K_M
- Ollama
How to use SixpertAI/SixpertK2 with Ollama:
ollama run hf.co/SixpertAI/SixpertK2:Q4_K_M
- Unsloth Desktop
- Pi
How to use SixpertAI/SixpertK2 with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf SixpertAI/SixpertK2:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "SixpertAI/SixpertK2:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use SixpertAI/SixpertK2 with Docker Model Runner:
docker model run hf.co/SixpertAI/SixpertK2:Q4_K_M
- Lemonade
How to use SixpertAI/SixpertK2 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull SixpertAI/SixpertK2:Q4_K_M
Run and chat with the model
lemonade run user.SixpertK2-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use SixpertAI/SixpertK2 with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf SixpertAI/SixpertK2:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default SixpertAI/SixpertK2:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use SixpertAI/SixpertK2 with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf SixpertAI/SixpertK2:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "SixpertAI/SixpertK2:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Sixpert K2 - Function Calling Agent Example
|
| 4 |
+
============================================
|
| 5 |
+
Demonstrates how to use Sixpert K2's function calling capabilities
|
| 6 |
+
in an agentic loop. K2's MoE architecture provides specialized experts
|
| 7 |
+
for tool selection and argument formatting.
|
| 8 |
+
|
| 9 |
+
Usage:
|
| 10 |
+
python function_calling.py
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
import json
|
| 14 |
+
import sys
|
| 15 |
+
|
| 16 |
+
try:
|
| 17 |
+
from llama_cpp import Llama
|
| 18 |
+
except ImportError:
|
| 19 |
+
print("Installing llama-cpp-python...")
|
| 20 |
+
import subprocess
|
| 21 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "llama-cpp-python"])
|
| 22 |
+
from llama_cpp import Llama
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
TOOLS = [
|
| 26 |
+
{
|
| 27 |
+
"type": "function",
|
| 28 |
+
"function": {
|
| 29 |
+
"name": "search_research_papers",
|
| 30 |
+
"description": "Search for academic research papers on a topic",
|
| 31 |
+
"parameters": {
|
| 32 |
+
"type": "object",
|
| 33 |
+
"properties": {
|
| 34 |
+
"query": {"type": "string", "description": "Research topic"},
|
| 35 |
+
"year_from": {"type": "integer", "description": "Start year"},
|
| 36 |
+
"max_results": {"type": "integer", "default": 10},
|
| 37 |
+
},
|
| 38 |
+
"required": ["query"],
|
| 39 |
+
},
|
| 40 |
+
},
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"type": "function",
|
| 44 |
+
"function": {
|
| 45 |
+
"name": "run_python_code",
|
| 46 |
+
"description": "Execute Python code in a sandboxed environment",
|
| 47 |
+
"parameters": {
|
| 48 |
+
"type": "object",
|
| 49 |
+
"properties": {
|
| 50 |
+
"code": {"type": "string", "description": "Python code to execute"},
|
| 51 |
+
"timeout": {"type": "integer", "description": "Timeout in seconds", "default": 30},
|
| 52 |
+
},
|
| 53 |
+
"required": ["code"],
|
| 54 |
+
},
|
| 55 |
+
},
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"type": "function",
|
| 59 |
+
"function": {
|
| 60 |
+
"name": "analyze_data",
|
| 61 |
+
"description": "Analyze a dataset and provide statistical insights",
|
| 62 |
+
"parameters": {
|
| 63 |
+
"type": "object",
|
| 64 |
+
"properties": {
|
| 65 |
+
"data_description": {"type": "string", "description": "Description of the data"},
|
| 66 |
+
"analysis_type": {"type": "string", "enum": ["descriptive", "inferential", "predictive"], "description": "Type of analysis"},
|
| 67 |
+
},
|
| 68 |
+
"required": ["data_description", "analysis_type"],
|
| 69 |
+
},
|
| 70 |
+
},
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"type": "function",
|
| 74 |
+
"function": {
|
| 75 |
+
"name": "calculate_math",
|
| 76 |
+
"description": "Perform mathematical calculations",
|
| 77 |
+
"parameters": {
|
| 78 |
+
"type": "object",
|
| 79 |
+
"properties": {
|
| 80 |
+
"expression": {"type": "string", "description": "Mathematical expression"},
|
| 81 |
+
"precision": {"type": "integer", "description": "Decimal places", "default": 6},
|
| 82 |
+
},
|
| 83 |
+
"required": ["expression"],
|
| 84 |
+
},
|
| 85 |
+
},
|
| 86 |
+
},
|
| 87 |
+
]
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
def mock_execute_tool(tool_call: dict) -> str:
|
| 91 |
+
"""Mock execution of a tool call. Replace with real implementations."""
|
| 92 |
+
name = tool_call["function"]["name"]
|
| 93 |
+
args = json.loads(tool_call["function"]["arguments"])
|
| 94 |
+
|
| 95 |
+
print(f" Tool call: {name}({json.dumps(args, indent=2)})")
|
| 96 |
+
|
| 97 |
+
if name == "search_research_papers":
|
| 98 |
+
return json.dumps({
|
| 99 |
+
"papers": [
|
| 100 |
+
{"title": f"Advances in {args['query']}", "year": 2025, "citations": 42},
|
| 101 |
+
{"title": f"Survey of {args['query']} Methods", "year": 2024, "citations": 128},
|
| 102 |
+
],
|
| 103 |
+
"total_found": 1247,
|
| 104 |
+
})
|
| 105 |
+
elif name == "run_python_code":
|
| 106 |
+
return json.dumps({"stdout": "42", "stderr": "", "exit_code": 0})
|
| 107 |
+
elif name == "analyze_data":
|
| 108 |
+
return json.dumps({
|
| 109 |
+
"summary": "Dataset shows normal distribution with mean=0.0, std=1.0",
|
| 110 |
+
"insights": ["No significant outliers detected", "Data is well-scaled"],
|
| 111 |
+
})
|
| 112 |
+
elif name == "calculate_math":
|
| 113 |
+
return json.dumps({"result": 3.141593, "expression": args["expression"]})
|
| 114 |
+
|
| 115 |
+
return json.dumps({"error": f"Unknown tool: {name}"})
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
def run_agent(model_path: str, user_query: str, max_turns: int = 5):
|
| 119 |
+
"""Run an agentic loop with function calling."""
|
| 120 |
+
print(f"\nUser Query: {user_query}")
|
| 121 |
+
print("-" * 50)
|
| 122 |
+
|
| 123 |
+
llm = Llama(
|
| 124 |
+
model_path=model_path,
|
| 125 |
+
n_ctx=16384,
|
| 126 |
+
n_gpu_layers=-1,
|
| 127 |
+
verbose=False,
|
| 128 |
+
)
|
| 129 |
+
|
| 130 |
+
messages = [
|
| 131 |
+
{
|
| 132 |
+
"role": "system",
|
| 133 |
+
"content": (
|
| 134 |
+
"You are Sixpert K2, a deep reasoning engine with advanced "
|
| 135 |
+
"agentic capabilities. When the user asks a question that "
|
| 136 |
+
"requires external tools, use the available functions. "
|
| 137 |
+
"Think step-by-step and plan your approach before calling tools. "
|
| 138 |
+
"You can call multiple tools in sequence to solve complex problems."
|
| 139 |
+
),
|
| 140 |
+
},
|
| 141 |
+
{"role": "user", "content": user_query},
|
| 142 |
+
]
|
| 143 |
+
|
| 144 |
+
for turn in range(max_turns):
|
| 145 |
+
print(f"\n--- Turn {turn + 1} ---")
|
| 146 |
+
|
| 147 |
+
response = llm.create_chat_completion(
|
| 148 |
+
messages=messages,
|
| 149 |
+
tools=TOOLS,
|
| 150 |
+
tool_choice="auto",
|
| 151 |
+
temperature=0.6,
|
| 152 |
+
stream=False,
|
| 153 |
+
)
|
| 154 |
+
|
| 155 |
+
choice = response["choices"][0]
|
| 156 |
+
message = choice["message"]
|
| 157 |
+
|
| 158 |
+
if message.get("tool_calls"):
|
| 159 |
+
for tool_call in message["tool_calls"]:
|
| 160 |
+
print(f" Tool call: {tool_call['function']['name']}")
|
| 161 |
+
tool_result = mock_execute_tool(tool_call)
|
| 162 |
+
print(f" Result: {tool_result[:150]}...")
|
| 163 |
+
|
| 164 |
+
messages.append({
|
| 165 |
+
"role": "assistant",
|
| 166 |
+
"content": None,
|
| 167 |
+
"tool_calls": [tool_call],
|
| 168 |
+
})
|
| 169 |
+
messages.append({
|
| 170 |
+
"role": "tool",
|
| 171 |
+
"tool_call_id": tool_call["id"],
|
| 172 |
+
"content": tool_result,
|
| 173 |
+
})
|
| 174 |
+
else:
|
| 175 |
+
print(f"\nSixpert K2: {message['content']}")
|
| 176 |
+
break
|
| 177 |
+
else:
|
| 178 |
+
print("\nReached maximum turns.")
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
def main():
|
| 182 |
+
import argparse
|
| 183 |
+
parser = argparse.ArgumentParser(description="Sixpert K2 Function Calling")
|
| 184 |
+
parser.add_argument("--model", type=str, default="SixpertK2.gguf", help="Path to GGUF model")
|
| 185 |
+
parser.add_argument("--query", type=str, default="Calculate pi to 6 decimal places and search for research on numerical methods", help="User query")
|
| 186 |
+
|
| 187 |
+
args = parser.parse_args()
|
| 188 |
+
|
| 189 |
+
print("=" * 60)
|
| 190 |
+
print(" Sixpert K2 - Function Calling Agent")
|
| 191 |
+
print(" MoE Architecture | Deep Reasoning")
|
| 192 |
+
print("=" * 60)
|
| 193 |
+
|
| 194 |
+
run_agent(args.model, args.query)
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
if __name__ == "__main__":
|
| 198 |
+
main()
|