cube-code / README.md
FMA03's picture
Add files using upload-large-folder tool
ebae2d7 verified
|
Raw History Blame Contribute Delete
4.39 kB
metadata
license: apache-2.0
base_model: Qwen/Qwen2.5-Coder-7B-Instruct
library_name: peft
language:
  - ja
  - en
tags:
  - lora
  - peft
  - code-generation
  - qwen2.5-coder
pipeline_tag: text-generation

Cube Code

Cube Code は、普通〜軽い規模の Web アプリ(HTML/CSS/JS の単体アプリ)の生成に特化した専門モデルです。自作 AI プロジェクト Cube の一部として開発されました。Qwen2.5-Coder-7B-Instruct に LoRA アダプタを適用したもので、このリポジトリではアダプタのみを配布します(土台モデルは公式リポジトリから別途取得してください)。

得意なのは、TODO リスト、タイマー、単位変換ツール、メモ帳、簡単なゲームといった、数百行程度の単一〜少数ファイルで完結する Web アプリの生成です。1,000 行級の大規模プロジェクトを対象としたモデルではありません。

土台モデルとライセンス

  • 土台モデル: Qwen/Qwen2.5-Coder-7B-Instruct
  • ライセンス: Apache 2.0(土台モデル・本アダプタとも)
  • LoRA 設定: r=16、lora_alpha=32、lora_dropout=0.05、対象モジュール = q/k/v/o/gate/up/down の各 proj

使い方

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

base_id = "Qwen/Qwen2.5-Coder-7B-Instruct"
adapter_id = "FMA03/cube-code"

tokenizer = AutoTokenizer.from_pretrained(base_id)
base = AutoModelForCausalLM.from_pretrained(
    base_id, torch_dtype="auto", device_map="auto"
)
model = PeftModel.from_pretrained(base, adapter_id)

messages = [
    {"role": "user", "content": "ストップウォッチの Web アプリを作ってください。"},
]
inputs = tokenizer.apply_chat_template(
    messages, add_generation_prompt=True, return_tensors="pt"
).to(model.device)
out = model.generate(**inputs, max_new_tokens=2048)
print(tokenizer.decode(out[0][inputs.shape[-1]:], skip_special_tokens=True))

測定結果(自作ベンチマーク)

自作ベンチマーク(Web アプリ生成 10 題、生成物をブラウザ上で実際に動作させて外部検証)では、従来条件で 9/10 題が合格しました。検証ハーネスを改良した条件(表示欄が <input> の場合にその value を読み取るよう検証を修正し、課題の契約をプロンプトで事前に明示)では、残りの calculator も修正 round 4 で合格し、10/10 相当となりました。なお、合格した calculator のコードには「0」ボタンが含まれていませんでした(当該チェックには 0 を押す操作が無かったため、未検証のまま通過しました)。このベンチマークは自作の小規模なものであり、公開ベンチマークのスコアではありません。

学習データは、自作の検証ハーネスを通過した手本コードのみで構成しています(106 件)。


English summary

Cube Code is a LoRA adapter for Qwen/Qwen2.5-Coder-7B-Instruct (Apache 2.0), specialized in generating small, ordinary web apps — single-file HTML/CSS/JS applications such as to-do lists, timers, unit converters, memo pads, and mini games. It is part of Cube, a personal AI project. This repository distributes the adapter only; the base model must be obtained from its official repository.

On the author's own small benchmark (10 web-app tasks, each verified externally by running the generated app in a browser), it passed 9/10 tasks under the original harness conditions. Under an improved harness (the verifier reads the value of <input> display fields, and the task contract is stated in the prompt up front), the remaining calculator task also passed at fix round 4, i.e. 10/10 under those conditions. Note that the passing calculator code did not include a "0" button (the checks never pressed 0, so this went unverified). This is a small, self-made benchmark, not a public leaderboard score.

LoRA config: r=16, alpha=32, dropout=0.05, target modules = q/k/v/o/gate/up/down projections. Training data (106 examples) consists solely of reference code that passed the project's own verification harness.