初始化项目,由ModelHub XC社区提供模型

Model: XuehangCang/EasyPL-1B
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-07-21 22:28:29 +08:00
commit 81e7754a4b
9 changed files with 654837 additions and 0 deletions

186
README.md Normal file
View File

@@ -0,0 +1,186 @@
---
license: mit
datasets:
- XuehangCang/e_style_code
language:
- zh
base_model:
- openbmb/MiniCPM5-1B
base_model_relation: finetune
pipeline_tag: text-generation
library_name: transformers
tags:
- text-generation
- code
- chinese
- easypl
- minicpm
- lora
- sft
---
# EasyPL-1B
EasyPL-1B 是一个面向 EasyPL易语言 Easy Programming Language编程场景的中文代码助手模型
模型目标是根据中文需求生成清晰、简洁、可运行的代码,同时提供必要的中文解释,适合教学示例、语法演示和轻量级编程辅助
## Model Details
| 项目 | 内容 |
| --- | --- |
| Model name | EasyPL-1B |
| Base model | `openbmb/MiniCPM5-1B` |
| Dataset | `XuehangCang/e_style_code` |
| Language | Chinese |
| Training method | SFT + LoRA |
| Task | Text generation / Code generation |
| License | MIT |
## Intended Use
EasyPL-1B 主要适用于:
- 根据中文需求生成示例代码
- 解释代码片段的执行逻辑
- 生成函数、字符串处理、循环、条件判断等基础编程示例
- 将结构化题目、自然语言描述整理为代码或中文说明
该模型更偏向编程教学与示例生成,不建议作为通用问答模型或复杂工程自动化模型使用
## Coding Style Skill
EasyPL-1B 配套提供 [易语言风格 Python 编码规范 SKILL.md](./易语言风格%20Python%20编码规范%20SKILL.md),用于说明模型推荐遵循的中文化 Python 编码风格。
该规范覆盖中文函数名和变量名、模块组织、函数设计、中文注释、异常处理、PEP8 格式约束、常用代码模板与质量检查清单。需要了解 EasyPL 风格代码的命名规则、生成边界和示例模板时,可以点击上方链接查看详情文件。
## How to Use
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "XuehangCang/EasyPL-1B"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype="auto",
device_map="auto",
trust_remote_code=True,
)
messages = [
{"role": "user", "content": "生成随机UUID"},
]
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
enable_thinking=False,
return_tensors="pt",
)
inputs = {key: value.to(model.device) for key, value in inputs.items()}
outputs = model.generate(**inputs, max_new_tokens=2048)
prompt_len = inputs["input_ids"].shape[-1]
print(tokenizer.decode(outputs[0][prompt_len:], skip_special_tokens=True))
```
如果使用的 `transformers` 或 tokenizer 版本不支持 `enable_thinking` 参数,可以移除该参数后再运行
## Example Outputs
以下示例均使用模型实际调用生成
### 生成随机UUID
```python
import uuid
def 生成随机UUID():
"""生成随机UUID"""
return str(uuid.uuid4())
# 测试
print(生成随机UUID())
```
### 判断一个数字是否为偶数,并输出结果
```python
def 取模( 数字, 基数):
"""取模函数,返回 数字 % 基数 结果"""
return 数字 % 基数
def 取余( 数字, 基数):
"""取余函数,返回 数字 % 基数 结果"""
return 取模( 数字, 基数)
def 判断偶数( 数字):
"""判断数字是否为偶数"""
return 取余( 数字, 2) == 0
def 判断奇数( 数字):
"""判断数字是否为奇数"""
return 取余( 数字, 2) != 0
# 测试
if __name__ == '__main__':
结果1 = 判断偶数(64)
print(f"64 是偶数:{结果1}")
结果2 = 判断奇数(64)
print(f"64 是奇数:{结果2}")
结果3 = 判断偶数(7)
print(f"7 是偶数:{结果3}")
结果4 = 判断奇数(10)
print(f"10 是奇数:{结果4}")
结果5 = 判断偶数(3)
print(f"3 是偶数:{结果5}")
```
### 计算字符串的MD5值
```python
import hashlib
def 计算MD5(数据文本):
"""
计算字符串的MD5值
参数:
数据文本: 需要计算MD5的字符串
返回:
MD5值字符串
"""
md5 = hashlib.md5()
md5.update(数据文本.encode('utf-8'))
return md5.hexdigest()
```
这些输出体现了模型对易语言风格的适配:短中文需求进入,返回带中文函数名、中文注释、测试代码或简要说明的代码片段
## Limitations
- EasyPL-1B 是针对中文编程场景微调的模型,通用知识问答能力不是主要优化目标
- 生成代码仍可能出现语法或逻辑错误,建议在实际使用前进行人工检查和运行验证
- 模型能力受训练数据质量、训练样本规模、训练轮数和基座模型能力影响
## Citation
如果你使用了本模型,请同时关注并引用相关基座模型与数据集:
- Base model: `openbmb/MiniCPM5-1B`
- Dataset: `XuehangCang/e_style_code`
## License
This model card is released under the MIT License.