ayushsinha commited on
Commit
41655e0
Β·
verified Β·
1 Parent(s): fc659cf

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +84 -0
README.md ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Movie Recommendation System with Sentence Transformers (all-MiniLM-L6-v2)
2
+
3
+ ## πŸ“Œ Overview
4
+
5
+ This repository hosts the quantized version of the all-MiniLM-L6-v2 model fine-tuned for movie reccommendation tasks. The model has been trained on the movielens_ratings dataset from Hugging Face. The model is quantized to Float16 (FP16) to optimize inference speed and efficiency while maintaining high performance.
6
+
7
+ ## πŸ— Model Details
8
+
9
+ - **Model Architecture:** all-MiniLM-L6-v2
10
+ - **Task:** Movie Recommendation System
11
+ - **Dataset:** Hugging Face's `movielens_ratings`
12
+ - **Quantization:** Float16 (FP16) for optimized inference
13
+ - **Fine-tuning Framework:** Hugging Face Transformers
14
+
15
+ ## πŸš€ Usage
16
+
17
+ ### Installation
18
+
19
+ ```bash
20
+ pip install transformers torch
21
+ ```
22
+
23
+ ### Loading the Model
24
+
25
+ ```python
26
+ from sentence_transformers import SentenceTransformer, models
27
+ import torch
28
+
29
+ device = "cuda" if torch.cuda.is_available() else "cpu"
30
+
31
+ model_name = "AventIQ-AI/all-MiniLM-L6-v2-movie-recommendation-system"
32
+ model = SentenceTransformer(model_name).to(device)
33
+ ```
34
+
35
+ ### Question Answer Example
36
+
37
+ ```python
38
+ def generate_movies(genre, top_k=5):
39
+ genre_embedding = model.encode([genre], convert_to_tensor=True)
40
+ movie_embeddings = model.encode(df['title'].tolist(), convert_to_tensor=True)
41
+
42
+ scores = torch.nn.functional.cosine_similarity(genre_embedding, movie_embeddings)
43
+ top_results = torch.argsort(scores, descending=True)
44
+
45
+ # Get unique movies while preserving order
46
+ recommended_movies = []
47
+ seen = set()
48
+ for idx in top_results.tolist():
49
+ movie = df.iloc[idx]['title']
50
+ if movie not in seen:
51
+ recommended_movies.append(movie)
52
+ seen.add(movie)
53
+ if len(recommended_movies) == top_k:
54
+ break
55
+ return recommended_movies
56
+
57
+ print("🎬 Recommended Movies for 'Action':", generate_movies("Action"))
58
+ print("🎬 Recommended Movies for 'Comedy':", generate_movies("Comedy"))
59
+ print("🎬 Recommended Movies for 'Sci-Fi':", generate_movies("Sci-Fi"))
60
+ ```
61
+
62
+ ## ⚑ Quantization Details
63
+
64
+ Post-training quantization was applied using PyTorch's built-in quantization framework. The model was quantized to Float16 (FP16) to reduce model size and improve inference efficiency while balancing accuracy.
65
+
66
+ ## πŸ“‚ Repository Structure
67
+
68
+ ```
69
+ .
70
+ β”œβ”€β”€ model/ # Contains the quantized model files
71
+ β”œβ”€β”€ tokenizer_config/ # Tokenizer configuration and vocabulary files
72
+ β”œβ”€β”€ model.safetensors/ # Quantized Model
73
+ β”œβ”€β”€ README.md # Model documentation
74
+ ```
75
+
76
+ ## ⚠️ Limitations
77
+
78
+ - The model may struggle for out of scope tasks.
79
+ - Quantization may lead to slight degradation in accuracy compared to full-precision models.
80
+ - Performance may vary across different writing styles and sentence structures.
81
+
82
+ ## 🀝 Contributing
83
+
84
+ Contributions are welcome! Feel free to open an issue or submit a pull request if you have suggestions or improvements.