Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
uploading sample data and updated yaml
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
  • Loading branch information
franciscojavierarceo committed Jan 29, 2025
commit a1a9408528ce62ddc40925167dad945e82782dd0
661 changes: 644 additions & 17 deletions Makefile

Large diffs are not rendered by default.

Binary file not shown.
11 changes: 9 additions & 2 deletions examples/rag/feature_repo/example_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
FileSource,
)
from feast.data_format import ParquetFormat
from feast.types import Float32, Array
from feast.types import Float32, Array, String
from feast import Entity

item = Entity(name="item_id")
Expand All @@ -23,7 +23,14 @@
name="city_embeddings",
entities=[item],
schema=[
Field(name="Embeddings", dtype=Array(Float32)),
Field(
name="vector",
dtype=Array(Float32),
vector_index=True,
vector_search_metric="L2",
),
Field(name="sentence_chunks", dtype=String),
Field(name="wiki_summary", dtype=String),
],
source=source,
ttl=timedelta(hours=2),
Expand Down
7 changes: 1 addition & 6 deletions examples/rag/feature_repo/feature_store.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ registry: data/registry.db
online_store:
type: milvus
vector_enabled: true
vector_len: 384
host: 127.0.0.1
# port: 5432
port: 19530
username: "username"
password: "password"
embedding_dim: 384


offline_store:
Expand Down
6 changes: 5 additions & 1 deletion examples/rag/feature_repo/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import torch
import torch.nn.functional as F
from feast import FeatureStore
from pymilvus import MilvusClient
from transformers import AutoTokenizer, AutoModel
from example_repo import city_embeddings_feature_view, item
TOKENIZER = "sentence-transformers/all-MiniLM-L6-v2"
Expand Down Expand Up @@ -37,8 +38,11 @@ def run_demo():
df = pd.read_parquet("./data/city_wikipedia_summaries_with_embeddings.parquet")
store.apply([city_embeddings_feature_view, item])
store.write_to_online_store_async("city_embeddings", df)
question = "the most populous city in the U.S. state of Texas?"

client = MilvusClient(alias="feast", host="localhost", port="19530", token="username:password")
print(client.list_collections())

question = "the most populous city in the U.S. state of Texas?"
tokenizer = AutoTokenizer.from_pretrained(TOKENIZER)
model = AutoModel.from_pretrained(MODEL)
query_embedding = run_model(question, tokenizer, model)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,26 @@ def retrieve_online_documents(

# Search query template to find the top k items that are closest to the given embedding
# SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5;
query = sql.SQL(
"""
SELECT
entity_key,
feature_name,
value,
vector_value,
vector_value {distance_metric_sql} %s::vector as distance,
event_ts FROM {table_name}
WHERE feature_name = {feature_name}
ORDER BY distance
LIMIT {top_k};
"""
).format(
distance_metric_sql=sql.SQL(distance_metric_sql),
table_name=sql.Identifier(table_name),
feature_name=sql.Literal(requested_feature),
top_k=sql.Literal(top_k),
)
print(query)
cur.execute(
sql.SQL(
"""
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/feast/repo_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"feast.infra.online_stores.contrib.ikv_online_store.ikv.IKVOnlineStore": "feast.infra.online_stores.ikv_online_store.ikv.IKVOnlineStore",
"feast.infra.online_stores.contrib.elasticsearch.ElasticSearchOnlineStore": "feast.infra.online_stores.elasticsearch_online_store.ElasticSearchOnlineStore",
"feast.infra.online_stores.contrib.singlestore_online_store.singlestore.SingleStoreOnlineStore": "feast.infra.online_stores.singlestore_online_store.singlestore.SingleStoreOnlineStore",
"feast.infra.online_stores.contrib.qdrant.QdrantOnlineStore": "feast.infra.online_stores.cqdrant.QdrantOnlineStore",
# "feast.infra.online_stores.contrib.qdrant.QdrantOnlineStore": "feast.infra.online_stores.cqdrant.QdrantOnlineStore",
}

ONLINE_STORE_CLASS_FOR_TYPE = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
"dynamodb": (DYNAMO_CONFIG, DynamoDBOnlineStoreCreator),
"datastore": ("datastore", DatastoreOnlineStoreCreator),
"bigtable": ("bigtable", BigtableOnlineStoreCreator),
# "milvus:": (MILVUS_CONFIG, MilvusOnlineStoreCreator),
}

for key, replacement in replacements.items():
Expand Down