Skip to content
Albert edited this page Jun 11, 2024 · 24 revisions

Welcome to the AssistantAI wiki!

Project Overview

  • Create a assistant AI to chat about a user knowledge base (.pdf, .md, data from a local database, etc ..)
  • Use OpenAI / AWS Bedrock
  • Spring Boot AI / LangChain4J
  • MongoDB vector

Tech stack

Approaches

Approach Title Description Link
#1 Class Configuration (not auto-configuration) MongoDB & AWS Bedrock Titan embeddings configuration using @Bean and @Configuration.
#2 LangChain4J A demo of LangChain4J for building applications using the LangChain framework. LangChain4J, GitHub
#3 Spring Boot AI Starters Using Spring Boot AI Starters for Bedrock, Titan embeddings, and MongoDB as a vector database. Spring Boot AI, Spring AI Bedrock, Titan embeddings
#4 Spring Boot AI Starters Using Spring Boot AI Starters for OpenAI embeddings and MongoDB as a vector database. Spring Boot AI, Spring AI Chat OpenAI
#5 ApplicationRunner (just one class, pure sandbox) Integrating Spring Boot AI with OpenAI, Postgres vector DB, and PDF source using ApplicationRunner with @Bean and @Component. video, Spring AI Chat pdf: code

Embedings & MongoDB data vector

Embedings

Note

Embeddings are a fundamental concept in natural language processing and machine learning. They are a way to represent words, phrases, or documents as vectors in a high-dimensional space, where the distance and direction between vectors capture semantic relationships. Amazon Titan supports the generation of text and multimodal embeddings, offering a powerful tool for various use cases, from information retrieval to content recommendation.

  • Semantic Relationships: Embeddings enable models to understand the semantic relationships between entities. Words with similar meanings are represented by vectors that are close in the embedding space.
  • Contextual Understanding: Embeddings capture contextual information, allowing algorithms to discern nuances and subtle differences in meaning, enhancing the accuracy of various NLP tasks.
  • Dimensionality Reduction: Embeddings effectively reduce the dimensionality of the data, retaining essential information while minimizing computational complexity.
  • Transfer Learning: Pre-trained embeddings, such as those learned from large language models, can be transferred and fine-tuned for specific tasks, saving training time and resources.

MongoDB as vector DB

We should define this fields at engine search, index definition:

Note

  • path: The field name in the collection on which index will be created
  • numDimensions: The Amazon Titan Embeddings G1 – Text v1.2 can intake up to 8k tokens and outputs a vector of 1,536 dimensions.
  • similarity: /Vector similarity function to use to search for top K-nearest neighbors.
path: 'vector_data'
numDimensions: 1536
similarity: 'dotProduct'

Bedrock AWS

What is Amazon Bedrock?

Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies like AI21 Labs, Anthropic, Cohere, Meta, Mistral AI, Stability AI, and Amazon through a single API, along with a broad set of capabilities you need to build generative AI applications with security, privacy, and responsible AI.

Using Amazon Bedrock, you can customize the models with your data using techniques such as fine-tuning and Retrieval Augmented Generation (RAG), and build agents that execute tasks using your enterprise systems and data sources.

Amazon Titan Text Embeddings models

image image image