---
title: TextoonPromptParsing
canonical_url: "https://www.modelscope.cn/models/hechaohc/TextoonPromptParsing"
md_url: "https://www.modelscope.cn/models/hechaohc/TextoonPromptParsing.md"
repository: hechaohc/TextoonPromptParsing
last_updated: 2025-04-27
pipeline_tag: feature-extraction
tasks:
  - feature-extraction
parameters: 1.5B
tensor_type:
  - BF16
library_name:
  - safetensors
downloads: 493
stars: 2
---

# TextoonPromptParsing

> TextoonPromptParsing - hechaohc 在 ModelScope 开源的模型。微调Qwen2.5-1.5B-Instruct，从输入prompt中解析Textoon需要的特定属性

- **Repository**: hechaohc/TextoonPromptParsing
- **Tasks**: feature-extraction
- **Parameters**: 1.5B
- **Downloads**: 493
- **Stars**: 2
- **Last updated**: 2025-04-27

Source: https://www.modelscope.cn/models/hechaohc/TextoonPromptParsing

---

## 模型介绍
基于Qwen2.5-1.5B-Instruct微调，对于人物形象的描述文本进行解析，得到如头发、服饰类型等属性。

## 模型训练
根据已有的头发、服饰类别进行随机组合生成10W条训练数据，将其写为sharegpt格式，使用LLaMA-Factory训练框架，对Qwen2.5-1.5B-Instruct微调，最后合并模型权重。

## 模型推理
```
from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "checkpoints/qwen2_5-1_5b-20250224-merged"

model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype="auto",
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)

prompt = "她将长发扎成两条俏皮的双马尾，中发修剪得干净利落，长刘海微微遮住额头，露出一双灵动的蓝色眼睛。她穿着一件圆领的浅紫色短袖上衣，袖口处有荷叶边设计，下身搭配一条高腰的白色短裤，脚上穿着一双白色运动鞋，整体造型充满青春气息."

messages = [
    {"role": "system", "content": "You are a helpful assistant."},    
    {"role": "user", "content": prompt}
]
text = self.tokenizer.apply_chat_template(
    messages,    
    tokenize=False,    
    add_generation_prompt=True
)
model_inputs = self.tokenizer([text], return_tensors="pt").to(self.model.device)

generated_ids = self.model.generate(
    **model_inputs,    
    max_new_tokens=512
)
generated_ids = [
    output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]

response = self.tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
```
## 模型效果
输入："她将长发扎成两条俏皮的双马尾，中发修剪得干净利落，长刘海微微遮住额头，露出一双灵动的蓝色眼睛。她穿着一件圆领的浅紫色短袖上衣，袖口处有荷叶边设计，下身搭配一条高腰的白色短裤，脚上穿着一双白色运动鞋，整体造型充满青春气息。"
输出：{'gender': 'female', 'bang type': 'long', 'hair length': 'double ponytail', 'hair color': 'blue', 'cloth color': 'purple', 'pant color': 'white', 'shoe color': 'white', 'clothes type': 'crew neck', 'sleeve type': 'short sleeve', 'pants type': 'mini shorts', 'shoe type': 'flat shoes', 'describe a person': 'yes'}
