Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pprados/rag vectorstore #13910

Open
wants to merge 70 commits into
base: master
Choose a base branch
from

Conversation

pprados
Copy link
Contributor

@pprados pprados commented Nov 27, 2023

Description:
The ParentDocumentRetriever class provides the add_documents() methods, which may seem unconventional for a retriever.

This deviation arises from the need to establish and maintain connections between document fragments and their various iterations. Consequently, the parent_splitter and child_splitter were introduced. As elaborated in this pull request, it's crucial not to confine oneself to text splitters exclusively. Instead, a preference is given to working with transformations, from which text splitters inherit.

However, my initial proposal proved insufficient to fully leverage this concept with all the advanced features of Langchain. An issue has been raised to address this limitation.

To enhance text selection, the proposed idea by ParentDocumentRetriever is as follows:

  • Convert each text fragment into multiple versions to enhance proximity between questions and potential answers.
  • Select corresponding fragments in the vector store.
  • Return the original fragment for injection into the prompt.

For this purpose, maintaining a link between the original document, each document chunk, and every transformation
applied to each chunk is essential.

My Proposition:
The RagVectorStore class serves as a vector store wrapper with rules for transforming a document
into a chunk and each chunk into different versions. It closely resembles ParentRetriever but employs
a VectorStore instead of a Retriever.

This approach is advantageous due to its simplicity and compatibility with all advanced features of Langchain.
Feel free to explore the benefits of this solution in this notebook.

Compatibility includes:

The implementation required several changes and additional pull requests, each of which can be validated independently before merging into this one:

Issues:

Dependencies:
Any dependencies required for this change.

Tag Maintainers:
@baskaryan @hwchase17

Twitter Handle:
Twitter account: pprados

pprados and others added 30 commits November 23, 2023 11:46
<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.

See contribution guidelines for more information on how to write/run
tests, lint, etc:

https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->
To the in-memory outputs. Separate it out from the outputs so it's
present in the dataframe.describe() results
Changes:
- remove langchain_core/schema since no clear distinction b/n schema and
non-schema modules
- make every module that doesn't end in -y plural
- where easy have 1-2 classes per file
- no more than one level of nesting in directories
- only import from top level core modules in langchain
- **Description:** We need to update the Dockerfile for templates to
also copy your README.md. This is because poetry requires that a readme
exists if it is specified in the pyproject.toml
Upgrade langserve template version to 0.0.30 to include new improvements
Adds a cookbook for semi-structured RAG via Docugami. This follows the
same outline as the semi-structured RAG with Unstructured cookbook:
https://github.com/langchain-ai/langchain/blob/master/cookbook/Semi_Structured_RAG.ipynb

The main change is this cookbook uses Docugami instead of Unstructured
to find text and tables, and shows how XML markup in the output helps
with retrieval and generation.

We are \@docugami on twitter, I am \@tjaffri

---------

Co-authored-by: Taqi Jaffri <tjaffri@docugami.com>
Fix some circular deps:
- move PromptValue into top level module bc both PromptTemplates and
OutputParsers import
- move tracer context vars to `tracers.context` and import them in
functions in `callbacks.manager`
- add core import tests
Provider check was incorrectly failing for anything other than "meta"
- Adds pydantic/import linting to core
- Adds a check for `langchain_experimental` imports to langchain
…ate(...) (langchain-ai#13645)

**Description:** BaseStringMessagePromptTemplate.from_template was
passing the value of partial_variables into cls(...) via **kwargs,
rather than passing it to PromptTemplate.from_template. Which resulted
in those *partial_variables being* lost and becoming required
*input_variables*.

Co-authored-by: Josep Pon Farreny <josep.pon-farreny@siemens.com>
Co-authored-by: Bagatur <baskaryan@gmail.com>
…-ai#13626)

**Description:** Currently, if we pass in a ToolMessage back to the
chain, it crashes with error

`Got unsupported message type: `

This fixes it. 

Tested locally

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
- **Description:** add method embed_general_texts in VoyageEmebddings to
support input_type
  - **Issue:** 
  - **Dependencies:** 
  - **Tag maintainer:** 
  - **Twitter handle:** @Voyage_AI_
…3652)

- **Description:** This commit fixed the problem that Redis vector store
will change the value of a metadata from 0 to empty when saving the
document, which should be an un-intended behavior.
  - **Issue:** N/A
  - **Dependencies:** N/A
Co-authored-by: Lance Martin <lance@langchain.dev>
Copy link

vercel bot commented Nov 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2023 5:08pm

@pprados pprados marked this pull request as ready for review November 27, 2023 17:12
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. Ɑ: vector store Related to vector store module 🤖:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features labels Nov 27, 2023
@pprados
Copy link
Contributor Author

pprados commented Dec 1, 2023

@hwchase17
I think you're the author of ParentDocumentRetriever.
This PR proposes an improvement on this approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features size:XXL This PR changes 1000+ lines, ignoring generated files. Ɑ: vector store Related to vector store module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet