Skip to main content

Generated from aind-library-template

Project description

License Code Style semantic-release: angular Interrogate Coverage Python

Usage

Installation

Install a virtual environment with python 3.11 (install a python 3.11 that's compatible with your operating system). Check if download was successful by runninng

py -3.11 -m venv .venv

On Windows, activate the environment with

.venv\Scripts\Activate.ps1

Install the chatbot package.

pip install -e .

To develop the code, run

pip install -e .[dev]

Or simply,

pip install metadata-chatbot

High Level Overview

The project's main goal is to developing a chat bot that is able to ingest, analyze and query metadata. Metadata is accumulated in lieu with experiments and consists of information about the data description, subject, equipment and session. To maintain reproducibility standards, it is important for metadata to be documented well.

Model Overview

The current chat bot model uses Anthropic's Claude Sonnet 3 hosted on AWS' Bedrock service. Since the primary goal is to use natural language to query the database, the user will provide prompts about the metadata specifically. The framework is hosted on Langchain. Claude's system prompt has been configured to understand the metadata schema format and craft MongoDB queries based on the prompt. Given a natural language query about the metadata, the model will produce a MongoDB query, thought reasoning and answer. This method of answering follows chain of thought reasoning, where a complex task is broken up into manageable chunks, allowing logical thinking through of a problem.

The main framework used by the model is Retrieval Augmented Generation, a process in which the model consults an external database to generate information for the user's query. This process doesn't interfere with the model's training process, but rather allows the model to successfully query unseen data with few shot learning (examples of queries and answers) and tools (e.g. API access) to examine these databases.

Data Retrieval

Vector Embeddings

To improve retrieval accuracy and decrease hallucinations, we use vector embeddings to access relevant chunks of information found across the database. This process starts with accessing assets, and chunking each json file to chunks of around 8000 tokens (10 chunks per file)-- each chunk preserves the hierarchy found in json files. These chunks are converted to vector arrays of size 1024, through an embedding model (Amazon's Titan 2.0 Embedding). The user's query is converted to a vector and projected onto the latent space. The chunks that contain the most relevant information will be accessed through a cosine similarity search.

AIND-data-schema-access REST API

For queries that require accessing the entire database, like count based questions, information is accessed through an aggregation pipeline, provided by one of the constructed LLM agents, and the API connection.

Multi-Agent graph framework

A multi-agent workflow is created using Langgraph, allowing for parallel execution of tasks, like document retrieval from the vector index, and control over the the RAG process.

Worfklow

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metadata_chatbot-0.0.59.tar.gz (92.8 kB view details)

Uploaded Source

Built Distribution

metadata_chatbot-0.0.59-py3-none-any.whl (38.6 kB view details)

Uploaded Python 3

File details

Details for the file metadata_chatbot-0.0.59.tar.gz.

File metadata

  • Download URL: metadata_chatbot-0.0.59.tar.gz
  • Upload date:
  • Size: 92.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for metadata_chatbot-0.0.59.tar.gz
Algorithm Hash digest
SHA256 91ff6ad3382eb1a2dee5177ac26583b6d386791e75461f44b5cc108d7b145ec8
MD5 762a4b6ec2821f029754d2979539a9d4
BLAKE2b-256 f19062d46af166c30e686d85f1fba5101cd2380c5781056847221825542f0838

See more details on using hashes here.

File details

Details for the file metadata_chatbot-0.0.59-py3-none-any.whl.

File metadata

File hashes

Hashes for metadata_chatbot-0.0.59-py3-none-any.whl
Algorithm Hash digest
SHA256 efe9ebb8ea6142555d3ad1fcc7216b3e3a963489f315343dcd408de5d99d76ba
MD5 e1b57397231479eb2280506c390ae600
BLAKE2b-256 a681234e363c89ed35d131e81eef3c376b2ee1f8bbc371a919ec5d1d0919936e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page