#RAG

1 messages · Page 1 of 1 (latest)

hoary osprey
#

Hey guys, I am using RAG to retrieve information from a Pinecone DB and then generate a response with llama3. The vector DB contains information about certain tasks that need to be completed but also unrelevant chats. Each embedding contains metadata about the message, timestamp, userid, and username.

If I want to provide additional information about the project behind those tasks, so the LLM can better understand which tasks are linked to what, where should I store this information? Should I create another vector database and provide the content additionally as project background, or should I upload it to the existing vector database? The existing one contains not only tasks but also chat logs between people, so information that could be wrong.

For example, I would like the llm to know which employee positions there are, e.g. developer, supporter, and what their tasks in general are. When a task is written in the chat, the llm should understand the connection between the role and the task.

quartz copperBOT
#

Hi @hoary osprey. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information provided in the knowledge sources, there are a few ways you could approach this.

One way is to use a graph database like Neo4j, as described in the RAG with a Graph database (https://cookbook.openai.com/examples/rag_with_graph_db) example. Graph databases are particularly useful when relationships between data points are important. In your case, you could create nodes for tasks, employees, and roles, and then create relationships between these nodes. This would allow the LLM to understand the connections between roles and tasks.

Another approach is to include the additional project information in your existing vector database. You could create embeddings for the project background information and store them in the same vector database as your tasks and chat logs. This would allow the LLM to retrieve this information when generating a response. However, you would need to ensure that your retrieval mechanism is able to distinguish between task-related information and chat logs, as well as between different projects if you have more than one.

In both cases, you would use the text-embedding-3-small model to create dense vector embeddings for your data, as described in the Building a Knowledge Base (https://cookbook.openai.com/examples/vector_databases/pinecone/gen_qa#building-a-knowledge-base) section of the Pinecone example. These embeddings are numerical representations of the meaning behind your sentences, which allows the LLM to retrieve information that is semantically related to your queries.

Here's an example of how you could create an embedding for a piece of text:

embed_model = "text-embedding-ada-002"

res = openai.Embedding.create(
 input=[
 "Sample document text goes here",
 "there will be several phrases in each batch"
 ], engine=embed_model
)
#

In the end, the choice between these approaches depends on your specific use case and the nature of your data. You might also want to consider factors such as the size of your data, the complexity of the relationships between your data points, and the resources available to you.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@hoary osprey kapa.ai is still learning and improving, please let us know how it did by reacting below

hoary osprey
#

@quartz copper So could i just use the same vector db, make a metadata tag like: "project_data"
And if this is yes all this information is handled as the real correct information and every embedding without is based on the project_data embedding.

For exapmle 1 project data embeddings explains the different jobs and their general tasks.

Now if someone writes another task for the job but its wrong it will check if its project_data and if yes it will use it as its knoledge about the project and if not it doesnt?

Or is the graph database approach better?

quartz copperBOT
#

Let me check the knowledge base for you. One moment! :books:

#

Yes, you could certainly use the same vector database and add a metadata tag like "project_data" to distinguish the project information from other data. This approach would allow you to store all your data in one place, and you could use the metadata tag to filter your data during retrieval.

For example, when you're creating an embedding for a piece of project information, you could do something like this:

# Create an embedding for a piece of project information
project_info = "Developers are responsible for writing code."
project_info_embedding = openai.Embedding.create(input=[project_info], engine="text-embedding-ada-002")

# Store the embedding in your vector database with a "project_data" metadata tag
vector_db.insert(id="project_info_1", vector=project_info_embedding, metadata={"type": "project_data"})

Then, when you're retrieving information, you could filter your results based on the metadata tag:

# Retrieve information related to a query
query = "What are developers responsible for?"
query_embedding = openai.Embedding.create(input=[query], engine="text-embedding-ada-002")
results = vector_db.query(query_embedding, filter={"type": "project_data"})

This would ensure that only the project information is used to answer the query.

However, while this approach would work for simple use cases, it might not be sufficient if you have complex relationships between your data points. In that case, a graph database might be a better choice. With a graph database, you can explicitly model the relationships between tasks, roles, and employees, which could provide more accurate and nuanced responses.

#

Ultimately, the choice between these approaches depends on your specific use case and the nature of your data. You might want to experiment with both approaches and see which one works best for you.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: