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

error while using SemanticChunking #1722

Open
mstrYoda opened this issue Jan 8, 2025 · 1 comment
Open

error while using SemanticChunking #1722

mstrYoda opened this issue Jan 8, 2025 · 1 comment

Comments

@mstrYoda
Copy link

mstrYoda commented Jan 8, 2025

While using SemanticChunking it gives the following error: ValueError: Failed to load embeddings via SentenceTransformerEmbeddings: SentenceTransformer.__init__() got an unexpected keyword argument 'similarity_threshold'

It is due to chonkie library has no similarity_threshold param, instead (I guess) it uses similarity_window.

class SemanticChunking(ChunkingStrategy):
    """Chunking strategy that splits text into semantic chunks using chonkie"""

    def __init__(
        self, embedder: Optional[Embedder] = None, chunk_size: int = 5000, similarity_threshold: Optional[float] = 0.5
    ):
        self.embedder = embedder or OpenAIEmbedder(model="text-embedding-3-small")
        self.chunk_size = chunk_size
        self.similarity_threshold = similarity_threshold
        self.chunker = SemanticChunker(
            embedding_model=self.embedder.model,  # type: ignore
            chunk_size=self.chunk_size,
            similarity_threshold=self.similarity_threshold, # this line gives error
        )

image

@manthanguptaa
Copy link
Contributor

Hey @mstrYoda good catch. The correct param is threshold here. I will make a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants