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

refactor: move the embedding to the rag module and abstract the rerank runner for extension #9423

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

hwzhuhao
Copy link
Contributor

@hwzhuhao hwzhuhao commented Oct 16, 2024

Checklist:

Important

Please review the checklist below before submitting your pull request.

  • Please open an issue before creating a PR or link to an existing issue
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Description

1.Add RerankRunnerFactory and BaseRerankRunner to simplify the creation logic of RerankRunner and enhance extensibility.
2.The core.embedding.cached_embedding depends on core.rag.datasource.entity.embedding, while core.rag.datasource.vdb relies on core.embedding.cached_embedding, creating a circular dependency.
3.Since the cached_embedding in the embedding package is only used by rag, move it to the rag module and reorganize it with the embedding_case module into a new package named embedding. This will make the structure clearer and the functionality more cohesive.
4.Rename embedding_constant to embedding_type. Since this module will be used by both model_runtime and rag, move it to core.entity.
After these changes, the embedding will mainly be used by rag, so moving it to the rag module will result in a clearer directory structure.
Scenario 1: Vector Search
rerank-1
rerank-2
rerank-3

Scenario 2: Hybrid Search
rerank-4
rerank-5
rerank-6

Fixes

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update, included: Dify Document
  • Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
  • Dependency upgrade

Testing Instructions

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

@hwzhuhao hwzhuhao changed the title refactor:move the embedding to the rag module and abstract the rerank runner for extension refactor: move the embedding to the rag module and abstract the rerank runner for extension Oct 16, 2024
@hwzhuhao hwzhuhao marked this pull request as ready for review October 17, 2024 02:30
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. 👻 feat:rag Embedding related issue, like qdrant, weaviate, milvus, vector database. 💪 enhancement New feature or request labels Oct 17, 2024
@crazywoola crazywoola requested a review from JohnJyong October 17, 2024 10:52
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 17, 2024
@JohnJyong JohnJyong merged commit b90ad58 into langgenius:main Oct 17, 2024
6 checks passed
lau-td pushed a commit to heydevs-io/dify that referenced this pull request Oct 23, 2024
idonotknow pushed a commit to AceDataCloud/Dify that referenced this pull request Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 enhancement New feature or request 👻 feat:rag Embedding related issue, like qdrant, weaviate, milvus, vector database. lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants