Downloads · 30 days
9
38% of all-time downloads
juanfra218/t5_small_cs_bot
t5_small_cs_bot is a machine learning model from juanfra218. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as mit.
A fine-tuned version of the Google T5 model, trained for the task of providing basic customer support.
Downloads · 30 days
9
38% of all-time downloads
All-time downloads
24
Public
Parameters
60.5M
243 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors242 MB · 99%
From the Hugging Face model README
A fine-tuned version of the Google T5 model, trained for the task of providing basic customer support.
training_args = TrainingArguments(
output_dir="./results",
num_train_epochs=3,
per_device_train_batch_size=16,
per_device_eval_batch_size=16,
warmup_steps=500,
weight_decay=0.01,
logging_dir="./logs",
logging_steps=100,
evaluation_strategy="steps",
eval_steps=500,
save_strategy="steps",
save_steps=500,
load_best_model_at_end=True,
metric_for_best_model="eval_loss",
greater_is_better=False,
learning_rate=3e-4,
fp16=True,
gradient_accumulation_steps=2,
push_to_hub=False,
)
import time
import torch
from transformers import T5Tokenizer, T5ForConditionalGeneration
# Load the tokenizer and model
model_path = 'juanfra218/t5_small_cs_bot'
tokenizer = T5Tokenizer.from_pretrained(model_path)
model = T5ForConditionalGeneration.from_pretrained(model_path)
def generate_answers(prompt):
inputs = tokenizer(prompt, return_tensors="pt", max_length=512, truncation=True, padding="max_length")
inputs = {key: value.to(device) for key, value in inputs.items()}
max_output_length = 1024
start_time = time.time()
with torch.no_grad():
outputs = model.generate(**inputs, max_length=max_output_length)
end_time = time.time()
generation_time = end_time - start_time
answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
return answer, generation_time
# Interactive loop
print("Enter 'quit' to exit.")
while True:
prompt = input("You: ")
if prompt.lower() == 'quit':
break
answer, generation_time = generate_answers(prompt)
print(f"Customer Support Bot: {answer}")
print(f"Time taken: {generation_time:.4f} seconds\n")
optimizer.pt: State of the optimizer.training_args.bin: Training arguments and hyperparameters.tokenizer.json: Tokenizer vocabulary and settings.spiece.model: SentencePiece model file.special_tokens_map.json: Special tokens mapping.tokenizer_config.json: Tokenizer configuration settings.model.safetensors: Trained model weights.generation_config.json: Configuration for text generation.config.json: Model architecture configuration.csbot_test_predictions.csv: Predictions on the test set, includes: prompt, true_answer, predicted_answer_text, generation_time, bleu_score