YAML Metadata Warning: empty or missing yaml metadata in repo card (https://huggingface.co/docs/hub/model-cards#model-card-metadata)

history-phi4-lora-sft-v2

本模型 TAIDE-EDU/history-phi4-lora-sft-v2 專為 高中小論文批改 設計。
輸入論文本體(含 --- Page N --- 分頁標記),模型會輸出 單一 JSON 物件,包含:

  • annotation:逐頁具體評論(優點、缺點、修正建議)
  • overall:綜合總評(附整體等第)

使用方式

import transformers

# 論文本體(需自行放入)
paper_text = """
--- Page 1 ---
這裡是論文的第一頁內容...
--- Page 2 ---
這裡是論文的第二頁內容...
"""

MODEL_NAME = "TAIDE-EDU/history-phi4-lora-sft-v2"

# 輸出範例模板
template_example = {
    "annotation": [
        {
            "page": "<該評論所對應的頁碼(整數;無法定位填 0)>",
            "text": "<被評論的原文或段落標題>",
            "content": (
                "<詳細評論,務必包含:優點、缺點、具體修正建議;"
                "若為五個核心部分之一,請在末行加入「等第:優等/中等/待加強」。"
                "一般段落或細節評論則不要加入等第。>"
            )
        }
    ],
    "overall": "<以繁體中文撰寫的一段綜合總評,文末以(優等/中等/待加強)標註整體等第>"
}

# 2) 型別約束(必須符合)
schema_types = {
    "type": "object",
    "additionalProperties": False,
    "required": ["annotation", "overall"],
    "properties": {
        "annotation": {
            "type": "array",
            "items": {
                "type": "object",
                "additionalProperties": False,
                "required": ["page", "text", "content"],
                "properties": {
                    "page": {"type": "integer", "minimum": 0},
                    "text": {"type": "string"},
                    "content": {"type": "string"}
                }
            }
        },
        "overall": {"type": "string"}
    }
}

pipeline = transformers.pipeline(
    "text-generation",
    model=MODEL_NAME,
    model_kwargs={"torch_dtype": "auto"},
    device_map="auto",
)

messages = [
      {
        "role": "system",
        "content": (
            "你是一位使用繁體中文、嚴格但公正的高中小論文批改專家。"
            "只根據使用者提供的論文內容輸出,不得臆測或補寫原文不存在的資訊。"
            "回覆必須且只允許為『一個 JSON 物件』,不得包含任何多餘說明或 Markdown。"
            "本任務產出兩個鍵:annotation(批改清單)與 overall(綜合總評)。"
            "annotation 陣列中 page 必須為整數頁碼,應依據文中的 '--- Page N ---' 標記填入;無法定位時填 0。"
            "【關於 annotation.content 的要求】必須提供『具體可操作』的評語:包含優點、缺點,以及明確的修正建議,"
            "若為五個核心部分(題目、前言、文獻探討、研究方法、參考文獻)之一,請在開頭加入「等第:優等/中等/待加強」,其他一般評論不須給等第。"
            "在最後【綜合總評】中,各部份的重視程度大致可參考以下比例:題目10%, 前言30%, 文獻探討40%, 研究方法10%, 參考文獻10%。"
        )
      },
      {
        "role": "user",
        "content": (
            "【任務】根據下列『論文本體』,產出兩個欄位:annotation、overall。\n"
            "【輸出模板(非約束示例)】請仿照下列鍵名與語義,但不要輸出尖括號與說明文字:\n"
            f"{template_example}\n"
            "【型別約束(必須符合)】你的輸出在型別上必須符合以下 JSON Schema:\n"
            f"{schema_types}\n"
            "【注意事項】\n"
            "1) 僅輸出一個 JSON 物件;不得有額外說明或 Markdown。"
            "2) 必用繁體中文。"
            "3) 請使用文中的 '--- Page N ---' 分頁標記來判斷 annotation.page 的頁碼;若無法定位,填 0。"
            "4) 若資訊不足,對應欄位填空字串 \"\" 或空陣列 [],不得臆測補齊。\n"
            "【論文本體】\n"
            f"{paper_text}"
        )
    }
]

outputs = pipeline(
    messages, 
    max_new_tokens=2048, 
    temperature=0.2, 
    top_p=0.2, 
    repetition_penalty=1.1, 
    return_full_text=True
)
print(outputs[0]["generated_text"][-1])

輸出範例

{
  "annotation": [
    {
      "page": 1,
      "text": "壹、前言",
      "content": "前言:優等\n研究動機具有個人經驗與現實觀察的結合,真實且具說服力。"
    },
    {
      "page": 2,
      "text": "某段落",
      "content": "某段落評價內容。"
    }
  ],
  "overall": "整體而言,本文在研究動機的說明上尚可,但文獻探討不足,建議補充來源以增加完整性。整體等第判定為「中等」。"
}
Downloads last month
3
Safetensors
Model size
15B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for TAIDE-EDU/history-phi4-lora-sft-v2

Quantizations
1 model