CoolFace
Modelpublic

tuskbyte/yes_no_model_english

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes7downloads
Model Card

label_map = {'True': 0, 'False': 1, 'Invalid input': 2} ------ <!-- This model card has been generated automatically according to the information the Trainer had access to. You should probably proofread and complete it, then remove this comment. -->

yesnomodel_english

This model is a fine-tuned version of gpt2 on an unknown dataset. It achieves the following results on the evaluation set:

  • —Loss: 0.0002

Model description

More information needed

Intended uses & limitations

from transformers import AutoModelForSequenceClassification, AutoTokenizer, Trainer, TrainingArguments
from transformers import GPT2Tokenizer, GPT2ForSequenceClassification, Trainer, TrainingArguments

# Replace 'your-username/your-model-name' with the actual model identifier
model_id = 'tuskbyte/yes_no_model_english'
label_map=["Yes","NO","Invalid Input"]
# label_map = {'True': 0, 'False': 1, 'Invalid input': 2}

# Load the model
model = AutoModelForSequenceClassification.from_pretrained(model_id)

try:
    # Try to load the tokenizer
    tokenizer = AutoTokenizer.from_pretrained(model_id)
except OSError:
    # Fallback to a default tokenizer if loading fails
    print(f"Tokenizer for '{model_id}' not found. Using  gpt as fallback.")
    tokenizer = GPT2Tokenizer.from_pretrained('gpt2')

# Initialize Trainer with dummy arguments for inference
training_args = TrainingArguments(
    output_dir='./results',  # specify your output directory
    per_device_eval_batch_size=1  # batch size for inference
)

trainer = Trainer(
    model=model,
    args=training_args,
    tokenizer=tokenizer
)

# Example input
question = "Would you like to paticipate ?"
answer = "yes i would"
input_text = f"{question} {answer}"

# Tokenize the input
inputs = tokenizer(input_text, return_tensors="pt")
model.to('cuda')
inputs.to('cuda')
# Perform inference using the model
outputs = model(**inputs)
logits = outputs.logits

# Get the predicted label
predicted_class_id = logits.argmax().item()
print("predicted_class_id",predicted_class_id)
labels = model.config.id2label
print("labels",labels)
predicted_label = labels[predicted_class_id]

# Output the result
print(f"Predicted label: {predicted_label}")
print(f"Model predection is : {label_map[predicted_class_id]}")
support english only

Training procedure

upcomming soon

Training hyperparameters

The following hyperparameters were used during training:

  • —learning_rate: 5e-05
  • —trainbatchsize: 10
  • —evalbatchsize: 10
  • —seed: 42
  • —optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
  • —lrschedulertype: linear
  • —lrschedulerwarmup_steps: 50
  • —num_epochs: 3

Training results

Training LossEpochStepValidation Loss
1.20720.2857101.0470
1.09090.5714200.7972
0.87010.8571300.5695
0.55251.1429400.2802
0.21311.4286500.0569
0.04541.7143600.0093
0.01442.0700.0012
0.00162.2857800.0003
0.00062.5714900.0002
0.00062.85711000.0002

Framework versions

  • —Transformers 4.41.2
  • —Pytorch 2.1.2
  • —Datasets 2.19.2
  • —Tokenizers 0.19.1