Difficult Time Deciding How to Structure Architecture

Oh great people of the internet. I have a problem I could use input on.

Let’s say I have several documents stored in an index for a user. These documents could be A, B, C and D. That user then has two different LangChain agents. They want those agents to have different knowledge stores related to those 4 documents. Imagine Agent 1 needs access to A, B and C documents and Agent 2 needs access to only C and D documents.

What’s the best way to do this? This is a simplified example as we will have many users, many documents and many agents so I’m looking for a solution that makes the most sense at scale.

Would it be best to:

  1. Use namespaces somehow to segregate?
  2. Use Meta Data that I can query on?
  3. Duplicate the Documents altogether and have each agent access its own copy?

There are various methods to achieve this goal.

My proposed solution involves fine-tuning a model specifically to generate accurate namespaces and metadata based on the input question.

The feedback loop could be the refine QA method langchain uses or the sequential method.
The only possible downside with this is the amount of token that you need to spend. The finetune models is of course a bit less expensive than gpt-4 so i would suggest you look down that road!
Fingers crosses for lower api prices at November 6 at dev day

Feel free to write and ask any question if you have some :slight_smile:

This has to be done without fine tuning. I’m not sure you’re fully understanding my question given your answer.

Do I group the documents by namespace, metadata, or making a vector copy for each agent to access?

Fair i though you had a basic understanding of how a vector database is working :slight_smile:

The finetuned model can be used to extract the namespace and metadata filter from the query. This way the agents would have a higher change of choosing the correct namespace, without the user have to state witch part of the index they want to retrieve the information from.

So i see no reason not to use this option if you end up having multiple namespaces.

It seems like you have different documents that contains information from different mediums, but without knowing the context of the document it is 100% impossible to give an answer… stating A, B and C gives us no basis to answer the question…

I recommend familiarizing yourself with the fundamentals of vector databases and the techniques for retrieving vectors from extensive datasets. :blush:

I understand vector databases. I work with them. Please let someone else answer who is able to understand my question.

My question purely relates to how to set up the vector labeling so that each bot has access ONLY to the information specified and NO OTHER vectors

Using metadata/filtering is fine for creating overlapping sub-sets of data that apply to different agents, assuming that each agent already knows which dataset is relevant.

You can specify the metadata filter at query time and Pinecone will limit the scope of the search based on that filter.

Where you’ll most likely end up with some complexity is around the indexing of content and keeping the metadata up to date, particularly if ad-hoc user actions drive changes that affect which data comes into or out of scope for an agent.

For example, I’m guessing you’ll find yourself wanting to do things like update a metadata flag for all vectors that match some other metadata filter, and that kind of thing is not supported in the API yet. Pretty much all of the management APIs are based on already having the IDs of the rows you want to make a change to. There are some workarounds to get those IDs, but things just might take a few more steps than you might expect.

Good luck, and let us know if we can be of any further help.

silas@ninetack.io

1 Like

Would it be best to apply metadata this way? Metadata would need to be changed as well. User 1 may decide, for example, to apply Bot 2 to vectors belonging to Document B at a later date. In this case we would need to update bots metadata for those vectors to be an array with [1,2] as the value.

Can you query metadata by values within a key/value array as shown?

You can query by metadata values with arrays and you can find the details here: Filtering with metadata

Just checking, in your example do the docs A, B, C, and D apply to all users?

Or are ABCD scoped to a single user, let’s call them User 1?
If User 2 comes along, would they have their own separate docs (EFGH) and different bot IDs that map to those EFGH docs?

1 Like

Correct User 2 would have their own data that would not be accessible to any of User 1’s bots

Got it, then I’d also suggest using namespaces to isolate user data (namespace per user). There are no limits to the number of namespaces you can create. That’ll make it easier to access and manage the data for a single user, and is conceptually pretty easy to reason about as you develop your app.

Won’t the index per user be enough to separate?

Oh you’re creating a separate index per user? That could get very expensive depending on the number of users and depending on how much your users are paying you for your service. Minimum $70 per index per month.

The main reason to deploy separate indexes are if you need to store vectors with different dimensions or use a different similarity metric (cosine vs. euclidean, etc.).

Got it! So we would use one index. What would be a reason of needing documents to have differing dimensions? Documents with differing data structures like CSV? Also, if you’re open to a contract role I’d be happy to talk about paying for your time.

Happy to chat more about your use case. Feel free to send me an email silas@ninetack.io

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.