Instructions to use 1998Shubham007/RecommModel with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use 1998Shubham007/RecommModel with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("1998Shubham007/RecommModel") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
File size: 988 Bytes
3713abf 37551d3 3713abf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | import streamlit as st
import torch
import pandas as pd
from sentence_transformers import SentenceTransformer, util
import pickle
# Load data
data = pd.read_csv("/content/arxiv_data.csv")
titles = data["titles"]
# Load pre-trained SentenceTransformer model
model = SentenceTransformer("all-MiniLM-L6-v2")
# Load saved embeddings
with open("/content/embedding.pkl", "rb") as f:
Lencode = pickle.load(f)
def recomm(inputPaper):
encodePaper = model.encode(inputPaper)
cosine_score = util.cos_sim(Lencode, encodePaper)
top_scores = torch.topk(cosine_score, dim=0, k=4)
paperList = []
for i in top_scores.indices:
paperList.append(titles[i.item()])
return paperList
# Streamlit UI
st.title("Paper Recommendation System")
input_paper = st.text_input("Enter the name of the paper")
if st.button("Recommend"):
recommended_papers = recomm(input_paper)
st.write("Recommended Papers:")
for paper in recommended_papers:
st.write(paper)
|