Text Generation
Transformers
Safetensors
GGUF
English
qwen2
qwen2.5
tool-calling
function-calling
merged
long-context
conversational
agent
sakthai
house-of-sak
benchmark
eval
ollama
cpu-inference
local-ai
Eval Results (legacy)
Eval Results
text-generation-inference
Instructions to use Nanthasit/sakthai-context-7b-merged with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Nanthasit/sakthai-context-7b-merged with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Nanthasit/sakthai-context-7b-merged") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Nanthasit/sakthai-context-7b-merged") model = AutoModelForCausalLM.from_pretrained("Nanthasit/sakthai-context-7b-merged", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Nanthasit/sakthai-context-7b-merged 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 Nanthasit/sakthai-context-7b-merged:Q8_0 # Run inference directly in the terminal: llama cli -hf Nanthasit/sakthai-context-7b-merged:Q8_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Nanthasit/sakthai-context-7b-merged:Q8_0 # Run inference directly in the terminal: llama cli -hf Nanthasit/sakthai-context-7b-merged:Q8_0
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 Nanthasit/sakthai-context-7b-merged:Q8_0 # Run inference directly in the terminal: ./llama-cli -hf Nanthasit/sakthai-context-7b-merged:Q8_0
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 Nanthasit/sakthai-context-7b-merged:Q8_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf Nanthasit/sakthai-context-7b-merged:Q8_0
Use Docker
docker model run hf.co/Nanthasit/sakthai-context-7b-merged:Q8_0
- LM Studio
- Jan
- vLLM
How to use Nanthasit/sakthai-context-7b-merged with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Nanthasit/sakthai-context-7b-merged" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Nanthasit/sakthai-context-7b-merged", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Nanthasit/sakthai-context-7b-merged:Q8_0
- SGLang
How to use Nanthasit/sakthai-context-7b-merged 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 "Nanthasit/sakthai-context-7b-merged" \ --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": "Nanthasit/sakthai-context-7b-merged", "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 "Nanthasit/sakthai-context-7b-merged" \ --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": "Nanthasit/sakthai-context-7b-merged", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use Nanthasit/sakthai-context-7b-merged with Ollama:
ollama run hf.co/Nanthasit/sakthai-context-7b-merged:Q8_0
- Unsloth Desktop
- Pi
How to use Nanthasit/sakthai-context-7b-merged with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Nanthasit/sakthai-context-7b-merged:Q8_0
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": "Nanthasit/sakthai-context-7b-merged:Q8_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use Nanthasit/sakthai-context-7b-merged with Docker Model Runner:
docker model run hf.co/Nanthasit/sakthai-context-7b-merged:Q8_0
- Lemonade
How to use Nanthasit/sakthai-context-7b-merged with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Nanthasit/sakthai-context-7b-merged:Q8_0
Run and chat with the model
lemonade run user.sakthai-context-7b-merged-Q8_0
List all available models
lemonade list
- Hermes Agent
How to use Nanthasit/sakthai-context-7b-merged with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Nanthasit/sakthai-context-7b-merged:Q8_0
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 Nanthasit/sakthai-context-7b-merged:Q8_0
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use Nanthasit/sakthai-context-7b-merged with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Nanthasit/sakthai-context-7b-merged:Q8_0
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 "Nanthasit/sakthai-context-7b-merged:Q8_0" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Upload eval/workbench-7b-endpoint-test.py with huggingface_hub
Browse files
eval/workbench-7b-endpoint-test.py
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Workbench test: 7B merged model via Inference Endpoint."""
|
| 3 |
+
import json, time, os, sys
|
| 4 |
+
import requests
|
| 5 |
+
|
| 6 |
+
MODEL = "Nanthasit/sakthai-context-7b-merged"
|
| 7 |
+
ENDPOINT_URL = None # Set dynamically after deployment
|
| 8 |
+
|
| 9 |
+
# Read endpoint URL from args or env
|
| 10 |
+
if len(sys.argv) > 1:
|
| 11 |
+
ENDPOINT_URL = sys.argv[1]
|
| 12 |
+
elif "ENDPOINT_URL" in os.environ:
|
| 13 |
+
ENDPOINT_URL = os.environ["ENDPOINT_URL"]
|
| 14 |
+
else:
|
| 15 |
+
print("Usage: python3 sakthai-7b-workbench-test.py <endpoint_url>")
|
| 16 |
+
print("Or set ENDPOINT_URL env var")
|
| 17 |
+
sys.exit(1)
|
| 18 |
+
|
| 19 |
+
TOKEN_PATH = "/opt/data/profiles/sakthai/home/.cache/huggingface/token"
|
| 20 |
+
with open(TOKEN_PATH) as f:
|
| 21 |
+
HF_TOKEN = f.read().strip()
|
| 22 |
+
|
| 23 |
+
HEADERS = {
|
| 24 |
+
"Authorization": f"Bearer {HF_TOKEN}",
|
| 25 |
+
"Content-Type": "application/json"
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
tests = [
|
| 29 |
+
{
|
| 30 |
+
"name": "basic_greeting",
|
| 31 |
+
"desc": "Say hello in one sentence",
|
| 32 |
+
"messages": [
|
| 33 |
+
{"role": "system", "content": "You are SakThai, a helpful assistant. Be concise."},
|
| 34 |
+
{"role": "user", "content": "Say hello in one sentence."}
|
| 35 |
+
],
|
| 36 |
+
"checks": ["non_empty", "substantial"]
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"name": "tool_call_intent",
|
| 40 |
+
"desc": "Tool-use intent",
|
| 41 |
+
"messages": [
|
| 42 |
+
{"role": "system", "content": "You are SakThai with tools: search(query), read_file(path), run_command(command)."},
|
| 43 |
+
{"role": "user", "content": "Search for the latest AI news"}
|
| 44 |
+
],
|
| 45 |
+
"checks": ["non_empty", "substantial"]
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"name": "name_recall",
|
| 49 |
+
"desc": "Remember name across 3 turns",
|
| 50 |
+
"messages": [
|
| 51 |
+
{"role": "system", "content": "You are SakThai."},
|
| 52 |
+
{"role": "user", "content": "My name is Beer."},
|
| 53 |
+
{"role": "assistant", "content": "Nice to meet you, Beer!"},
|
| 54 |
+
{"role": "user", "content": "What's my name?"}
|
| 55 |
+
],
|
| 56 |
+
"checks": ["non_empty", "name_recall"]
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"name": "factual_qa",
|
| 60 |
+
"desc": "Simple factual question",
|
| 61 |
+
"messages": [
|
| 62 |
+
{"role": "system", "content": "You are SakThai. Be concise."},
|
| 63 |
+
{"role": "user", "content": "What is the capital of Japan?"}
|
| 64 |
+
],
|
| 65 |
+
"checks": ["non_empty", "correct"]
|
| 66 |
+
},
|
| 67 |
+
{
|
| 68 |
+
"name": "json_output",
|
| 69 |
+
"desc": "Structured JSON",
|
| 70 |
+
"messages": [
|
| 71 |
+
{"role": "system", "content": "You are SakThai. Only respond with valid JSON."},
|
| 72 |
+
{"role": "user", "content": 'List 3 ML frameworks: {"frameworks": ["a","b","c"]}'}
|
| 73 |
+
],
|
| 74 |
+
"checks": ["non_empty", "valid_json"]
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
"name": "instruction_following",
|
| 78 |
+
"desc": "Follow formatting instruction",
|
| 79 |
+
"messages": [
|
| 80 |
+
{"role": "system", "content": "You are SakThai. Exactly one sentence."},
|
| 81 |
+
{"role": "user", "content": "Explain what a transformer is."}
|
| 82 |
+
],
|
| 83 |
+
"checks": ["non_empty", "substantial"]
|
| 84 |
+
},
|
| 85 |
+
{
|
| 86 |
+
"name": "multi_step_reasoning",
|
| 87 |
+
"desc": "Multi-step reasoning",
|
| 88 |
+
"messages": [
|
| 89 |
+
{"role": "system", "content": "You are SakThai, a helpful assistant."},
|
| 90 |
+
{"role": "user", "content": "If you have 3 apples and give away 1, then buy 5 more, how many do you have? Show your work."}
|
| 91 |
+
],
|
| 92 |
+
"checks": ["non_empty", "substantial"]
|
| 93 |
+
},
|
| 94 |
+
{
|
| 95 |
+
"name": "context_window",
|
| 96 |
+
"desc": "Longer context understanding",
|
| 97 |
+
"messages": [
|
| 98 |
+
{"role": "system", "content": "You are SakThai. Be concise."},
|
| 99 |
+
{"role": "user", "content": "The transformer architecture introduced in 'Attention Is All You Need' revolutionized NLP by replacing recurrent layers with multi-head self-attention. It uses positional encodings, layer normalization, and feed-forward networks in an encoder-decoder structure. BERT, GPT, and T5 all build on this foundation. What year was the original transformer paper published?"}
|
| 100 |
+
],
|
| 101 |
+
"checks": ["non_empty", "correct_answer"]
|
| 102 |
+
}
|
| 103 |
+
]
|
| 104 |
+
|
| 105 |
+
print(f"π§ͺ WORKBENCH TEST β SakThai Context 7B")
|
| 106 |
+
print(f" Endpoint: {ENDPOINT_URL}")
|
| 107 |
+
print(f" Model: {MODEL}")
|
| 108 |
+
print(f" Time: {time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())}")
|
| 109 |
+
print()
|
| 110 |
+
|
| 111 |
+
results = []
|
| 112 |
+
for i, test in enumerate(tests):
|
| 113 |
+
print(f"{'β'*60}")
|
| 114 |
+
print(f"TEST {i+1}: {test['name']} β {test['desc']}")
|
| 115 |
+
print(f" Turns: {len(test['messages'])}", flush=True)
|
| 116 |
+
|
| 117 |
+
try:
|
| 118 |
+
t0 = time.time()
|
| 119 |
+
resp = requests.post(
|
| 120 |
+
f"{ENDPOINT_URL}/v1/chat/completions",
|
| 121 |
+
headers=HEADERS,
|
| 122 |
+
json={
|
| 123 |
+
"model": "tgi",
|
| 124 |
+
"messages": test["messages"],
|
| 125 |
+
"max_tokens": 256,
|
| 126 |
+
"temperature": 0.1,
|
| 127 |
+
},
|
| 128 |
+
timeout=120
|
| 129 |
+
)
|
| 130 |
+
elapsed = time.time() - t0
|
| 131 |
+
|
| 132 |
+
if resp.status_code != 200:
|
| 133 |
+
raise Exception(f"HTTP {resp.status_code}: {resp.text[:200]}")
|
| 134 |
+
|
| 135 |
+
data = resp.json()
|
| 136 |
+
choice = data["choices"][0]
|
| 137 |
+
content = choice["message"]["content"].strip()
|
| 138 |
+
finish = choice.get("finish_reason", "")
|
| 139 |
+
usage = data.get("usage", {})
|
| 140 |
+
|
| 141 |
+
# Run quality checks
|
| 142 |
+
checks = []
|
| 143 |
+
if len(content) > 0:
|
| 144 |
+
checks.append("non_empty")
|
| 145 |
+
if len(content) > 10:
|
| 146 |
+
checks.append("substantial")
|
| 147 |
+
|
| 148 |
+
if "beer" in content.lower() and test["name"] == "name_recall":
|
| 149 |
+
checks.append("name_recall")
|
| 150 |
+
if "tokyo" in content.lower() and test["name"] == "factual_qa":
|
| 151 |
+
checks.append("correct")
|
| 152 |
+
if "2017" in content and test["name"] == "context_window":
|
| 153 |
+
checks.append("correct_answer")
|
| 154 |
+
if test["name"] == "json_output":
|
| 155 |
+
try:
|
| 156 |
+
json.loads(content)
|
| 157 |
+
checks.append("valid_json")
|
| 158 |
+
except:
|
| 159 |
+
pass
|
| 160 |
+
|
| 161 |
+
result = {
|
| 162 |
+
"name": test["name"],
|
| 163 |
+
"passed": len(checks) > 0,
|
| 164 |
+
"response_preview": content[:200],
|
| 165 |
+
"response_length": len(content),
|
| 166 |
+
"latency_seconds": round(elapsed, 2),
|
| 167 |
+
"prompt_tokens": usage.get("prompt_tokens"),
|
| 168 |
+
"completion_tokens": usage.get("completion_tokens"),
|
| 169 |
+
"finish_reason": finish,
|
| 170 |
+
"checks": checks
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
print(f" {'β
' if result['passed'] else 'β'} Response: {content[:150]}")
|
| 174 |
+
print(f" β± {elapsed:.2f}s | β
{checks} | π {finish}")
|
| 175 |
+
if result.get("prompt_tokens"):
|
| 176 |
+
print(f" π {result['prompt_tokens']}β{result['completion_tokens']}")
|
| 177 |
+
|
| 178 |
+
except Exception as e:
|
| 179 |
+
result = {
|
| 180 |
+
"name": test["name"],
|
| 181 |
+
"passed": False,
|
| 182 |
+
"error": str(e)[:300]
|
| 183 |
+
}
|
| 184 |
+
print(f" β FAIL: {e}")
|
| 185 |
+
|
| 186 |
+
results.append(result)
|
| 187 |
+
sys.stdout.flush()
|
| 188 |
+
|
| 189 |
+
# Summary
|
| 190 |
+
print(f"\n{'='*60}")
|
| 191 |
+
passed = sum(1 for r in results if r.get("passed"))
|
| 192 |
+
total = len(results)
|
| 193 |
+
print(f"π WORKBENCH SUMMARY β 7B ({MODEL})")
|
| 194 |
+
print(f"\nResults: {passed}/{total} passed")
|
| 195 |
+
print()
|
| 196 |
+
|
| 197 |
+
for r in results:
|
| 198 |
+
status = "β
" if r.get("passed") else "β"
|
| 199 |
+
name = r["name"].ljust(22)
|
| 200 |
+
lat = f"{r.get('latency_seconds', 0):.1f}s" if r.get("passed") else " - "
|
| 201 |
+
detail = str(r.get("checks", r.get("error", "?")[:60]))
|
| 202 |
+
print(f" {status} {name} β± {lat} {detail}")
|
| 203 |
+
|
| 204 |
+
# Save record
|
| 205 |
+
record = {
|
| 206 |
+
"test_run": f"workbench-{time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())}",
|
| 207 |
+
"model": MODEL,
|
| 208 |
+
"endpoint_url": ENDPOINT_URL,
|
| 209 |
+
"timestamp": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
| 210 |
+
"results": results,
|
| 211 |
+
"summary": f"{passed}/{total} passed"
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
output_path = "/opt/data/sakthai-7b-workbench-test-record.json"
|
| 215 |
+
with open(output_path, "w") as f:
|
| 216 |
+
json.dump(record, f, indent=2)
|
| 217 |
+
print(f"\nπΎ Saved: {output_path}")
|
| 218 |
+
print("π Done.")
|