ludwig 在训练模型过程中捕获到异常:在获取对象的字符串表示时超过了最大递归深度,

zqry0prt  于 1个月前  发布在  其他
关注(0)|答案(1)|浏览(20)

描述bug

在模型预处理过程中捕获到异常:在获取对象的字符串表示时超过了最大递归深度。

重现步骤

重现问题的步骤:
从github上采样:

results = model.train(dataset=df)
print(results)

请提供代码、yaml配置文件和一个数据样本,以便完全重现问题。无法重现的问题将被忽略。

导入yaml

import yaml
config_str = """
model_type: llm
base_model: /mnt/d/AI/Models/llama-7b-hf
quantization:
 bits: 4
adapter:
 type: lora
prompt:
 template: |
 ### Instruction:
 {instruction}

Input:

{input}

Response:


input_features:

* name: prompt

 type: text
 preprocessing:
 max_sequence_length: 256
output_features:

* name: output

 type: text
 preprocessing:
 max_sequence_length: 256
trainer:
 type: finetune
 learning_rate: 0.0001
 batch_size: 1
 gradient_accumulation_steps: 16
 epochs: 3
 learning_rate_scheduler:
 warmup_fraction: 0.01
preprocessing:
 sample_ratio: 0.1
 """
config = yaml.safe_load(config_str)
y0u0uwnf

y0u0uwnf1#

@Bdl-1989 Odd error. Are you able to use the tokenizer for /mnt/d/AI/Models/llama-7b-hf on your outside of Ludwig?

from transformers import AutoTokenizer
import pandas as pd

tokenizer = AutoTokenizer.from_pretrained("/mnt/d/AI/Models/llama-7b-hf")

# Example DataFrame
df = pd.DataFrame({
    'text_column': [
        "Here is the first text to encode",
        "And here is the second one",
        # ... other texts
    ]
})

# Tokenize the text column
tokenized_column = df['text_column'].apply(lambda x: tokenizer.encode_plus(x, return_tensors='pt', truncation=True, padding='max_length', max_length=512))

相关问题