prrao87 commited on
Commit
11a568a
·
verified ·
1 Parent(s): 5d2deab

Update README with LanceDB examples

Browse files
Files changed (1) hide show
  1. README.md +64 -0
README.md CHANGED
@@ -66,6 +66,54 @@ ds = lance.dataset("hf://datasets/lance-format/gqa-testdev-balanced-lance/data/t
66
  print(ds.count_rows(), ds.schema.names, ds.list_indices())
67
  ```
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  ## Filter by reasoning type
70
 
71
  ```python
@@ -74,6 +122,22 @@ ds = lance.dataset("hf://datasets/lance-format/gqa-testdev-balanced-lance/data/t
74
  verify_qs = ds.scanner(filter="structural = 'verify'", columns=["question", "answer"], limit=5).to_table()
75
  ```
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  ## Why Lance?
78
 
79
  - One dataset for the joined image + question + answer + reasoning-program metadata + dual embeddings + indices — no instructions/images parquet split to keep in sync.
 
66
  print(ds.count_rows(), ds.schema.names, ds.list_indices())
67
  ```
68
 
69
+ ## Load with LanceDB
70
+
71
+ These tables can also be consumed by [LanceDB](https://lancedb.github.io/lancedb/), the serverless vector database built on Lance, for simplified vector search and other queries.
72
+
73
+ ```python
74
+ import lancedb
75
+
76
+ db = lancedb.connect("hf://datasets/lance-format/gqa-testdev-balanced-lance/data")
77
+ tbl = db.open_table("testdev")
78
+ print(f"LanceDB table opened with {len(tbl)} image-question pairs")
79
+ ```
80
+
81
+ ### LanceDB vector search
82
+
83
+ ```python
84
+ import lancedb
85
+
86
+ db = lancedb.connect("hf://datasets/lance-format/gqa-testdev-balanced-lance/data")
87
+ tbl = db.open_table("testdev")
88
+
89
+ ref = tbl.search().limit(1).select(["question_emb", "question"]).to_list()[0]
90
+ query_embedding = ref["question_emb"]
91
+
92
+ results = (
93
+ tbl.search(query_embedding, vector_column_name="question_emb")
94
+ .metric("cosine")
95
+ .select(["question", "answer"])
96
+ .limit(5)
97
+ .to_list()
98
+ )
99
+ ```
100
+
101
+ ### LanceDB full-text search
102
+
103
+ ```python
104
+ import lancedb
105
+
106
+ db = lancedb.connect("hf://datasets/lance-format/gqa-testdev-balanced-lance/data")
107
+ tbl = db.open_table("testdev")
108
+
109
+ results = (
110
+ tbl.search("color of the car")
111
+ .select(["question", "answer"])
112
+ .limit(10)
113
+ .to_list()
114
+ )
115
+ ```
116
+
117
  ## Filter by reasoning type
118
 
119
  ```python
 
122
  verify_qs = ds.scanner(filter="structural = 'verify'", columns=["question", "answer"], limit=5).to_table()
123
  ```
124
 
125
+ ### Filter with LanceDB
126
+
127
+ ```python
128
+ import lancedb
129
+
130
+ db = lancedb.connect("hf://datasets/lance-format/gqa-testdev-balanced-lance/data")
131
+ tbl = db.open_table("testdev")
132
+ verify_qs = (
133
+ tbl.search()
134
+ .where("structural = 'verify'")
135
+ .select(["question", "answer"])
136
+ .limit(5)
137
+ .to_list()
138
+ )
139
+ ```
140
+
141
  ## Why Lance?
142
 
143
  - One dataset for the joined image + question + answer + reasoning-program metadata + dual embeddings + indices — no instructions/images parquet split to keep in sync.