Downloads · 30 days
0
Zqbot1/TransportGPT
TransportGPT is a machine learning model from Zqbot1. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Anastasia Goh, Alden Sio, Dylan Lo, Li Shuyao, Xu Ziqi, Zhu Yi Cheng
Downloads · 30 days
0
Access
Public
Updated Mar 21, 2024
Repo size
5.6 GB
Likes
0
Public
Click a slice to open those files.
.zip2.6 GB · 46%
From the Hugging Face model README
Anastasia Goh, Alden Sio, Dylan Lo, Li Shuyao, Xu Ziqi, Zhu Yi Cheng
As an external user, leveraging the fine-tuned model for your applications is straightforward. Follow the steps below to integrate and utilize the model effectively:
Ensure you have Python and the necessary libraries installed. You will need all the libraries within the requirements.txt file, which can be installed via pip:
pip install requirements.txt
Ensure you download the Checkpoint (updated model) into any portion within your drive. Save the file path.
You can load the fine-tuned model directly using the Transformers library. Replace your_model_path with the actual path where the fine-tuned model is hosted:
from transformers import T5ForConditionalGeneration, T5Tokenizer
model_path = "your_model_path" # Replace this with the path to the fine-tuned model
model = T5ForConditionalGeneration.from_pretrained(model_path)
tokenizer = T5Tokenizer.from_pretrained(model_path)
Prepare the text you want to analyze or process. Ensure it's in a format compatible with the model's expectations:
text_to_process = "Your input text here"
inputs = tokenizer(text_to_process, return_tensors="pt")
With the model and inputs ready, you can now generate predictions:
outputs = model.generate(**inputs)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(result)
The output will be your model's interpretation or response based on its fine-tuning. Analyze the results as needed for your application.
This is our guide on how we fine-tuned the "google/flan-t5-base" model for emergency incident reporting. Below is a generic sequence of events that outlines our fine-tuning process:
Firstly, we begin by installing and importing necessary libraries and models. For this project, we utilized "google/flan-t5-base" from HuggingFace.
We then instantiate the base Google FLAN model for further processing.
The dataset is loaded and preprocessed through tokenization. We specifically allow contextual words like "no", "don't", etc., to handle prompts such as "no one is injured" or "don't need to send ambulance".
Our dataset is further tokenized into a dictionary format, which is a requirement for this model. For our case, keys such as 'input_ids', 'attention_mask', 'labels' are essential for training.
We add a system prompt, "extract structured details:", and attach labels to the respective columns. This data is then split into training and testing samples.
Text data is converted into embeddings to be processed by the model.
Next, we decide on global parameters for training, which mostly depend on computational power. Here are some key parameters:
With the parameters set, we proceed to train the model using .train() method.
After training, we obtain the desired checkpoint (the one with the least loss) and store it. This model can then be loaded using:
last_checkpoint = "./results/checkpoint-500"
finetuned_model = T5ForConditionalGeneration.from_pretrained(last_checkpoint)
tokenizer = T5Tokenizer.from_pretrained(last_checkpoint)
Finally, we test the fine-tuned model with prompts to evaluate its performance. For example:
incident_report = "Hello police, there is an accident near me at Information Technology NUS, Street 2. A bus collided with a Taxi, 3 people are severely injured, there is a fire. Students are calling for help, Lamp post nearby: 88"
inputs = tokenizer(incident_report, return_tensors="pt")
outputs = finetuned_model.generate(**inputs, max_length=200, min_length=50, length_penalty=2.0, num_beams=4, early_stopping=True)
answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
Once we have obtained our extracted entities, we use these to prompt for specific instructions to be distributed to relevant authorities -- helping in effectively managing this given incident.