Downloads · 30 days
27
8% of all-time downloads
ProfessorLeVesseur/bert-base-cased-timeframe-classifier
bert-base-cased-timeframe-classifier is a text classification model from ProfessorLeVesseur. Use it when you need a label for a piece of text. The card lists the license as apache-2.0.
This model is a text classification model trained to predict the tense of English sentences: Past, Present, or Future. It is based on the bert-base-uncased architecture.
Downloads · 30 days
27
8% of all-time downloads
All-time downloads
350
Public
Parameters
108M
433 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors433 MB · 100%
From the Hugging Face model README
This model is a text classification model trained to predict the tense of English sentences: Past, Present, or Future. It is based on the bert-base-uncased architecture.
This model can be used in applications such as:
| Sentence | Label |
|---|---|
| the fishermen had caught a variety of fish including bass and perch | Past |
| medical professionals are researching the impact of social determinants on health | Present |
| in the future robotic surgical systems will have been empowering surgeons to perform increasingly complex procedures | Future |
The model was fine-tuned on the ProfessorLeVesseur/EnglishTense dataset, which provides a diverse set of sentences labeled with their respective tenses. The training involved optimizing the model's weights for three epochs using a learning rate of 5e-5.
The model achieves a perfect accuracy of 1.00 on the test set, with precision, recall, and F1-scores also at 1.00 for all classes. These results indicate excellent performance in classifying sentence tenses.
| Class | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| Future | 1.00 | 1.00 | 1.00 | 727 |
| Past | 1.00 | 1.00 | 1.00 | 577 |
| Present | 1.00 | 1.00 | 1.00 | 694 |
| Accuracy | 1.00 | 1998 | ||
| Macro Avg | 1.00 | 1.00 | 1.00 | 1998 |
| Weighted Avg | 1.00 | 1.00 | 1.00 | 1998 |
While the model performs well on the provided dataset, it may not generalize to all types of English text, particularly those with ambiguous or complex sentence structures.
This model can be used for text classification tasks, either for individual text inputs or for batch processing via a DataFrame. Below are examples of both use cases.
To classify a single piece of text and retrieve the predicted label along with the confidence score, you can use the following code:
from transformers import pipeline # Import the pipeline function from the transformers library
# Initialize a text classification pipeline using the specified model
classifier = pipeline(
"text-classification", # Specify the task type as text classification
model="ProfessorLeVesseur/bert-base-cased-timeframe-classifier" # Specify the model to use from the Hugging Face Model Hub
)
result = classifier("MTSS.ai is the future of education, call it education².") # Classify the input text and store the result
print(result) # Output the result
For batch processing, you can classify multiple text entries stored in a DataFrame. This example demonstrates how to read a CSV file and add a new column with the predicted labels:
# Import libraries
from transformers import pipeline # Import the pipeline function from the transformers library
import pandas as pd # Import pandas for data manipulation
# Read the CSV file
file_path = 'filename.csv' # Define the path to the CSV file
df = pd.read_csv(file_path) # Read the CSV file into a DataFrame
# Initialize the text classification pipeline
classifier = pipeline(
"text-classification", # Specify the task type as text classification
model="ProfessorLeVesseur/bert-base-cased-timeframe-classifier" # Specify the model to use from the Hugging Face Model Hub
)
# Apply the classifier to each row in the "Text" column and store results in a new column "label"
df['label'] = df['Text'].apply(lambda text: classifier(text)[0]['label']) # Classify each text and store the label
# Display the DataFrame with the new "label" column
df.head(5) # Display the first 5 rows of the DataFrame