Downloads · 30 days
4
18% of all-time downloads
AventIQ-AI/Movie-Recommendation-Using-Sentence-Transormer
Movie-Recommendation-Using-Sentence-Transormer is a machine learning model from AventIQ-AI. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository hosts a quantized version of the Sentence Transformer model, fine-tuned for Movie Recommendation using the Movie Lens dataset. The model has been optimized using FP16 quantization for efficient deploym…
Downloads · 30 days
4
18% of all-time downloads
All-time downloads
22
Public
Parameters
22.7M
45.4 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors45.4 MB · 98%
From the Hugging Face model README
This repository hosts a quantized version of the Sentence Transformer model, fine-tuned for Movie Recommendation using the Movie Lens dataset. The model has been optimized using FP16 quantization for efficient deployment without significant accuracy loss.
!pip install pandas torch sentence-transformers scikit-learn
from sentence_transformers import SentenceTransformer, InputExample, losses, util
import torch
# Load model
device = 'cuda' if torch.cuda.is_available() else 'cpu'
model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2', device=device)
# pass the movie name
recommend_by_movie_name("Toy Story")
# Recommend Movies
def recommend_by_movie_name(movie_name, top_k=5):
titles = movie_subset["title"].tolist()
matches = get_close_matches(movie_name, titles, n=1, cutoff=0.6)
if not matches:
print(f"❌ Movie '{movie_name}' not found in dataset.")
return
matched_title = matches[0]
movie_index = movie_subset[movie_subset["title"] == matched_title].index[0]
query_embedding = movie_embeddings[movie_index]
scores = util.pytorch_cos_sim(query_embedding, movie_embeddings)[0]
top_results = torch.topk(scores, k=top_k + 1)
print(f"\n🎬 Recommendations for: {matched_title}")
for score, idx_tensor in zip(top_results[0][1:], top_results[1][1:]): # skip itself
idx = idx_tensor.item() # ✅ Convert tensor to int
title = movie_subset.iloc[idx]["title"]
print(f" {title} (Score: {score:.4f})")
The dataset is sourced from Hugging Face’s Movie-Lens dataset. It contains 20,000 movies and their genres.
epochPost-training quantization was applied using PyTorch’s half() precision (FP16) to reduce model size and inference time.
.
├── quantized-model/ # Contains the quantized model files
│ ├── config.json
│ ├── model.safetensors
│ ├── tokenizer_config.json
│ ├── modules.json
│ └── special_tokens_map.json
│ ├── sentence_bert_config.jason
│ └── tokenizer.json
│ ├── config_sentence_transformers.jason
│ └── vocab.txt
├── README.md # Model documentation
Feel free to open issues or submit pull requests to improve the model or documentation.