PyThaiNLP/prachathai67k
Updated • 137 • 4
How to use tonkaew131/nlp-prachathai67k-text-classification with PEFT:
from peft import PeftModel
from transformers import AutoModelForSequenceClassification
base_model = AutoModelForSequenceClassification.from_pretrained("meta-llama/Llama-3.2-1B")
model = PeftModel.from_pretrained(base_model, "tonkaew131/nlp-prachathai67k-text-classification")This model is a fine-tuned version of meta-llama/Llama-3.2-1B on the prachathai67k dataset. It achieves the following results on the evaluation set:
id2label = {
0: 'politics',
1: 'human_rights',
2: 'quality_of_life',
3: 'international',
4: 'social',
5: 'environment',
6: 'economics',
7: 'culture',
8: 'labor',
9: 'national_security',
10: 'ict',
11: 'education'
}
label2id = {
'politics': 0,
'human_rights': 1,
'quality_of_life': 2,
'international': 3,
'social': 4,
'environment': 5,
'economics': 6,
'culture': 7,
'labor': 8,
'national_security': 9,
'ict': 10,
'education': 11
}
from peft import PeftModel, PeftConfig
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
model_id = "tonkaew131/nlp-prachathai67k-text-classification"
config = PeftConfig.from_pretrained(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(
config.base_model_name_or_path,
problem_type="multi_label_classification",
num_labels=12,
id2label=id2label,
label2id=label2id
)
model.resize_token_embeddings(len(tokenizer))
lora_model = PeftModel.from_pretrained(model, model_id)
classifier = pipeline(
"text-classification",
model=lora_model,
tokenizer=tokenizer,
top_k=None
)
text = "<news-content>"
results = classifier(text)
print(results)
More information needed
More information needed
More information needed
The following hyperparameters were used during training:
| Training Loss | Epoch | Step | Validation Loss | Accuracy | F1 | Precision | Recall |
|---|---|---|---|---|---|---|---|
| 0.1687 | 0.9998 | 4531 | 0.1698 | 0.9302 | 0.7251 | 0.7787 | 0.6784 |
| 0.1513 | 1.9997 | 9062 | 0.1609 | 0.9349 | 0.7418 | 0.8033 | 0.6890 |
Base model
meta-llama/Llama-3.2-1B