Skip to content

Commit

Permalink
main.py changed
Browse files Browse the repository at this point in the history
  • Loading branch information
danilyef committed Sep 3, 2024
1 parent 1b8017c commit 378828a
Showing 1 changed file with 0 additions and 56 deletions.
56 changes: 0 additions & 56 deletions homework_3/pr7/main.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
'''
Before starting the script, create a virtual environment:
1. cd /path/to/your/project
2. python -m venv env
3. source env/bin/activate
5. pip install -r requirements.txt
After these steps start script from cmd:
5. python main.py
'''


from datasets import load_dataset
import lancedb
Expand All @@ -20,48 +8,6 @@
from sentence_transformers import SentenceTransformer
import typer

"""
# Load the Rick and Morty Transcript dataset
dataset = load_dataset("Prarabdha/Rick_and_Morty_Transcript")
# Remove columns
dataset = dataset.remove_columns(['Unnamed: 0', 'episode no.'])
# Dataset to pandas
dataset = dataset['train'].to_pandas()
# Connect to the LanceDB database
db = lancedb.connect("/tmp/db")
# Initialize the sentence transformer model for embedding
model = get_registry().get("sentence-transformers").create(name="BAAI/bge-small-en-v1.5", device="cpu")
# This class defines the schema for storing quotes in LanceDB
class Quotes(LanceModel):
# Field for the speaker's name
speaker: str
# Field for the dialogue text, which will be used as the source for embedding
dialouge: str = model.SourceField()
# Field for the vector embedding of the dialogue, with dimensions matching the model
vector: Vector(model.ndims()) = model.VectorField()
# Create a table in the LanceDB database with the Quotes schema
table = db.create_table("rick_and_morty", schema=Quotes)
# Add the dataset to the table
table.add(dataset)
# Perform a semantic search query on the table
query = table.search("What is the purpose of existence?").limit(5).to_df()
# Print the query results
print(query)
"""

######################################

app = typer.Typer()

Expand Down Expand Up @@ -121,5 +67,3 @@ def search_index(query: str, top_n: int = 2):
app()


# python main.py create-index
# python main.py search-index "Who are you?" --top-n 2

0 comments on commit 378828a

Please sign in to comment.