Coder Social home page Coder Social logo

illiterate / bertclassifier Goto Github PK

View Code? Open in Web Editor NEW
146.0 146.0 18.0 109 KB

基于PyTorch的BERT中文文本分类模型(BERT Chinese text classification model implemented by PyTorch)

License: MIT License

Python 100.00%
bert pytorch transformer transformers

bertclassifier's Introduction

Hi there 👋

🏠 Welcome to my page.

🏫 I graduated with a bachelor's and a master's degree from Shanxi University.

✨ My research interests are NLP, LLMs and AIGC.

bertclassifier's People

Contributors

illiterate 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bertclassifier's Issues

请教大佬

大佬可以写一个对代码的详细分析吗,小白有点看不懂。

CrossEntropyLoss内置log_softmax,不需要在模型输出层额外添加softmax

问题描述:

  • 训练模型时,loss下降非常缓慢
  • 数据量大且不同类别数量平衡时能收敛但容易过拟合
  • 数据量不大且存在数据不平衡时,模型预测明显偏向于数据量最多的类别

原因分析:

解决方案:

  • 移除model输出层的softmax
  • 若需要获取模型输出的概率值logits,在model输出的logits后接F.softmax()
import torch.nn.functional as F

output = model(
                input_ids=input_ids, 
                attention_mask=attention_mask, 
                token_type_ids=token_type_ids, 
            )

logits = F.softmax(output)

linux环境运行出错

RuntimeError: CUDA error: unspecified launch failure
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Compile with TORCH_USE_CUDA_DSA to enable device-side assertions.

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.