tuskbyte/yes_no_model_english
07
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 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 onlyTraining procedure
upcomming soonTraining 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
Framework versions
- Transformers 4.41.2
- Pytorch 2.1.2
- Datasets 2.19.2
- Tokenizers 0.19.1
