Sui-lang generation AI
https://github.com/TakatoHonda/sui-lang
based on Qwen3-8B
from llama_cpp import Llama
import llama_cpp
# model load
base_model = "qwen3-8b"
quant = "Q4_K_M"
llm = Llama.from_pretrained(
repo_id=f"kishida/sui-lang-{base_model}",
filename=f"sui-lang-{base_model}.{quant}.gguf",
seed=4321,
n_ctx=2048,
n_gpu_layers=-1,
)
lang_spec = """
## Sui言語仕様
Suiは純粋なロジック言語。1行1命令、識別子は連番のみ。
### 命令
= VAR VAL 代入
+ R A B 加算 (R = A + B)
- R A B 減算
* R A B 乗算
/ R A B 除算
% R A B 剰余
< R A B 小なり (R = 1 if A < B else 0)
> R A B 大なり
~ R A B 等価
! R A NOT
& R A B AND
| R A B OR
? COND LABEL 条件ジャンプ(LABELは整数のみ)
@ LABEL 無条件ジャンプ(LABELは整数のみ)
: LABEL ラベル定義(LABELは整数のみ)
# ID ARGC { 関数定義
} 関数終了
$ R FN ARGS... 関数呼び出し
^ VAL return
[ VAR SIZE 配列作成
] R ARR IDX 配列読み取り
{ ARR IDX VAL 配列書き込み
. VAL 出力
, VAR 入力
; COMMENT コメント
### 変数
v0, v1, v2... ローカル変数
g0, g1, g2... グローバル変数(状態、UIからアクセス可能)
a0, a1, a2... 関数引数
### ラベル(重要)
- **LABELは必ず整数**(例: `0`, `1`, `2`)
- `: start_label` のような **文字列ラベルは禁止**
### 例
```sui
; 与えられた整数を3倍する
# 0 1 {
* v0 a0 3
^ v0
}
```
```sui
; Print 1 to 10
= v0 1
: 0
> v1 v0 10
? v1 1
. v0
+ v0 v0 1
@ 0
: 1
```
### 注意
コメントは ; で始める。#でのコメントは禁止
"""
system_prompt = """あなたはSui言語を使ったアプリケーション開発者です。
ユーザーに与えられた課題をSui言語の命令で実装してください。
実装のみを出力してください。
Sui言語の仕様は次のとおり
{}
""".format(lang_spec)
# streaming
def chat(msg):
print(msg)
res = llm.create_chat_completion(
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": msg},
],
temperature=0.7,
)
return res["choices"][0]["message"]["content"]
template = """/nothink
次の仕様を満たす{}を実装してください。
仕様:{}
"""
problem = "整数A,B,Cの最大値を返す。"
print("sui-lang")
print(problem)
print(chat(template.format("3引数関数", problem)))
"""
# 0 3 {
; Compare A and B
> v0 a0 a1
? v0 2
; A > B, compare A and C
> v0 a0 a2
? v0 3
; A > C, compare B and C
> v0 a1 a2
? v0 4
; B > C, return C
^ a2
; A > B, A > C, B > C, return C
^ a2
}
"""
# それっぽいけど正しくはない
- Downloads last month
- 1
Hardware compatibility
Log In to add your hardware
4-bit
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support