Empower your business growth with smart, data-driven marketing solutions
Streamline success with tailored business solutions built for growth
Transform learning experiences with innovative education solutions
Sort emails by their MX
Extract emails from email account
Varify large email list
Send emails without any hessle
Swift, reliable SMS delivery
Professional business email
Smart pharmacy automation
Secure pharmacy operations
Complete hospital operations
Streamlined business workflow
Smarter property management
Automated result system
Smart student admission
Modern coaching administration
Build innovative custom software that drives your business forward.
Create stunning, responsive websites that engage and convert.
Deliver powerful, user-friendly apps that bring ideas to life.
Advice and answers from the our team.
Boost local credibility with a .BD domain, registered swiftly via our BTCL partnership.
Scalable hosting built for speed, security, and consistent uptime to support business growth.
Trusted local domain authority
Secure global domain
High-performance, reliable infrastructure
30 N GOULD ST STE R, SHERIDAN, WY 82801
+1 (307) 310-6664
info@astgd.com
https://astgd.com
Learn about our company, our culture, and the values that drive us to innovate every day.
Explore our suite of powerful and intuitive productivity tools designed to streamline your work.
Explore a gallery of our company milestones, team photos, and exciting moments from technology showcases and events.
Visit us at our office
Recently we completed a software project where customer will store a lot of information and the information will get a conclusion (a lot of other data) through some steps and fixed procedures.
We decided to choose XAF because it will greatly reduce our work when we have to create/design various roles and access rules. We faced a problem when there is similar information already stored and that have a conclusion.
But how to search for similar information, because title doesn’t match, description doesn’t match but they are identical in context. Here comes the semantic search/ contextual search solution.
We will create Vector Embeddings of our Information title and description and then perform cosine search to get similarity score.
We will tune the similarity score and thus we will get similar information stored that does not have exact match in title but their context is the same.
There are many services for vector embeddings. GitHub Models have some nice free options. So I will use text embedding 3 small offered by OpenAI. For reference check out here .
Let’s create a new project XAF Blazor. I am using XPO as ORM.
Take a new business object with 2 properties (Title, Description) and another calculated property (Semantic Document) to hold them together.
[Size(SizeAttribute.DefaultStringMappingFieldSize)] public string Title { get => title; set => SetPropertyValue(nameof(Title), ref title, value); } [Size(SizeAttribute.Unlimited)] public string Description { get => description; set => SetPropertyValue(nameof(Description), ref description, value); } [VisibleInDetailView(false), VisibleInListView(false)] public string SemanticDocument => $"{Title}\n{Description}";
To store vector embeddings lets take a byte property ‘Embedding’ and to store similarity score take a double non persistent property ‘Similarity Score’.
[Size(SizeAttribute.Unlimited)] [VisibleInDetailView(false), VisibleInListView(false)] public byte[] Embedding { get => embedding; set => SetPropertyValue(nameof(Embedding), ref embedding, value); } [NonPersistent] [ModelDefault("DisplayFormat", "0.000")] [ModelDefault("AllowEdit", "False")] public double SimilarityScore { get => similarityScore; set => SetPropertyValue(nameof(SimilarityScore), ref similarityScore, value); } private double similarityScore;
To use Github models (text embedding 3 small from OpenAI), we need “OpenAI” package reference. We will add the package reference to our platform agnostic projects i.e., the module project.
dotnet add package OpenAI
Now go to the Github models and get your personal access token. We will save that access token in appsettings.json like this.
"ConnectionStrings": { "ConnectionString": "Data Source=(localdb)\\mssqllocaldb;Integrated Security=SSPI;Pooling=false;Initial Catalog=SemanticSearchBlog", "EasyTestConnectionString": "Data Source=(localdb)\\mssqllocaldb;Integrated Security=SSPI;Pooling=false;Initial Catalog=SemanticSearchBlogEasyTest" }, "GitHubModels": { "Token": "your_github_tokens" }, "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information", "DevExpress.ExpressApp": "Information" }
Now we will create Get Embedding service and vectormath in services folder of the module project.
Get Embedding service is creating a Embedding Client. Here check how we retrieved our Github model token from appsettings.json. You can more securely save token in other more secure storage.
private EmbeddingClient CreateClient() { var token =_config["GitHubModels:Token"] ?? _config["GITHUB_MODELS_TOKEN"] ?? Environment.GetEnvironmentVariable("GITHUB_TOKEN"); if (string.IsNullOrWhiteSpace(token)) throw new InvalidOperationException("GitHub Models token is missing."); var options = new OpenAIClientOptions { Endpoint = new Uri("https://models.github.ai/inference") }; return new EmbeddingClient("openai/text-embedding-3-small",new ApiKeyCredential(token),options); }
Finally we are accepting text and returning generated embeddings.
public byte[] GenerateEmbedding(string text) { var result = Client.GenerateEmbeddings(new[] { text }); var embeddings = result.Value; var vector = embeddings[0].ToFloats().Span; return FloatVectorToBytes(vector); }
Vectormatch.cs performs the cosine similarity and return a scrore less than 1. View Full Code
Generate embeddings may take a long time for long text. So better not to use OnSaving method of the business objects. You can create a background service that will periodically run embedding service for newly created records. Here we will use a view controller and will create an action to generate embedding on demand for selected records.
Check AI Services controller code. Check the Find Similarity action code. Here I am checking similarity and taking top 5 objects and also I used threshold of 0.5. You can increase the threshold value to your needs. This needs to be tuned for better results.
There are many other ways to extend this demo. Implementing AI techniques in your existing XAF application is going to be a much prioritized work in coming times ahead.
Discover powerful hosting solutions, premium VPS plans, and tools designed to boost your website’s performance and reliability.
Live Chat
Skype Support
Support Ticket
WhatsApp Support