Update README.md
Browse files
README.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
license:
|
| 3 |
tags:
|
| 4 |
- generated_from_trainer
|
| 5 |
-
base_model:
|
| 6 |
model-index:
|
| 7 |
- name: yes_no_model_english
|
| 8 |
results: []
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
-----
|
| 11 |
label_map = {'True': 0, 'False': 1, 'Invalid input': 2}
|
|
@@ -25,13 +27,70 @@ More information needed
|
|
| 25 |
|
| 26 |
## Intended uses & limitations
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
More information needed
|
| 33 |
|
| 34 |
## Training procedure
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
### Training hyperparameters
|
| 37 |
|
|
@@ -66,4 +125,4 @@ The following hyperparameters were used during training:
|
|
| 66 |
- Transformers 4.41.2
|
| 67 |
- Pytorch 2.1.2
|
| 68 |
- Datasets 2.19.2
|
| 69 |
-
- Tokenizers 0.19.1
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
tags:
|
| 4 |
- generated_from_trainer
|
| 5 |
+
base_model: gpt3.5
|
| 6 |
model-index:
|
| 7 |
- name: yes_no_model_english
|
| 8 |
results: []
|
| 9 |
+
language:
|
| 10 |
+
- en
|
| 11 |
---
|
| 12 |
-----
|
| 13 |
label_map = {'True': 0, 'False': 1, 'Invalid input': 2}
|
|
|
|
| 27 |
|
| 28 |
## Intended uses & limitations
|
| 29 |
|
| 30 |
+
```from transformers import AutoModelForSequenceClassification, AutoTokenizer, Trainer, TrainingArguments
|
| 31 |
+
from transformers import GPT2Tokenizer, GPT2ForSequenceClassification, Trainer, TrainingArguments
|
| 32 |
+
|
| 33 |
+
# Replace 'your-username/your-model-name' with the actual model identifier
|
| 34 |
+
model_id = 'tuskbyte/yes_no_model_english'
|
| 35 |
+
label_map=["Yes","NO","Invalid Input"]
|
| 36 |
+
# label_map = {'True': 0, 'False': 1, 'Invalid input': 2}
|
| 37 |
+
|
| 38 |
+
# Load the model
|
| 39 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_id)
|
| 40 |
+
|
| 41 |
+
try:
|
| 42 |
+
# Try to load the tokenizer
|
| 43 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 44 |
+
except OSError:
|
| 45 |
+
# Fallback to a default tokenizer if loading fails
|
| 46 |
+
print(f"Tokenizer for '{model_id}' not found. Using gpt as fallback.")
|
| 47 |
+
tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
|
| 48 |
+
|
| 49 |
+
# Initialize Trainer with dummy arguments for inference
|
| 50 |
+
training_args = TrainingArguments(
|
| 51 |
+
output_dir='./results', # specify your output directory
|
| 52 |
+
per_device_eval_batch_size=1 # batch size for inference
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
trainer = Trainer(
|
| 56 |
+
model=model,
|
| 57 |
+
args=training_args,
|
| 58 |
+
tokenizer=tokenizer
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
# Example input
|
| 62 |
+
question = "Would you like to paticipate ?"
|
| 63 |
+
answer = "yes i would"
|
| 64 |
+
input_text = f"{question} {answer}"
|
| 65 |
+
|
| 66 |
+
# Tokenize the input
|
| 67 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
| 68 |
+
model.to('cuda')
|
| 69 |
+
inputs.to('cuda')
|
| 70 |
+
# Perform inference using the model
|
| 71 |
+
outputs = model(**inputs)
|
| 72 |
+
logits = outputs.logits
|
| 73 |
+
|
| 74 |
+
# Get the predicted label
|
| 75 |
+
predicted_class_id = logits.argmax().item()
|
| 76 |
+
print("predicted_class_id",predicted_class_id)
|
| 77 |
+
labels = model.config.id2label
|
| 78 |
+
print("labels",labels)
|
| 79 |
+
predicted_label = labels[predicted_class_id]
|
| 80 |
+
|
| 81 |
+
# Output the result
|
| 82 |
+
print(f"Predicted label: {predicted_label}")
|
| 83 |
+
print(f"Model predection is : {label_map[predicted_class_id]}")
|
| 84 |
+
```
|
| 85 |
+
```
|
| 86 |
+
support english only
|
| 87 |
+
```
|
| 88 |
|
|
|
|
| 89 |
|
| 90 |
## Training procedure
|
| 91 |
+
```
|
| 92 |
+
upcomming soon
|
| 93 |
+
```
|
| 94 |
|
| 95 |
### Training hyperparameters
|
| 96 |
|
|
|
|
| 125 |
- Transformers 4.41.2
|
| 126 |
- Pytorch 2.1.2
|
| 127 |
- Datasets 2.19.2
|
| 128 |
+
- Tokenizers 0.19.1
|