GithubHelp home page GithubHelp logo

Comments (4)

dosubot avatar dosubot commented on June 4, 2024 2

πŸ€–

Hello @araza110! πŸš€

I'm Dosu, your friendly neighborhood bot. While human maintainers are busy saving the world, I'm here to assist you with bugs, answer your questions, and help you become a stellar contributor. Let's get those vector counts aligning, shall we? πŸ˜‰πŸ‘Ύ

The discrepancy in the number of vectors between your NestJS implementation and the original code could be due to several factors. Here are a few possibilities:

  1. Different Text Splitting Parameters: The RecursiveCharacterTextSplitter is used to split the text into chunks. If the chunkSize and chunkOverlap parameters are different in your NestJS implementation, this could result in a different number of vectors. In your code, you've set chunkSize to 1000 and chunkOverlap to 200. If these values are different in the original code, it could explain the discrepancy.

  2. Different Document Loaders: The method you use to load the PDF files could also affect the number of vectors. If your NestJS implementation uses a different method to load the PDF files, it could result in a different number of vectors.

  3. Different Embedding Method: The OpenAIEmbeddings is used to create embeddings from the split text. If your NestJS implementation uses a different method to create embeddings, it could result in a different number of vectors.

Without more information, it's impossible to provide a more specific answer. Could you please provide the original code and the specific parameters used there? This would help in diagnosing the issue more accurately.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a πŸ‘ if this is helpful and πŸ‘Ž if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

from gpt4-pdf-chatbot-langchain.

dosubot avatar dosubot commented on June 4, 2024 2

Hi, @araza110,

I'm helping the gpt4-pdf-chatbot-langchain team manage their backlog and am marking this issue as stale. The issue involves a discrepancy in the number of vectors stored when ingesting PDF documents into a Pinecone database using a NestJS application. It seems that the discrepancy has been resolved, with potential factors contributing to the issue identified and addressed. Additionally, a detailed explanation of the textSplitter and textKey parameters was provided to help achieve consistency in the number of vectors generated.

Could you please confirm if this issue is still relevant to the latest version of the gpt4-pdf-chatbot-langchain repository? If it is, please let the gpt4-pdf-chatbot-langchain team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days. Thank you!

from gpt4-pdf-chatbot-langchain.

araza110 avatar araza110 commented on June 4, 2024

Hi,@dosbut Please explain this code block

  const textSplitter = new RecursiveCharacterTextSplitter({
        chunkSize: 1000,
        chunkOverlap: 200,
      });

Also what is textKey?

 await PineconeStore.fromDocuments(docs, embeddings, {
        pineconeIndex: index,
        namespace,
        textKey: 'text',
      });

from gpt4-pdf-chatbot-langchain.

jkobb510 avatar jkobb510 commented on June 4, 2024

@araza110 textSplitter splits PDF documents into smaller parts called "chunks".
chunkSize - each chunk should have a maximum of 1000 characters.
chunkOverlap - how much overlap there should be between adjacent chunks (200 characters)

say we load a document containing:

"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae mauris nec nisl imperdiet placerat. Nullam in semper velit. Phasellus congue varius felis, in efficitur tellus tempor sit amet. Duis mollis tincidunt ex, ac feugiat metus consectetur ut. Sed tincidunt lacus sed felis fringilla, eu blandit massa ullamcorper. Aliquam pulvinar, nisl eu consectetur dignissim, mi erat fermentum sapien, eu ultrices turpis lectus a nunc."

const rawDocs = await directoryLoader.load();

const textSplitter = new RecursiveCharacterTextSplitter({
  chunkSize: 1000,
  chunkOverlap: 200,
});

const docs = await textSplitter.splitDocuments(rawDocs);
console.log('split docs', docs);

We get:

[
  "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae mauris nec nisl imperdiet placerat. Nullam in semper velit. Phasellus congue varius felis, in efficitur tellus tempor sit amet. Duis mollis tincidunt ex, ",
  "ac feugiat metus consectetur ut. Sed tincidunt lacus sed felis fringilla, eu blandit massa ullamcorper. Aliquam pulvinar, nisl eu consectetur dignissim, mi erat fermentum sapien, eu ultrices turpis lectus a nunc."
]

For:

await PineconeStore.fromDocuments(docs, embeddings, {
  pineconeIndex: index,
  namespace,
  textKey: 'text',
});

textKey tells the code which part of each document should be used for generating embeddings. In this case, it expects each element in the docs array to have a property called 'text'. Each document object has a text property containing the text to be used for generating embeddings.

{ 
    text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae mauris nec nisl imperdiet placerat. Nullam in semper velit. Phasellus congue varius felis, in efficitur tellus tempor sit amet. Duis mollis tincidunt ex, ", 
    text:  "ac feugiat metus consectetur ut. Sed tincidunt lacus sed felis fringilla, eu blandit massa ullamcorper. Aliquam pulvinar, nisl eu consectetur dignissim, mi erat fermentum sapien, eu ultrices turpis lectus a nunc."
};

from gpt4-pdf-chatbot-langchain.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.