Downloads · 30 days
0
shaheerawan3/Vibescribe
Vibescribe is a machine learning model from shaheerawan3. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
Vibescribe built with Hugging Face Transformers, fine-tuned on IMDB reviews.
Downloads · 30 days
0
Access
Public
Updated Dec 25, 2024
Repo size
—
Likes
0
Public
Click a slice to open those files.
.py4.6 KB · 52%
From the Hugging Face model README
Vibescribe built with Hugging Face Transformers, fine-tuned on IMDB reviews.
git clone https://github.com/your-username/sentiment-analysis
cd sentiment-analysis
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
huggingface-cli login
sentiment-analysis/
├── requirements.txt
├── train.py
├── inference.py
├── utils.py
└── README.md
transformers==4.37.2
datasets==2.16.1
torch==2.1.2
scikit-learn==1.4.0
from sklearn.metrics import accuracy_score, precision_recall_fscore_support
def compute_metrics(pred):
labels = pred.label_ids
preds = pred.predictions.argmax(-1)
precision, recall, f1, _ = precision_recall_fscore_support(labels, preds, average='binary')
return {
'accuracy': accuracy_score(labels, preds),
'f1': f1,
'precision': precision,
'recall': recall
}
from transformers import pipeline
def load_model(model_path):
return pipeline("sentiment-analysis", model=model_path)
def predict(classifier, text):
return classifier(text)
if __name__ == "__main__":
model_path = "your-username/sentiment-analysis-model"
classifier = load_model(model_path)
# Example prediction
text = "This movie was really great!"
result = predict(classifier, text)
print(f"Text: {text}\nSentiment: {result}")
train.py:training_args = TrainingArguments(
output_dir="sentiment-analysis-model",
hub_model_id="your-username/sentiment-analysis-model", # Change this
...
)
python train.py
from inference import load_model, predict
classifier = load_model("your-username/sentiment-analysis-model")
result = predict(classifier, "Your text here")
MIT License