Skip to content

trieveoferatosthenes/trieve

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Trieve Logo

Sign Up (1k chunks free) | Documentation | Meeting Link | +1 628-222-4090 | Community Matrix

Github stars GitHub issues Join Discord Join Matrix

Trieve is an Advanced Relevance API for hybrid search, recommendations, and RAG

Trieve OG tag

Quick Links

Features

  • 🔒 Self-Hosting in your VPC or on-prem: Buy a license to host in your company's VPC on prem with our ready-to-go docker containers and terraform templates.
  • 🧠 Semantic Dense Vector Search: Integrates with OpenAI or Jina embedding models and Qdrant to provide semantic vector search.
  • 🔍 Typo Tolerant Full-Text/Neural Search: Every uploaded chunk is vector'ized with naver/efficient-splade-VI-BT-large-query for typo tolerant, quality neural sparse-vector search.
  • 🖊️ Sub-Sentence Highlighting: Highlight the matching words or sentences within a chunk and bold them on search to enhance UX for your users. Shout out to the simsearch crate!
  • 🌟 Recommendations: Find similar chunks (or files if using grouping) with the recommendation API. Very helpful if you have a platform where users favorite, bookmark, or upvote content.
  • 🤖 Convenient RAG API Routes: We integrate with OpenRouter to provide you with access to any LLM you would like for RAG. Try our routes for fully-managed RAG with topic-based memory management or select your own context RAG.
  • 💼 Bring Your Own Models: If you'd like, you can bring your own text-embedding, SPLADE, cross-encoder re-ranking, and/or large-language model (LLM) and plug it into our infrastructure.
  • 🔄 Hybrid Search with cross-encoder re-ranking: For the best results, use hybrid search with BAAI/bge-reranker-large re-rank optimization.
  • 📆 Recency Biasing: Easily bias search results for what was most recent to prevent staleness
  • 🛠️ Tunable Popularity-Based Ranking (Merchandizing): Weight indexed documents by popularity, total sales, or any other arbitrary metric for tunable relevancy
  • 🕳️ Filtering: Date-range, substring match, tag, numeric, and other filter types are supported.
  • 🧐 Duplicate Detection: Check out our docs on collision-based dup detection to learn about how we handle duplicates. This is a setting you can turn on or off.
  • 👥 Grouping: Mark multiple chunks as being part of the same file and search on the file-level such that the same top-level result never appears twice

Are we missing a feature that your use case would need? - call us at 628-222-4090, make a Github issue, or join the Matrix community and tell us! We are a small company who is still very hands-on and eager to build what you need; professional services are available.

Roadmap

Our current top 2 priorities for the next while are as follows. Subject to change as current or potential customers ask for things.

  1. Observability and metrics (likely something w/ Clickhouse)
  2. Benchmarking (going to aim for a 1M, 10M, and 100M vector benchmark)
  3. SDKs (can generate from OpenAPI spec, but would like to test a bit more)

How to contribute

  1. Find an issue in the issues tab that you would like to work on.
  2. Fork the repository and clone it to your local machine
  3. Create a new branch with a descriptive name: git checkout -b your-branch-name
  4. Solve the issue by adding or removing code on your forked branch.
  5. Test your changes locally to ensure that they do not break anything
  6. Commit your changes with a descriptive commit message: git commit -m "Add descriptive commit message here"
  7. Push your changes to your forked repository: git push origin your-branch-name
  8. Open a pull request to the main repository and describe your changes in the PR description

Self-hosting the API and UI's

We have a full self-hosting guide available on our documentation page here.

Local development with Linux

Install apt packages

sudo apt install curl \
gcc \
g++ \
make \
pkg-config \
python3 \
python3-pip \
libpq-dev \
libssl-dev \
openssl

Install NodeJS and Yarn

You can install NVM using its install script.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash

You should restart the terminal to update bash profile with NVM. Then, you can install NodeJS LTS release and Yarn.

nvm install --lts
npm install -g yarn

Make server tmp dir

