Instructions to use Ravinthiran/Distilsenti-Net-42M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use Ravinthiran/Distilsenti-Net-42M with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://Ravinthiran/Distilsenti-Net-42M") - Notebooks
- Google Colab
- Kaggle
Model Architecture
- Embedding Layer: Converts input text into dense vectors.
- CNN Layers: Extracts features from text sequences.
- RNN, LSTM, and GRU Layers: Capture temporal dependencies in text.
- Dense Layers: Classify text into sentiment categories.
Usage
You can use this model for sentiment analysis on text data. Here's a sample code to load and use the model:
from tensorflow.keras.models import load_model
import pickle
import numpy as np
from tensorflow.keras.preprocessing.sequence import pad_sequences
# Load the model
model = load_model('path_to_model/hybrid_model.h5')
# Load the tokenizer
with open('path_to_tokenizer/tokenizer.pkl', 'rb') as f:
tokenizer = pickle.load(f)
# Predict sentiment
def predict_sentiment(text):
text = text.lower()
text = re.sub(r'[^\w\s]', '', text)
sequence = tokenizer.texts_to_sequences([text])
padded_sequence = pad_sequences(sequence, maxlen=100)
pred = model.predict(padded_sequence)
sentiment = np.argmax(pred)
return sentiment
# Example usage
text = "I love this product!"
print(predict_sentiment(text))
- Downloads last month
- 11