|
--- |
|
license: apache-2.0 |
|
base_model: facebook/bart-large |
|
tags: |
|
- generated_from_trainer |
|
model-index: |
|
- name: multichoice-question-generator |
|
results: [] |
|
--- |
|
|
|
|
|
|
|
# multichoice-question-generator |
|
|
|
This model is a fine-tuned version of [facebook/bart-large](https://huggingface.co/facebook/bart-large) on an unknown dataset. |
|
It achieves the following results on the evaluation set: |
|
- Loss: 0.1787 |
|
|
|
## Model description |
|
|
|
More information needed |
|
|
|
## Intended uses & limitations |
|
This is an early version of a model meant to generate multichoice questions from text |
|
To load the model: |
|
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM |
|
|
|
tokenizer = AutoTokenizer.from_pretrained("Gachomba/multichoice-question-generator") |
|
model = AutoModelForSeq2SeqLM.from_pretrained("Gachomba/multichoice-question-generator") |
|
# tokenize input text |
|
import torch |
|
device = "cuda" if torch.cuda.is_available() else "cpu" |
|
|
|
def tokenize_input(input_text): |
|
inputs = tokenizer(input_text, return_tensors="pt", truncation=True, padding='max_length', max_length=1024) |
|
return inputs.input_ids.to(device), inputs.attention_mask.to(device) |
|
|
|
# generate output from the model |
|
def generate_output(input_text): |
|
input_ids, attention_mask = tokenize_input(input_text) |
|
outputs = model.generate(input_ids=input_ids, attention_mask=attention_mask, max_length=512) |
|
return tokenizer.decode(outputs[0], skip_special_tokens=True) |
|
|
|
# get user input and generate a response |
|
def get_response(): |
|
user_input = input("Enter your text: ") |
|
response = generate_output(user_input) |
|
print("Generated Output:", response) |
|
|
|
get_response() |
|
|
|
|
|
|
|
## Training and evaluation data |
|
|
|
More information needed |
|
|
|
## Training procedure |
|
|
|
### Training hyperparameters |
|
|
|
The following hyperparameters were used during training: |
|
- learning_rate: 2e-05 |
|
- train_batch_size: 8 |
|
- eval_batch_size: 8 |
|
- seed: 42 |
|
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08 |
|
- lr_scheduler_type: linear |
|
- num_epochs: 3 |
|
|
|
### Training results |
|
|
|
| Training Loss | Epoch | Step | Validation Loss | |
|
|:-------------:|:-----:|:----:|:---------------:| |
|
| 0.2218 | 1.0 | 1000 | 0.1910 | |
|
| 0.1913 | 2.0 | 2000 | 0.1811 | |
|
| 0.1727 | 3.0 | 3000 | 0.1787 | |
|
|
|
|
|
### Framework versions |
|
|
|
- Transformers 4.42.4 |
|
- Pytorch 2.3.1+cu121 |
|
- Tokenizers 0.19.1 |
|
|