Giter Site home page Giter Site logo

nlp-huggingface-tutorial's Introduction

NLP-HuggingFace-Tutorial

使用 Hugging Face 以及 PyTorch 做一些 NLP 任务的 tutorial

代码相对简洁易懂,适合新手入门

如有任何问题,可以在 issues 中提出,也可以在 CSDN/friedrichor 私信我。

PyTorch 环境配置 / 服务器

Windows: Windows 系统从零配置 Python 环境,安装CUDA、CUDNN、PyTorch 详细教程
Linux服务器: 远程服务器配置 Anaconda 并安装 PyTorch 详细教程
本地-服务器文件传输: 将本地项目/文件上传到远程服务器中详细教程(vscode,sftp)

对话生成

备注:对话生成的代码同样适用于文本生成、文本摘要等 text-to-text 任务。

文本分类

备注:情感分析、主题分类、意图识别等任务均属于文本分类。

更新中...

nlp-huggingface-tutorial's People

Contributors

friedrichor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nlp-huggingface-tutorial's Issues

[BUG] RuntimeError: Unexpected error from cudaGetDeviceCount()

(base) root@I12f01b1f1300b01732:/hy-tmp/code/NLP-HuggingFace-Tutorial/text_classification/T5# !53
python train.py --device='cuda'
/usr/local/miniconda3/lib/python3.8/site-packages/torch/cuda/init.py:88: UserWarning: CUDA initialization: Unexpected error from cudaGetDeviceCount(). Did you run some cuda functions before calling NumCudaDevices() that might have already set an error? Error 804: forward compatibility was attempted on non supported HW (Triggered internally at ../c10/cuda/CUDAFunctions.cpp:109.)
return torch._C._cuda_getDeviceCount() > 0
{'batch_size': 16,
'classes_map_dir': '/hy-tmp/code/NLP-HuggingFace-Tutorial/text_classification/T5/classes_map.json',
'data_dir': '/hy-tmp/code/NLP-HuggingFace-Tutorial/text_classification/T5/dataset',
'device': 'cuda',
'learning_rate': 0.0001,
'lr_warmup_steps': 0,
'num_train_epochs': 10,
'num_workers': 8,
'prefix_text': 'tweet_eval emotion sentence: ',
'pretrained_model_name_or_path': 't5-base',
'save_weights_path': '/hy-tmp/code/NLP-HuggingFace-Tutorial/text_classification/T5/weights',
'use_Adafactor': True,
'use_AdafactorSchedule': True,
'use_weighted_random_sampler': False,
'weight_decay': 0}
Traceback (most recent call last):
File "train.py", line 187, in
main(args)
File "train.py", line 93, in main
model.to(args.device)
File "/usr/local/miniconda3/lib/python3.8/site-packages/transformers/modeling_utils.py", line 1811, in to
return super().to(*args, **kwargs)
File "/usr/local/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 989, in to
return self._apply(convert)
File "/usr/local/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 641, in _apply
module._apply(fn)
File "/usr/local/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 664, in _apply
param_applied = fn(param)
File "/usr/local/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 987, in convert
return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)
File "/usr/local/miniconda3/lib/python3.8/site-packages/torch/cuda/init.py", line 229, in _lazy_init
torch._C._cuda_init()
RuntimeError: Unexpected error from cudaGetDeviceCount(). Did you run some cuda functions before calling NumCudaDevices() that might have already set an error? Error 804: forward compatibility was attempted on non supported HW

你好,在CPU上可以正常训练,在linux的GPU上有报错

输入长度

当我输入长文本的时候,error:Token indices sequence length is longer than the specified maximum sequence length for this model (2965 > 512)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.