Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: When using AllMiniLML6V2 vectorizer, inference sessions would be… #485

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
- name: fetch-models
run: sh fetch-models.sh
- name: execute
run: docker-compose -f ./docker/docker-compose.yaml run dotnet
run: docker compose -f ./docker/docker-compose.yaml run dotnet
6 changes: 3 additions & 3 deletions src/Redis.OM.Vectorizers.AllMiniLML6V2/SentenceVectorizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class SentenceVectorizer : IVectorizer<string>

/// <inheritdoc />
public int Dim => 384;
private static Lazy<TokenizerBase> Tokenizer => new Lazy<TokenizerBase>(AllMiniLML6V2Tokenizer.Create);
private static Lazy<InferenceSession> InferenceSession => new Lazy<InferenceSession>(LoadInferenceSession);
private static readonly Lazy<TokenizerBase> Tokenizer = new(AllMiniLML6V2Tokenizer.Create);
private static readonly Lazy<InferenceSession> InferenceSession = new(LoadInferenceSession);

private static InferenceSession LoadInferenceSession()
{
Expand All @@ -40,7 +40,7 @@ public byte[] Vectorize(string obj)
return Vectorize(new[] { obj })[0].SelectMany(BitConverter.GetBytes).ToArray();
}

private static Lazy<string[]> OutputNames => new (() => InferenceSession.Value.OutputMetadata.Keys.ToArray());
private static readonly Lazy<string[]> OutputNames = new (() => InferenceSession.Value.OutputMetadata.Keys.ToArray());

/// <summary>
/// Vectorizers an array of sentences (which are vectorized individually).
Expand Down
Loading