# Inability to Determine the Breakpoint between s1 and s2 due to Current Windowing Logic

**URL:** <https://forum.langchain.com/t/inability-to-determine-the-breakpoint-between-s1-and-s2-due-to-current-windowing-logic/3148>\
**Category:** LangChain\
**Tags:** python-help\
**Created:** [March 12, 2026, 6:20pm UTC](https://forum.langchain.com/t/inability-to-determine-the-breakpoint-between-s1-and-s2-due-to-current-windowing-logic/3148 "2026-03-12T18:20:11Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![OnAnd0n](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/onand0n/32/2444_2.png) [@OnAnd0n](https://forum.langchain.com/u/OnAnd0n)\
**Post date:** [March 12, 2026, 6:20pm UTC](https://forum.langchain.com/t/inability-to-determine-the-breakpoint-between-s1-and-s2-due-to-current-windowing-logic/3148/1 "2026-03-12T18:20:11Z")

</div>

![553121263-9fb637bf-8ac7-4302-8b67-65f2a929dd34](https://canada1.discourse-cdn.com/flex007/uploads/langchain/original/2X/3/3db7c7b6c037c9b68094326a00144a3bf4adefb1.png)

so, I have just opened an issue on GitHub.  
Could you please take a look when you have a moment?

[https://github.com/langchain-ai/langchain-experimental/issues/73](https://issue-link)

---

<div class="post-metadata">

**Author:** ![keenborder786](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/keenborder786/32/1757_2.png) [@keenborder786](https://forum.langchain.com/u/keenborder786)\
**Post date:** [March 12, 2026, 10:10pm UTC](https://forum.langchain.com/t/inability-to-determine-the-breakpoint-between-s1-and-s2-due-to-current-windowing-logic/3148/2 "2026-03-12T22:10:14Z")

</div>

@OnAnd0n I did check your proposed solution and problem that you have identified.

Why don’t we `make combine_sentences` use a **fixed-size window with edge padding** (clamp or reflect indices), instead of shrinking windows at document boundaries.

It removes the start/end “dead-zone” bias. Also, It keeps embedding calls at n (same as now), so runtime/cost stays nearly identical. Plus It’s a small, local change in one function.

---

<div class="post-metadata">

**Author:** ![OnAnd0n](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/onand0n/32/2444_2.png) [@OnAnd0n](https://forum.langchain.com/u/OnAnd0n)\
**Post date:** [March 14, 2026, 4:27pm UTC](https://forum.langchain.com/t/inability-to-determine-the-breakpoint-between-s1-and-s2-due-to-current-windowing-logic/3148/3 "2026-03-14T16:27:49Z")

</div>

@keenborder786  
Thank you for the clamping suggestion.  
unfortunately, I found that the issue of failing to separate s1 and s2 still persists even after applying the clamping method.  
But, By applying the Disjoint Context Comparison approach alongside your suggested Clamping method, we can effectively address the boundary detection issues at the start of the document.

While Clamping ensures a stable window size, combining it with a Disjoint approach eliminates Inclusion Bias by isolating the information at each boundary.

Here is how the combined logic works with a buffer\_size of 2:

Boundary 0 (s1 | s2):  
Left (Pre): {s1, s1} (Clamping applied)  
Right (Post): {s2, s3}

Boundary 1 (s2 | s3):  
Left (Pre): {s1, s2}  
Right (Post): {s3, s4}

Boundary 2 (s3 | s4):  
Left (Pre): {s2, s3}  
Right (Post): {s4, s5}

Boundary 3 (s4 | s5):  
Left (Pre): {s3, s4}  
Right (Post): {s5, s6}

Boundary 4 (s5 | s6):  
Left (Pre): {s4, s5}  
Right (Post): {s6, s6} (Clamping applied)

By integrating these two approaches, we can accurately capture the semantic shifts between s1 and s2.  
Furthermore, since each sentence is embedded only once, the computational overhead and costs are significantly reduced.

Applied Methods

1. Clamping: Ensures stable window sizes at the document edges.
2. Disjoint Context Comparison: Eliminates overlap bias by isolating pre- and post-context windows.

Modified Functions

1. \_calculate\_sentence\_distances: Updated to implement the Disjoint and Clamping logic.
2. calculate\_cosine\_distances: Refactored to handle the refined distance metrics.

Deprecated Function

- combine\_sentences: This function is no longer used as the logic has been shifted to a more efficient vector-based mean pooling.

---

<div class="post-metadata">

**Author:** ![OnAnd0n](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/onand0n/32/2444_2.png) [@OnAnd0n](https://forum.langchain.com/u/OnAnd0n)\
**Post date:** [March 14, 2026, 4:32pm UTC](https://forum.langchain.com/t/inability-to-determine-the-breakpoint-between-s1-and-s2-due-to-current-windowing-logic/3148/4 "2026-03-14T16:32:10Z")

</div>

@keenborder786

I am attaching an image showing the improved results after applying the proposed logic.

 ![semantic_chunking_20260315](https://canada1.discourse-cdn.com/flex007/uploads/langchain/original/2X/d/d491355e3c28b2b9baac3f87ad7a6699d6c01a47.png)

Would it be okay to proceed with the Pull Request (PR) in this manner?  
Also, could you recommend whom I should tag or request for a review?  
(I am mindful that github-maintainers all have very busy schedules and want to ensure the PR is directed to the right person so it doesn’t get overlooked.)

---

<div class="post-metadata">

**Author:** ![keenborder786](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/keenborder786/32/1757_2.png) [@keenborder786](https://forum.langchain.com/u/keenborder786)\
**Post date:** [March 17, 2026, 6:42am UTC](https://forum.langchain.com/t/inability-to-determine-the-breakpoint-between-s1-and-s2-due-to-current-windowing-logic/3148/5 "2026-03-17T06:42:09Z")

</div>

Excellent, yes you can open a PR in here [GitHub - langchain-ai/langchain-community: Community-maintained LangChain integrations · GitHub](https://github.com/langchain-ai/langchain-community) and mention @mdrxy

---

<div class="post-metadata">

**Author:** ![keenborder786](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/keenborder786/32/1757_2.png) [@keenborder786](https://forum.langchain.com/u/keenborder786)\
**Post date:** [March 17, 2026, 6:43am UTC](https://forum.langchain.com/t/inability-to-determine-the-breakpoint-between-s1-and-s2-due-to-current-windowing-logic/3148/6 "2026-03-17T06:43:48Z")

</div>

Also if possible @OnAnd0n can you mark your reply as a solution as it helps the community.

---

<div class="post-metadata">

**Author:** ![OnAnd0n](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/onand0n/32/2444_2.png) [@OnAnd0n](https://forum.langchain.com/u/OnAnd0n)\
**Post date:** [March 17, 2026, 10:51am UTC](https://forum.langchain.com/t/inability-to-determine-the-breakpoint-between-s1-and-s2-due-to-current-windowing-logic/3148/7 "2026-03-17T10:51:15Z")

</div>

> [@keenborder786](#):
>
> Excellent, yes you can open a PR in here [GitHub - langchain-ai/langchain-community: Community-maintained LangChain integrations · GitHub](https://github.com/langchain-ai/langchain-community) and mention

Thank you for the guidance!!!  
Just to double-check, my changes are currently within the **`langchain-experimental`** package. Should I still open the PR in the **`langchain-community`** repository, or was that a link for the experimental repo?

---

<div class="post-metadata">

**Author:** ![keenborder786](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/keenborder786/32/1757_2.png) [@keenborder786](https://forum.langchain.com/u/keenborder786)\
**Post date:** [March 17, 2026, 1:33pm UTC](https://forum.langchain.com/t/inability-to-determine-the-breakpoint-between-s1-and-s2-due-to-current-windowing-logic/3148/8 "2026-03-17T13:33:29Z")

</div>

Oh yes, open it in langchain-experimental package.

---

<div class="post-metadata">

**Author:** ![OnAnd0n](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/onand0n/32/2444_2.png) [@OnAnd0n](https://forum.langchain.com/u/OnAnd0n)\
**Post date:** [April 12, 2026, 3:01pm UTC](https://forum.langchain.com/t/inability-to-determine-the-breakpoint-between-s1-and-s2-due-to-current-windowing-logic/3148/9 "2026-04-12T15:01:05Z")

</div>

@keenborder786  
There hasn’t been any progress on PRs in `langchain-experimental` at all.  
In this case, where or whom should I reach out to?

---

<div class="post-metadata">

**Author:** ![keenborder786](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/keenborder786/32/1757_2.png) [@keenborder786](https://forum.langchain.com/u/keenborder786)\
**Post date:** [April 13, 2026, 11:13am UTC](https://forum.langchain.com/t/inability-to-determine-the-breakpoint-between-s1-and-s2-due-to-current-windowing-logic/3148/10 "2026-04-13T11:13:20Z")

</div>

@OnAnd0n you can reach out to @mdrxy or tag him in your PR.
