Downloads · 30 days
0
wilzeelbub/testo
testo is a machine learning model from wilzeelbub. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Downloads · 30 days
0
Access
Public
Updated Apr 2, 2025
Repo size
—
Likes
1
Public
Click a slice to open those files.
.md1.6 KB · 51%
From the Hugging Face model README
from datasets import load_dataset
dataset = load_dataset("imdb") # Example with IMDB dataset from transformers import BertTokenizer, BertForSequenceClassification, Trainer, TrainingArguments
model_name = "bert-base-uncased" tokenizer = BertTokenizer.from_pretrained(model_name) model = BertForSequenceClassification.from_pretrained(model_name)
def tokenize_function(examples): return tokenizer(examples['text'], padding="max_length", truncation=True)
tokenized_datasets = dataset.map(tokenize_function, batched=True)
training_args = TrainingArguments( output_dir="./results", evaluation_strategy="epoch", learning_rate=2e-5, per_device_train_batch_size=16, num_train_epochs=3, )
trainer = Trainer( model=model, args=training_args, train_dataset=tokenized_datasets["train"], eval_dataset=tokenized_datasets["test"], )
trainer.train() model.save_pretrained("./my_model") tokenizer.save_pretrained("./my_model")
from huggingface_hub import HfApi, HfFolder
HfFolder.save_token("YOUR_HUGGINGFACE_TOKEN")
api = HfApi() api.upload_folder( folder_path="./my_model", path_in_repo="my_model", repo_id="your_username/my_model", repo_type="model", ) from transformers import pipeline
classifier = pipeline("text-classification", model="your_username/my_model") result = classifier("This is an example sentence.") print(result)