Repository navigation
Conversation
Fine-tunes Qwen3 (1.7B) with a sequence-classification head on Banking77 (77 intents) instead of trimming the LM head to single-token labels, so the same recipe scales to hundreds of classes and multi-token label names. Shows class_encode_column for string labels, tracks accuracy and macro F1, and prints top-k predictions. Closes unslothai#192
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #192
#192 asks for a classification notebook that works with many classes (the reporter has about 400). The text classification notebook linked in the README trims the LM head down to single tokens like
"0"to"9", which breaks once labels need more than one token.This adds Qwen3 (1.7B) Classification, which uses a sequence-classification head instead:
FastLanguageModel.from_pretrained(..., num_labels, id2label, label2id), one output per class, trained with cross-entropy. Label names never go through the tokenizer, so the same code works for 77 or 400+ classes.What the notebook covers
class_encode_column, for string labels like the reporter's.get_peft_model. Unsloth detects the classification model and trains the newscorehead too.Results (free Colab T4, full Run all)
Files
original_template/Qwen3_(1.7B)-Classification.ipynb, plus the Colab, Kaggle and AMD notebooks and thepython_scripts/andfsdp2_scripts/copies generated byupdate_all_notebooks.pyWhen I ran
update_all_notebooks.pylocally, the Hugging Face metadata lookup failed for every model, which reordered most README tables and touched unrelated notebooks. I kept only the files for this notebook and its README rows.