第36节课-LLaMA-factory 微调医疗数据集,FastGPT 部署模型应用下 #719
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: HswOAuth/llm_course#719
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
老师,用以下命令
llamafactory-cli train script_yaml/train_lora/Chinese-medical-dialogue-data-IM_Qwen2_5_7B_Instruct_lora_sft.yaml 训练模型,我现在是无卡模式,报这个错,这个是无卡模式的问题嘛?
图2,script_yaml是我自己创建的,下在下来没有,这个是正常的嘛,其余操作都是根据文档的
你需要检查下你的数据集构建,配置到data_info.json中的信息,可能没有配对。
老师,dataset_info.json 如下所示,我在最上边 加入
"Chinese-medical-dialogue-data-IM": {
"file_name": "Chinese-medical-dialogue-data-IM.json",
"columns": {
"prompt": "instruction",
"query": "input",
"response": "output"
}
},
Chinese-medical-dialogue-data-IM.json 就在如下目录 ,这个文件就是csv_to_json.py 生成的,我看步骤是没有问题的,我现在也找不到哪块错了
因为报错是:JSONDecodeError: Extra data,表明 JSON 文件中包含了多余的数据或格式不正确,导致解析失败。
可以测试下面代码:
示例 JSON 文件内容(假设保存为 'test_data.json')
import json
sample_json = '''
{
"name": "Example",
"data": [1, 2, 3],
"valid": true
}
'''
错误 JSON 文件内容(包含多余数据)
invalid_json = '''
{
"name": "Invalid Example",
"data": [1, 2, 3]
}
{
"extra": "This will cause JSONDecodeError"
}
'''
将示例 JSON 保存到文件
with open("test_data.json", "w") as f:
f.write(sample_json)
将错误 JSON 保存到文件
with open("invalid_data.json", "w") as f:
f.write(invalid_json)
测试 json.load 的函数
def test_json_load(file_path):
try:
with open(file_path, "r") as f:
data = json.load(f)
print(f"Successfully loaded JSON from {file_path}:")
print(data)
except json.JSONDecodeError as e:
print(f"JSONDecodeError occurred while loading {file_path}: {e}")
except FileNotFoundError:
print(f"File {file_path} not found.")
except Exception as e:
print(f"An unexpected error occurred: {e}")
测试用例 1:加载正确的 JSON 文件
print("Test 1: Loading valid JSON file")
test_json_load("test_data.json")
测试用例 2:加载错误的 JSON 文件
print("\nTest 2: Loading invalid JSON file")
test_json_load("invalid_data.json")
测试用例 3:加载不存在的文件
print("\nTest 3: Loading non-existent file")
test_json_load("non_existent.json")
如果报错就说明生成的json格式不对,可以检查下csv_to_json.py、自己的步骤的问题。