mkdir server/tmp

Install cargo-watch

cargo install cargo-watch

Setup env's

cp .env.chat ./chat/.env
cp .env.search ./search/.env
cp .env.server ./server/.env

Add your LLM_API_KEY to ./server/.env

Here is a guide for acquiring that.

Steps once you have the key

  1. Open the ./server/.env file
  2. Replace the value for LLM_API_KEY to be your own OpenAI API key.
  3. Replace the value for OPENAI_API_KEY to be your own OpenAI API key.

Start docker container services needed for local dev

cat .env.chat .env.search .env.server .env.docker-compose > .env

./convenience.sh -l
# or 
COMPOSE_PROFILE=dev docker compose up 

Start services for local dev

We know this is bad. Currently, We recommend managing this through tmux or VSCode terminal tabs.

cd server
cargo watch -x run
cd search
yarn
yarn dev
cd chat
yarn
yarn dev

Local development with Windows

Install NodeJS and Yarn

You can download the latest version NodeJS from here. Open the downloaded file and follow the steps from the installer.

After completing the installation, open a powershell with administrator permissions.

npm install -g yarn

After installation, yarn might throw an error when used due to Window's execution policy. Change the execution policy to allow scripts to be executed by applications that are signed by a trusted publisher by putting this command in an admin powershell.

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

Install Rust

You can download the latest version of Rust from here. Follow the installer's directions and install the prerequisites.

After installation, open a new powershell window with administrator permissions.

cargo install cargo-watch

Install Docker

Follow the instructions to download Docker Desktop for Windows from here. You may need to follow the instructions to enable WSL 2.

Install Postgres dependencies for building

Download PostgreSQL 13 from here. You should not use any other version of PostgreSQL due to there being an issue with diesel on other versions.

When installing, ensure that the PostgreSQL server is set to a port other than 5432 to prevent it from interfering with the docker container.

Add Postgres to PATH

[Environment]::SetEnvironmentVariable("PATH", $Env:PATH + ";C:\Program Files\PostgreSQL\13\lib;C:\Program Files\PostgreSQL\13\bin", [EnvironmentVariableTarget]::Machine)

Setup env's

cp .env.chat ./chat/.env
cp .env.search ./search/.env
cp .env.server ./server/.env

Add your LLM_API_KEY to ./server/.env

Here is a guide for acquiring that.

Steps once you have the key

  1. Open the ./server/.env file
  2. Replace the value for LLM_API_KEY to be your own OpenAI API key.
  3. Replace the value for OPENAI_API_KEY to be your own OpenAI API key.

Start Docker containers

Start the docker containers using the batch script.

Get-Content .env.chat, .env.search, .env.server, .env.docker-compose | Set-Content .env
./convenience.bat l

Start services for local dev

You need 3 different windows of powershell or use something like VSCode terminal tabs to manage it.

cd server
cargo watch -x run
cd search
yarn
yarn dev
cd chat
yarn
yarn dev

Install ImageMagick (Linux) - only needed if you want to use pdf_from_range route

apt install libjpeg-dev libpng-dev libtiff-dev

curl https://imagemagick.org/archive/ImageMagick.tar.gz | tar xz
cd ImageMagick
./configure
make uninstall
make install

How to debug diesel by getting the exact generated SQL

diesel::debug_query(&query).to_string();

Listen to Stripe events for billing

Install Stripe CLI.

  1. stripe login
  2. stripe listen --forward-to localhost:8090/api/stripe/webhook
  3. stripe plans create --amount=1200 --currency=usd --interval=month --product=prod_PCHehsNBCcVN9i

Deploying to Kubernetes

Ensure that the values.yaml contains the value

environment: local

Install docker-ce on your system. Use the following link to find the instructions:

https://docs.docker.com/engine/install/

Install kubectl on your system. Use the following link to get the binary:

https://kubernetes.io/releases/download/

Install virtualbox on your system. Downloads are accessible via the page below:

https://www.virtualbox.org/wiki/Downloads

Install minikube using the following resource:

