Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: TypeError: 'type' object is not subscriptable #9775

Open
1 task done
BaolanChen opened this issue Jan 13, 2025 · 1 comment
Open
1 task done

[Bug]: TypeError: 'type' object is not subscriptable #9775

BaolanChen opened this issue Jan 13, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@BaolanChen
Copy link

软件环境

-paddle2onnx:              1.1.0
-paddlefsl:                1.1.0
-paddlenlp:                3.0.0b3
-paddlepaddle-gpu:         3.0.0rc0

重复问题

  • I have searched the existing issues

错误描述

在百度AI Studio环境中开发项目,开发环境: paddle dev gpu-cuda11.8-cudnn8

安装paddlenlp后,并import paddlenlp使用,这时出现报错,如下所示

>>> import paddlenlp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/aistudio/.local/lib/python3.8/site-packages/paddlenlp/__init__.py", line 46, in <module>
    from . import (
  File "/home/aistudio/.local/lib/python3.8/site-packages/paddlenlp/trl/__init__.py", line 21, in <module>
    from .sft_config import *
  File "/home/aistudio/.local/lib/python3.8/site-packages/paddlenlp/trl/sft_config.py", line 29, in <module>
    class SFTConfig(TrainingArguments):
  File "/home/aistudio/.local/lib/python3.8/site-packages/paddlenlp/trl/sft_config.py", line 62, in SFTConfig
    model_init_kwargs: Optional[dict[str, Any]] = None
TypeError: 'type' object is not subscriptable

稳定复现步骤 & 代码

  1. AI Studio开发环境: paddle dev gpu-cuda11.8-cudnn8

  2. 安装paddle命令:
    python -m pip install paddlepaddle-gpu==3.0.0rc0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/

  3. 安装paddlenlp命令:
    pip install --upgrade paddlenlp==3.0.0b3

  4. 使用paddlenlp后报错,如图所示:

ec9afcd8757f0a90139e393039081a9
@BaolanChen BaolanChen added the bug Something isn't working label Jan 13, 2025
@BaolanChen BaolanChen changed the title [Bug]: TypeError: 'type' object is not subscriptable [Question]: TypeError: 'type' object is not subscriptable Jan 13, 2025
@BaolanChen BaolanChen changed the title [Question]: TypeError: 'type' object is not subscriptable [Bug]: TypeError: 'type' object is not subscriptable Jan 13, 2025
@JunnYu
Copy link
Member

JunnYu commented Jan 24, 2025

你好,你这里可以临时解决一下,下面提供2种方法:

  1. 这个报错的py文件的开头,添加 from __future__ import annotations
    Image
  2. 可以参考下面的改法,从typing导入Dict
from typing import Any, Optional, Dict    
model_init_kwargs: Optional[Dict[str, Any]] = None 
dataset_kwargs: Optional[Dict[str, Any]] = None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants