Heliars-Carla-X1

Heliars-Carla-X1 是基於 unsloth/phi-4-unsloth-bnb-4bit(Microsoft Phi-4)進行監督式微調的語言模型,專門從英文或繁體中文的自然語言描述生成合法的 OpenDRIVE (.xodr) 路網,供 CARLA 自動駕駛模擬器使用。

模型資訊

基本規格

基底模型 unsloth/phi-4-unsloth-bnb-4bit
架構 LlamaForCausalLM(Phi-4 via Unsloth)
參數量 ~14B
精度 bfloat16
最大 Context 長度 16,384 tokens
訓練方式 監督式微調(SFT)+ LoRA
框架 Unsloth + HuggingFace TRL
任務 OpenDRIVE 路網生成
輸入語言 英文、繁體中文
授權 MIT

訓練細節

Heliars-Carla-X1 使用雙語(英文 + 繁體中文)資料集進行 LoRA 微調,訓練資料由自然語言路網描述與對應的合法 OpenDRIVE 1.4/1.5 XML 組成,訓練約 1 個 epoch(300 步)。訓練完成後將 LoRA adapter merge 回 base model 並以 bfloat16 儲存。

LoRA rank 128
LoRA alpha 128
LoRA dropout 0.0
目標模組 q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
訓練步數 300 步(約 1 epoch)
最高學習率 2e-4
最終訓練 loss ~0.54

使用方式

System Prompt

You are an OpenDRIVE road network generator that accepts descriptions in English or Traditional Chinese (繁體中文). Output valid OpenDRIVE XML (.xodr) following the 1.4/1.5 specification, with proper header, roads with planView geometry, lane sections, and junction definitions where needed.

你是一個 OpenDRIVE 路網生成器,可接受英文或繁體中文描述。請輸出符合 OpenDRIVE 1.4/1.5 規範的合法 .xodr XML,包含正確的 header、含 planView 幾何的 roads、車道區段,以及必要的 junction 定義。

Prompt 範例

英文:

Generate a small road cluster suitable for autonomous driving simulation.
The network should have roughly 4 roads with about 0 junctions.
Total road length should be around 320 m.
Roads should have one lane per direction.
Include sidewalks along the roads.
Road geometry should be mostly straight with minimal curves.

繁體中文:

請以 OpenDRIVE (.xodr) 格式生成一個路網,包含 1 條道路與 1 個路口,總長度 136 公尺。請輸出合法的 OpenDRIVE XML。

輸入格式

本模型使用 ChatML 格式,以 <|im_sep|> 作為角色分隔符:

<|im_start|>system<|im_sep|>
{system prompt}<|im_end|>
<|im_start|>user<|im_sep|>
{路網描述}<|im_end|>
<|im_start|>assistant<|im_sep|>

使用 transformers

import transformers

pipeline = transformers.pipeline(
    "text-generation",
    model="./Heliars-Carla-X1",
    model_kwargs={"torch_dtype": "auto"},
    device_map="auto",
)

SYSTEM_PROMPT = (
    "You are an OpenDRIVE road network generator that accepts descriptions in English or "
    "Traditional Chinese (繁體中文). Output valid OpenDRIVE XML (.xodr) following the 1.4/1.5 "
    "specification, with proper header, roads with planView geometry, lane sections, and "
    "junction definitions where needed.\n\n"
    "你是一個 OpenDRIVE 路網生成器,可接受英文或繁體中文描述。請輸出符合 OpenDRIVE 1.4/1.5 規範的合法 "
    ".xodr XML,包含正確的 header、含 planView 幾何的 roads、車道區段,以及必要的 junction 定義。"
)

messages = [
    {"role": "system", "content": SYSTEM_PROMPT},
    {"role": "user", "content": "請生成一個住宅區路網,4 條道路、無路口,總長約 320 公尺,每方向一車道,含人行道。"},
]

outputs = pipeline(messages, max_new_tokens=4096)
print(outputs[0]["generated_text"][-1]["content"])

OpenAI-compatible API 呼叫:

from openai import OpenAI

client = OpenAI(base_url="http://localhost:8000/v1", api_key="dummy")

response = client.chat.completions.create(
    model="Heliars-Carla-X1",
    messages=[
        {"role": "system", "content": SYSTEM_PROMPT},
        {"role": "user", "content": "請生成一個包含 3 條道路、1 個路口的路網,總長度約 250 公尺。"},
    ],
    max_tokens=4096,
    temperature=0.1,
)
print(response.choices[0].message.content)

負責任 AI 使用注意事項

  • 輸出驗證:請務必在載入 CARLA 或其他模擬器前,以 OpenDRIVE validator 驗證生成的 .xodr 檔案。
  • 模擬用途:本模型僅供模擬與研究使用,不得應用於真實世界安全關鍵場景。
  • 幾何正確性:模型可能生成語法合法但幾何或拓撲不一致的路網,複雜路網建議人工審查。
  • 語言支援:目前支援英文與繁體中文,其他語言輸出品質不保證。

相關連結

Downloads last month
17
Safetensors
Model size
15B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for NCUT-AI/Heliars-Phi4-Carla-X1-14B

Base model

microsoft/phi-4
Finetuned
(350)
this model
Adapters
2 models

Collection including NCUT-AI/Heliars-Phi4-Carla-X1-14B

Paper for NCUT-AI/Heliars-Phi4-Carla-X1-14B