https://minikube.sigs.k8s.io/docs/start/

Use the command:

minikube config set driver virtualbox

Now you can deploy a local kubernetes cluster to minikube:

minikube start --disk-size=50g

Deploy the registry addon using the include scripts

cd trieve
bash minikube/enable-registry.sh

Run the included script to launch socat to port forward the registry

cd trieve
bash minikube/launch-socat.sh

Now you can build the entire set of images in the project and deploy them to the local registry at localhost:5000

cd trieve
bash scripts/docker-build.sh

This may take a bit, but after the first build it becomes very quick to iterate on the docker images.

Once you have the docker images, you can now deploy the helm chart:

cd trieve/
helm install -f values.yaml trieve .

This deploys everything.

To make API calls to trieve/server, you can expose it as such:

minikube addons enable ingress
kubectl expose deployment server --type=NodePort --port=8080

Get the URL endpoint with:

minikube service server --url

Deploy to AWS

Get the AWS CLI tool using the instructions here:

https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html

Ensure you have a kubectl binary. Instructions to install are here:

https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html

Get a helm binary. Instructions to install are here:

https://docs.aws.amazon.com/eks/latest/userguide/helm.html

Run the command:

aws configure

Enter your account ID and region. Then, run the following command:

Get a eksctl binary using these instructions:

https://docs.aws.amazon.com/eks/latest/userguide/getting-started-eksctl.html

Add AWS Load Balancer Controller

Do this first:

cd aws/elb
bash create-policy.sh
bash create-iamserviceaccount.sh
cd ../../
helm repo add eks https://aws.github.io/eks-charts
helm repo update eks
cd aws/elb
bash install-chart.sh

Deploy cluster

Configure trieve/aws/eks/cluster.yaml to your needs, then ensure that you rename any references to the name included in the source tree for the cluster (it may be trieve-10 for example) to anything that is not taken. We can assume we are renaming trieve-10 to trieve for the relevant files. You can call the script to do this as so:

cd trieve/aws/eks
bash rename-cluster.sh trieve-10 trieve

Then you can create the cluster:

cd trieve/aws/eks
eksctl create-cluster -f cluster.yaml

This may take a while. Once finished, you can target this deployment with kubectl:

aws eks update-kubeconfig --name trieve

To actually deploy the chart to AWS, first you must do the necessary set up to ensure gp2 volume provisioning from EBS will work for the filesystem deployments.

The following commands only have to be run on an AWS account once. After these commands run you can destroy the cluster and make a new one but do not need to re-run them:

cd trieve/aws/eks
bash create-identity-provider.sh
cd ..
bash make-service-account.sh
bash make-trust-policy-file.sh
bash create-role.sh
bash attach-role.sh
bash annotate-service-account.sh
cd eks

After this set-up is complete, for any cluster you create you can run the command:

cd trieve/aws/eks
bash create-identity-provider.sh
bash add-driver.sh

Configure values.yaml and, assuming you want a mainnet deployment and are using us-east-2 for example, use the values:

environment: aws
accountId: <aws-account-id>
region: us-east-2

Now you can deploy the chart:

cd trieve/
helm install -f values.yaml trieve .

Now check your deployment!

kubectl describe pods

Building images and publishing to ECR

Use the steps in the above section to configure your AWS CLI tool, and ensure you have docker installed.

Run the script:

cd aws/dkr
bash login-docker.sh

Bump versions, if necessary, of any docker images that have been updated in values.yaml, specifically the tag property of each docker image referenced in the yaml file. The publish script included with trieve will attempt to build and publish every docker image used in the deployments using the tag from this yaml file (parsed with shyaml).

Now you can publish the images:

bash scripts/docker-build-eks.sh

Now you can upgrade the chart with the new images:

helm upgrade -f values.yaml trieve .

About

EXPERIMENTAL FORK OF TRIEVE -- USE WITH CAUTION

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 78.5%
  • Smarty 17.9%
  • PLpgSQL 3.2%
  • Other 0.4%