question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using a specific transformer encoder model for Text Classification Task

See original GitHub issue

Hi, I would like to use a specific transformer encoder model such as roberta-large instead of the default roberta, which loads a roberta-base. Is there any way to do so?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
justinxzhaocommented, May 31, 2022

Hi,

You can use auto_transformer, i.e.:

import pandas as pd
import yaml

from ludwig.api import LudwigModel

config = """
input_features:
    - name: text
      type: text
      encoder: auto_transformer
      pretrained_model_name_or_path: 'roberta-large'
output_features:
    - name: category
      type: category
trainer:
    epochs: 1
"""
model = LudwigModel(yaml.load(config), backend="local")

df = pd.DataFrame(
    {
        "text": ["Suomessa vaihtuu kesän aikana sekä pääministeri että valtiovarain"],
        "category": ["Suomi"],
    }
)
model.train(df)
model.predict(df)

Related discussion: https://github.com/ludwig-ai/ludwig/discussions/2057

Documentation: https://ludwig-ai.github.io/ludwig-docs/0.5/configuration/features/text_features/#autotransformer

0reactions
msakthiganeshcommented, Jun 8, 2022

Hi @justinxzhao ! I recently came across a similar machine learning framework - Lightwood .

On comparison with Ludwig, they both have functionalities to handle features of multiple input types, pre-process them based on their input type, encode the inputs, TRAIN THE MODEL USING THE ENCODED INPUT (emphasizing on the model), decode the outputs from the trained model into output features.

In Lightwood, the possible models that could be trained are provided here - https://lightwood.io/mixer.html

In similar fashion, are there a list of possible models that could be trained using Ludwig? And if yes, how do we specify our preferred model to train (using the concated output from the combiner)?

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transformers For Text Classification - Paperspace Blog
This new comprehensive guide will usher you through creating your own transformers nlp model for semantic analysis following two methodologies: from scratch ...
Read more >
A Hands-On Guide To Text Classification With Transformer ...
A step-by-step tutorial on using Transformer Models for Text Classification tasks. Learn how to load, fine-tune, and evaluate text ...
Read more >
Text classification with Transformer - Keras
Create classifier model using transformer layer. Transformer layer outputs one vector for each time step of our input sequence. Here, we take ...
Read more >
Text Classification with Transformers | by Ashwin N - Medium
Text classification is one of the most common tasks in NLP; it can be used for a broad range of applications, such as...
Read more >
Text classification - Hugging Face
Text classification is a common NLP task that assigns a label or class to text. ... from transformers import TFAutoModelForSequenceClassification >>> model ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found