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
Download app.py from 1998Shubham007/RecommModel: direct link, hf CLI and curl.
- Browser
- Download file 988 Bytes
-
https://huggingface.co/1998Shubham007/RecommModel/resolve/main/app.py
- Command line
-
hf download hf://1998Shubham007/RecommModel/app.py
-
curl -L -o app.py https://huggingface.co/1998Shubham007/RecommModel/resolve/main/app.py
988 Bytes
| 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) | |