nikolltt commited on
Commit
9f28380
·
verified ·
1 Parent(s): 17c1ba6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -4,13 +4,13 @@ from sentence_transformers import SentenceTransformer, util
4
 
5
  # Load dataset
6
  df = pd.read_csv("quotes.csv")
7
- quotes = df["quote"].tolist()
8
 
9
  # Load embedding model
10
  model = SentenceTransformer("all-MiniLM-L6-v2")
11
  quote_embeddings = model.encode(quotes, convert_to_tensor=True)
12
 
13
- # Function to find top 3 similar quotes
14
  def get_top3(user_input):
15
  if not user_input.strip():
16
  return "Please enter a search phrase."
@@ -25,13 +25,13 @@ def get_top3(user_input):
25
 
26
  return "\n".join(output_quotes)
27
 
28
- # Create Gradio interface
29
  demo = gr.Interface(
30
  fn=get_top3,
31
  inputs=gr.Textbox(lines=2, placeholder="Type something..."),
32
  outputs="text",
33
- title="Quote Finder (1,000+ quotes)",
34
- description="Enter any topic or phrase to find 3 semantically similar quotes from our dataset.",
35
  examples=[
36
  ["happiness"],
37
  ["overcoming failure"],
 
4
 
5
  # Load dataset
6
  df = pd.read_csv("quotes.csv")
7
+ quotes = df["quote"].dropna().tolist()
8
 
9
  # Load embedding model
10
  model = SentenceTransformer("all-MiniLM-L6-v2")
11
  quote_embeddings = model.encode(quotes, convert_to_tensor=True)
12
 
13
+ # Recommendation function
14
  def get_top3(user_input):
15
  if not user_input.strip():
16
  return "Please enter a search phrase."
 
25
 
26
  return "\n".join(output_quotes)
27
 
28
+ # Gradio app
29
  demo = gr.Interface(
30
  fn=get_top3,
31
  inputs=gr.Textbox(lines=2, placeholder="Type something..."),
32
  outputs="text",
33
+ title="Quote Finder",
34
+ description="Find 3 quotes similar to your input using AI embeddings.",
35
  examples=[
36
  ["happiness"],
37
  ["overcoming failure"],