Model Card for Model ID
LoRA fine-tune of Google-T5-base for generative question paraphrasing
Model Details
Model Description
Originally develped as a proof-of-concept mechanism for preventing the sharing of knowledge check questions and answers in e-learning, generating on-the-fly paraphrasing of knowledge check questions so no two learners would see the same thing and could not effectively share questions/answers with others. The model was set aside. Its effectiveness for the task was never fully evaluated, though certain shortcomings were apparent in some circusmtances.
Bias, Risks, and Limitations
Noted tendency to switch POV (ie, "How do you do ABC?"->"How do I do ABC?") and in the case of questions requiring a high degree of regime expertise, paraphrases tended not to vary significantly from original source.
Recommendations
Experimentation is the only recommended use. If an effective use case is discovered, please let us know!
How to Get Started with the Model
Use the code below to get started with the model.
import torch
from transformers import T5Tokenizer
from peft import PeftModel, PeftConfig
# Check for MPS availability (Apple Silicon)
device = torch.device("mps" if torch.backends.mps.is_available() else "cpu")
#CUDA
#device = torch.device("CUDA")
# Path to your saved model
model_path = "./question-paraphrase-T5"
tokenizer = T5Tokenizer.from_pretrained("t5-base")
config = PeftConfig.from_pretrained(model_path)
from transformers import AutoModelForSeq2SeqLM
model = AutoModelForSeq2SeqLM.from_pretrained(config.base_model_name_or_path)
model = PeftModel.from_pretrained(model, model_path)
model = model.to(device)
model.eval() # Set to evaluation mode
def generate_paraphrase(text):
"""Generate a paraphrase for the given text."""
input_text = f"paraphrase : {text}"
print(f"Input: {input_text}")
inputs = tokenizer(input_text, return_tensors="pt").to(device)
# Use keyword arguments for generate
with torch.no_grad():
outputs = model.generate(
input_ids=inputs.input_ids,
attention_mask=inputs.attention_mask,
max_length=128,
num_beams=4, # Use beam search for better quality
no_repeat_ngram_size=2, # Avoid repeating phrases
temperature=0.7 # Add some randomness for diversity
)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
return result
# Interactive mode
print("\nInteractive Mode: Enter questions to paraphrase (type 'exit' to quit)")
while True:
user_input = input("\nEnter text to paraphrase: ")
if user_input.lower() == 'exit':
break
paraphrase = generate_paraphrase(user_input)
print(f"Paraphrase: {paraphrase}")
Training Details
Training Data
Used GLUE/mrpc and GLUE/qqp (cards not appearing on HF.)
Training Procedure
Trained on Mac Studio M3 Ultra using metal shaders in torch.
- Training regime: ```
- save_strategy="epoch", learning_rate=1e-3, per_device_train_batch_size=16, per_device_eval_batch_size=16, num_train_epochs=3, weight_decay=0.01,` ``
Environmental Impact
- Hardware Type: Apple Silicon-M3 Ultra processor, 80 GPU 40NPU/GPU
- Hours used: 2
Framework versions
- PEFT 0.15.1
- Downloads last month
- 2
Model tree for maxhirez/question-paraphrase-t5
Base model
google-t5/t5-base