diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index 731e3199..d1fa608e 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - with: - lfs: true + - name: fetch-models + run: sh fetch-models.sh - name: execute run: docker-compose -f ./docker/docker-compose.yaml run dotnet \ No newline at end of file diff --git a/fetch-models.sh b/fetch-models.sh new file mode 100644 index 00000000..89d9234f --- /dev/null +++ b/fetch-models.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +curl -o ./src/Redis.OM.Vectorizers.AllMiniLML6V2/Resources/model.onnx https://storage.googleapis.com/slorello/model.onnx + +curl -o ./src/Redis.OM.Vectorizers.AllMiniLML6V2/Resources/vocab.txt https://storage.googleapis.com/slorello/vocab.txt + +curl -o ./src/Redis.OM.Vectorizers.Resnet18/Resources/ResNet18Onnx/ResNet18.onnx https://storage.googleapis.com/slorello/ResNet18.onnx + +curl -o ./src/Redis.OM.Vectorizers.Resnet18/Resources/ResNetPrepOnnx/ResNetPreprocess.onnx https://storage.googleapis.com/slorello/ResNetPreprocess.onnx \ No newline at end of file diff --git a/src/Redis.OM.Vectorizers.AllMiniLML6V2/Redis.OM.Vectorizers.AllMiniLML6V2.csproj b/src/Redis.OM.Vectorizers.AllMiniLML6V2/Redis.OM.Vectorizers.AllMiniLML6V2.csproj index 30badfd0..09f06dd7 100644 --- a/src/Redis.OM.Vectorizers.AllMiniLML6V2/Redis.OM.Vectorizers.AllMiniLML6V2.csproj +++ b/src/Redis.OM.Vectorizers.AllMiniLML6V2/Redis.OM.Vectorizers.AllMiniLML6V2.csproj @@ -5,9 +5,9 @@ enable enable Redis.OM.Vectorizers.AllMiniLML6V2 - 0.6.0 - 0.6.0 - https://github.com/redis/redis-om-dotnet/releases/tag/v0.6.0 + 0.6.1 + 0.6.1 + https://github.com/redis/redis-om-dotnet/releases/tag/v0.6.1 Sentence Vectorizer for Redis OM .NET using all-MiniLM-L6-v2 Redis OM all-MiniLM-L6-v2 Vectorizers Steve Lorello diff --git a/src/Redis.OM.Vectorizers.Resnet18/Redis.OM.Vectorizers.Resnet18.csproj b/src/Redis.OM.Vectorizers.Resnet18/Redis.OM.Vectorizers.Resnet18.csproj index 58d9d1e3..f1d214ee 100644 --- a/src/Redis.OM.Vectorizers.Resnet18/Redis.OM.Vectorizers.Resnet18.csproj +++ b/src/Redis.OM.Vectorizers.Resnet18/Redis.OM.Vectorizers.Resnet18.csproj @@ -4,9 +4,9 @@ enable enable Redis.OM.Vectorizers.Resnet18 - 0.6.0 - 0.6.0 - https://github.com/redis/redis-om-dotnet/releases/tag/v0.6.0 + 0.6.1 + 0.6.1 + https://github.com/redis/redis-om-dotnet/releases/tag/v0.6.1 Resnet 18 Vectorizers for Redis OM .NET. Redis OM Resnet 18 Vectorizers Steve Lorello diff --git a/src/Redis.OM.Vectorizers/Redis.OM.Vectorizers.csproj b/src/Redis.OM.Vectorizers/Redis.OM.Vectorizers.csproj index 830ac576..df9f5732 100644 --- a/src/Redis.OM.Vectorizers/Redis.OM.Vectorizers.csproj +++ b/src/Redis.OM.Vectorizers/Redis.OM.Vectorizers.csproj @@ -5,9 +5,9 @@ enable enable Redis.OM - 0.6.0 - 0.6.0 - https://github.com/redis/redis-om-dotnet/releases/tag/v0.6.0 + 0.6.1 + 0.6.1 + https://github.com/redis/redis-om-dotnet/releases/tag/v0.6.1 Core Vectorizers for Redis OM .NET. Redis OM Vectorizers Steve Lorello diff --git a/src/Redis.OM/Modeling/RedisSchemaField.cs b/src/Redis.OM/Modeling/RedisSchemaField.cs index 1a938eb5..4f6d4da3 100644 --- a/src/Redis.OM/Modeling/RedisSchemaField.cs +++ b/src/Redis.OM/Modeling/RedisSchemaField.cs @@ -119,7 +119,13 @@ internal static string[] SerializeArgs(this PropertyInfo info) } } - var ret = new List { !string.IsNullOrEmpty(attr.PropertyName) ? $"attr.PropertyName{suffix}" : $"{info.Name}{suffix}" }; + var ret = new List { !string.IsNullOrEmpty(attr.PropertyName) ? $"{attr.PropertyName}{suffix}" : $"{info.Name}{suffix}" }; + if (!string.IsNullOrEmpty(suffix)) + { + ret.Add("AS"); + ret.Add(!string.IsNullOrEmpty(attr.PropertyName) ? attr.PropertyName : info.Name); + } + var innerType = Nullable.GetUnderlyingType(info.PropertyType); ret.AddRange(CommonSerialization(attr, innerType ?? info.PropertyType, info)); return ret.ToArray(); diff --git a/src/Redis.OM/Redis.OM.csproj b/src/Redis.OM/Redis.OM.csproj index 93e68ddc..0cee403e 100644 --- a/src/Redis.OM/Redis.OM.csproj +++ b/src/Redis.OM/Redis.OM.csproj @@ -6,9 +6,9 @@ Redis.OM enable true - 0.6.0 - 0.6.0 - https://github.com/redis/redis-om-dotnet/releases/tag/v0.6.0 + 0.6.1 + 0.6.1 + https://github.com/redis/redis-om-dotnet/releases/tag/v0.6.1 Object Mapping and More for Redis Redis OM Steve Lorello diff --git a/src/Redis.OM/RedisObjectHandler.cs b/src/Redis.OM/RedisObjectHandler.cs index 4f765670..a60aa023 100644 --- a/src/Redis.OM/RedisObjectHandler.cs +++ b/src/Redis.OM/RedisObjectHandler.cs @@ -639,7 +639,7 @@ private static string SendToJson(IDictionary hash, Type t) } var valueStr = $"[{arrString}]"; - ret += $"\"Vector\":{valueStr}}}"; + ret += $"\"Vector\":{valueStr}}},"; } } diff --git a/test/Redis.OM.Unit.Tests/RediSearchTests/VectorTests/HuggingFaceVectors.cs b/test/Redis.OM.Unit.Tests/RediSearchTests/VectorTests/HuggingFaceVectors.cs index 585de4fc..23ce2347 100644 --- a/test/Redis.OM.Unit.Tests/RediSearchTests/VectorTests/HuggingFaceVectors.cs +++ b/test/Redis.OM.Unit.Tests/RediSearchTests/VectorTests/HuggingFaceVectors.cs @@ -4,7 +4,7 @@ namespace Redis.OM.Unit.Tests; -[Document(StorageType = StorageType.Json)] +[Document] public class HuggingFaceVectors { [RedisIdField] diff --git a/test/Redis.OM.Unit.Tests/RediSearchTests/VectorTests/VectorFunctionalTests.cs b/test/Redis.OM.Unit.Tests/RediSearchTests/VectorTests/VectorFunctionalTests.cs index 1a497587..b8d14326 100644 --- a/test/Redis.OM.Unit.Tests/RediSearchTests/VectorTests/VectorFunctionalTests.cs +++ b/test/Redis.OM.Unit.Tests/RediSearchTests/VectorTests/VectorFunctionalTests.cs @@ -236,6 +236,26 @@ public void ScoresOnHash() Assert.Equal(0, res.VectorScores.NearestNeighborsScore); } + [Fact] + public void ScoresOnHashVectorizer() + { + _connection.DropIndexAndAssociatedRecords(typeof(ObjectWithVectorHash)); + _connection.CreateIndex(typeof(ObjectWithVectorHash)); + var simpleHnswVector = Vector.Of(Enumerable.Range(0, 10).Select(x => (double)x).ToArray()); + var simpleVectorizedVector = Vector.Of("foo"); + var obj = new ObjectWithVectorHash + { + Id = "helloWorld", + SimpleHnswVector = simpleHnswVector, + SimpleVectorizedVector = simpleVectorizedVector, + }; + var collection = new RedisCollection(_connection); + collection.Insert(obj); + var res = collection.NearestNeighbors(x => x.SimpleVectorizedVector, 5, "foo").First(); + + Assert.Equal(0, res.VectorScores.NearestNeighborsScore); + } + [Fact] public void HybridQueryTest() { diff --git a/test/Redis.OM.Unit.Tests/RediSearchTests/VectorTests/VectorTests.cs b/test/Redis.OM.Unit.Tests/RediSearchTests/VectorTests/VectorTests.cs index 0ab57f6d..66016e60 100644 --- a/test/Redis.OM.Unit.Tests/RediSearchTests/VectorTests/VectorTests.cs +++ b/test/Redis.OM.Unit.Tests/RediSearchTests/VectorTests/VectorTests.cs @@ -53,7 +53,7 @@ public void CreateIndexWithVector() "Name", "TAG", "SEPARATOR", "|", "Num", "NUMERIC", "SimpleHnswVector", "VECTOR", "HNSW", "6", "TYPE", "FLOAT64", "DIM", "10", "DISTANCE_METRIC", "L2", - "SimpleVectorizedVector.Vector", "VECTOR", "FLAT", "6", "TYPE", "FLOAT32", "DIM", "30", "DISTANCE_METRIC", "L2" + "SimpleVectorizedVector.Vector", "AS", "SimpleVectorizedVector", "VECTOR", "FLAT", "6", "TYPE", "FLOAT32", "DIM", "30", "DISTANCE_METRIC", "L2" ); }