From e4c3a9346c2bc68caf3e826f5a5e20c25b92bf2d Mon Sep 17 00:00:00 2001 From: Tan Li Date: Tue, 3 Oct 2023 00:55:16 -0700 Subject: [PATCH] [doc] make the tensor width differnt from height (#533) --- docs/src/guides/tables.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/src/guides/tables.md b/docs/src/guides/tables.md index ab49ef0d..e3e9a35b 100644 --- a/docs/src/guides/tables.md +++ b/docs/src/guides/tables.md @@ -42,7 +42,7 @@ A Table is a collection of Records in a LanceDB Database. You can follow along o import pandas as pd data = pd.DataFrame({ - "vector": [[1.1, 1.2], [0.2, 1.8]], + "vector": [[1.1, 1.2, 1.3, 1.4], [0.2, 1.8, 0.4, 3.6]], "lat": [45.5, 40.1], "long": [-122.7, -74.1] }) @@ -56,7 +56,7 @@ A Table is a collection of Records in a LanceDB Database. You can follow along o ```python custom_schema = pa.schema([ - pa.field("vector", pa.list_(pa.float32(), 2)), + pa.field("vector", pa.list_(pa.float32(), 4)), pa.field("lat", pa.float32()), pa.field("long", pa.float32()) ]) @@ -70,8 +70,8 @@ A Table is a collection of Records in a LanceDB Database. You can follow along o ```python table = pa.Table.from_arrays( [ - pa.array([[3.1, 4.1], [5.9, 26.5]], - pa.list_(pa.float32(), 2)), + pa.array([[3.1, 4.1, 5.1, 6.1], [5.9, 26.5, 4.7, 32.8]], + pa.list_(pa.float32(), 4)), pa.array(["foo", "bar"]), pa.array([10.0, 20.0]), ], @@ -88,12 +88,12 @@ A Table is a collection of Records in a LanceDB Database. You can follow along o LanceDB supports creating tables by specifying a pyarrow schema or a specialized pydantic model called `LanceModel`. - For example, the following Content model specifies a table with 5 columns: + For example, the following Content model specifies a table with 5 columns: movie_id, vector, genres, title, and imdb_id. When you create a table, you can - pass the class as the value of the `schema` parameter to `create_table`. + pass the class as the value of the `schema` parameter to `create_table`. The `vector` column is a `Vector` type, which is a specialized pydantic type that can be configured with the vector dimensions. It is also important to note that - LanceDB only understands subclasses of `lancedb.pydantic.LanceModel` + LanceDB only understands subclasses of `lancedb.pydantic.LanceModel` (which itself derives from `pydantic.BaseModel`). ```python @@ -131,8 +131,8 @@ A Table is a collection of Records in a LanceDB Database. You can follow along o for i in range(5): yield pa.RecordBatch.from_arrays( [ - pa.array([[3.1, 4.1], [5.9, 26.5]], - pa.list_(pa.float32(), 2)), + pa.array([[3.1, 4.1, 5.1, 6.1], [5.9, 26.5, 4.7, 32.8]], + pa.list_(pa.float32(), 4)), pa.array(["foo", "bar"]), pa.array([10.0, 20.0]), ], @@ -140,7 +140,7 @@ A Table is a collection of Records in a LanceDB Database. You can follow along o ) schema = pa.schema([ - pa.field("vector", pa.list_(pa.float32(), 2)), + pa.field("vector", pa.list_(pa.float32(), 4)), pa.field("item", pa.utf8()), pa.field("price", pa.float32()), ])