Spaces:
Runtime error
Runtime error
Commit ·
9513c18
1
Parent(s): a555050
Change embed syntax
Browse files- app.py +2 -1
- populate_db.py +3 -2
app.py
CHANGED
|
@@ -67,7 +67,8 @@ model = ChatNebius(
|
|
| 67 |
|
| 68 |
def emb_text(text: str) -> List[float]:
|
| 69 |
"""Generate embeddings for text using the sentence transformer model."""
|
| 70 |
-
return embedding_model.
|
|
|
|
| 71 |
|
| 72 |
def retrieve_relevant_documents(query: str, limit: int = 5) -> List[Dict]:
|
| 73 |
"""Retrieve relevant documents from Milvus based on the query."""
|
|
|
|
| 67 |
|
| 68 |
def emb_text(text: str) -> List[float]:
|
| 69 |
"""Generate embeddings for text using the sentence transformer model."""
|
| 70 |
+
return embedding_model.embed_query(text)
|
| 71 |
+
# return embedding_model.encode([text], normalize_embeddings=True).tolist()[0]
|
| 72 |
|
| 73 |
def retrieve_relevant_documents(query: str, limit: int = 5) -> List[Dict]:
|
| 74 |
"""Retrieve relevant documents from Milvus based on the query."""
|
populate_db.py
CHANGED
|
@@ -26,7 +26,8 @@ embedding_model = NebiusEmbeddings(
|
|
| 26 |
|
| 27 |
def emb_text(text):
|
| 28 |
"""Generate embeddings for text using the sentence transformer model."""
|
| 29 |
-
return embedding_model.
|
|
|
|
| 30 |
|
| 31 |
def create_collection():
|
| 32 |
"""Create collection if it doesn't exist."""
|
|
@@ -37,7 +38,7 @@ def create_collection():
|
|
| 37 |
# Create Milvus collection schema
|
| 38 |
schema = milvus_client.create_schema(auto_id=False, enable_dynamic_field=False)
|
| 39 |
schema.add_field(field_name="id", datatype=DataType.INT64, is_primary=True)
|
| 40 |
-
schema.add_field(field_name="vector", datatype=DataType.FLOAT_VECTOR, dim=
|
| 41 |
schema.add_field(field_name="text", datatype=DataType.VARCHAR) # 32KB max
|
| 42 |
schema.add_field(field_name="metadata", datatype=DataType.JSON)
|
| 43 |
|
|
|
|
| 26 |
|
| 27 |
def emb_text(text):
|
| 28 |
"""Generate embeddings for text using the sentence transformer model."""
|
| 29 |
+
return embedding_model.embed_query(text)
|
| 30 |
+
# return embedding_model.encode([text], normalize_embeddings=True).tolist()[0]
|
| 31 |
|
| 32 |
def create_collection():
|
| 33 |
"""Create collection if it doesn't exist."""
|
|
|
|
| 38 |
# Create Milvus collection schema
|
| 39 |
schema = milvus_client.create_schema(auto_id=False, enable_dynamic_field=False)
|
| 40 |
schema.add_field(field_name="id", datatype=DataType.INT64, is_primary=True)
|
| 41 |
+
schema.add_field(field_name="vector", datatype=DataType.FLOAT_VECTOR, dim=4096) # Qwen/Qwen3-Embedding-8B dimension
|
| 42 |
schema.add_field(field_name="text", datatype=DataType.VARCHAR) # 32KB max
|
| 43 |
schema.add_field(field_name="metadata", datatype=DataType.JSON)
|
| 44 |
|