Bumps [sentence-transformers](https://github.com/huggingface/sentence-transformers) from 5.2.3 to 5.6.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/huggingface/sentence-transformers/releases">sentence-transformers's releases</a>.</em></p> <blockquote> <h2>v5.6.0 - Fixes for Causal LM Rerankers, Hard-Negative Mining, and More</h2> <p>This minor version is a correctness- and robustness-focused release. It fixes a silent scoring bug for causal-LM rerankers, corrects several hard-negative mining and GIST loss edge cases, restores TSDAE on <code>transformers</code> v5, and adds Apple Silicon (MPS) support for the cached losses.</p> <p>The headline fix affects chat-template models that read the final token position, i.e. causal-LM rerankers (like <code>Qwen3-Reranker</code>) and last-token-pooling embedders: when an over-long input was truncated, the chat template's trailing suffix (e.g. the assistant prefill the model scores from) was silently dropped, producing wrong scores with no error. There's also a forward-looking deprecation: loading local custom code without <code>trust_remote_code=True</code> now warns, and will require it from v6.0.</p> <p>Install this version with</p> <pre lang="bash"><code># Training + Inference pip install sentence-transformers[train]==5.6.0 <h1>Inference only, use one of:</h1> <p>pip install sentence-transformers==5.6.0 pip install sentence-transformers[onnx-gpu]==5.6.0 pip install sentence-transformers[onnx]==5.6.0 pip install sentence-transformers[openvino]==5.6.0</p> <h1>Multimodal dependencies (optional):</h1> <p>pip install sentence-transformers[image]==5.6.0 pip install sentence-transformers[audio]==5.6.0 pip install sentence-transformers[video]==5.6.0</p> <h1>Or combine as needed:</h1> <p>pip install sentence-transformers[train,onnx,image]==5.6.0 </code></pre></p> <h2>Fixed silently wrong scores when truncation drops chat-template suffixes (<a href="https://redirect.github.com/huggingface/sentence-transformers/issues/3787">#3787</a>)</h2> <p>Chat-template models render the full conversation to a flat string before tokenizing, so when the rendered input is longer than the tokenizer's <code>model_max_length</code>, the tokenizer truncates it from the right and drops the template's trailing suffix: the fixed tokens a template appends <em>after</em> the content, e.g. a prompt, instruction, <code>[/INST]</code>, or a trailing EOS. For models that read the final token position, this silently corrupted the result:</p> <ul> <li>causal-LM rerankers (e.g. <code>Qwen/Qwen3-Reranker-0.6B</code>) score a pair from the last token's <code>yes</code>/<code>no</code> logits, and</li> <li>last-token-pooling embedders read the final hidden state.</li> </ul> <p>When the suffix was truncated away, that final position landed mid-document instead of after the prefill, so the score or embedding came from the wrong place.</p> <p><code>Transformer.preprocess</code> now detects when truncation drops the suffix and splices it back onto the tail of each truncated row. Because the fix lives in the shared base <code>Transformer</code>, it applies across <code>SentenceTransformer</code>, <code>CrossEncoder</code>, and <code>SparseEncoder</code>. It's enabled by default and saved to the model configuration. Pass <code>processing_kwargs={"chat_template": {"restore_suffix": False}}</code> to opt back into raw truncation.</p> <h2>Hard-negative mining and GIST loss correctness (<a href="https://redirect.github.com/huggingface/sentence-transformers/issues/3821">#3821</a>, <a href="https://redirect.github.com/huggingface/sentence-transformers/issues/3817">#3817</a>, <a href="https://redirect.github.com/huggingface/sentence-transformers/issues/3816">#3816</a>)</h2> <p>A trio of correctness and scalability fixes for hard-negative mining and the GIST losses:</p> <ul> <li>Sign-independent relative margin: <code>mine_hard_negatives(relative_margin=...)</code> and the <code>margin_strategy="relative"</code> branch of <code>GISTEmbedLoss</code> / <code>CachedGISTEmbedLoss</code> used a multiplicative threshold (<code>positive * (1 - margin)</code>) that only behaves correctly when the positive-pair similarity is positive. When that similarity was negative, the threshold moved the wrong way and let through false negatives: candidates <em>more</em> similar to the anchor than the true positive. The threshold is now <code>positive - |positive| * margin</code>, identical to before for positive scores but correct for negative ones.</li> <li>Distributed positive masking in the GIST losses: with <code>gather_across_devices=True</code> and a non-zero <code>margin</code>, the false-negative suppression mask protected the wrong columns on ranks beyond the first (it ignored the per-rank offset into the gathered batch), which set the true positive's logit to <code>-inf</code> and produced a <code>+inf</code> loss. The mask now accounts for the cross-rank offset, so multi-GPU GIST training stays finite.</li> <li>Memory-bounded mining without FAISS: <code>mine_hard_negatives(use_faiss=False)</code> (the default) materialized the full <code>(queries × corpus)</code> similarity matrix at once, which could OOM on large corpora. It now batches over the query axis (controlled by <code>faiss_batch_size</code>, default 16384), bounding peak memory while producing identical results.</li> </ul> <h2>TSDAE weight tying restored on <code>transformers</code> v5 (<a href="https://redirect.github.com/huggingface/sentence-transformers/issues/3781">#3781</a>)</h2> <p><code>transformers</code> v5 removed the private <code>PreTrainedModel._tie_encoder_decoder_weights</code> helper that <code>DenoisingAutoEncoderLoss</code> (TSDAE) used to tie its separate encoder and decoder. As a stopgap, v5.5 raised a <code>RuntimeError</code> for the default <code>tie_encoder_decoder=True</code> on <code>transformers >= 5.0.0</code>, effectively breaking TSDAE there unless you pinned an older <code>transformers</code> or disabled tying. TSDAE now ships its own tying routine that shares storage between encoder and decoder, so it works on both <code>transformers</code> <5 and >=5 with the default settings.</p> <h2>Deprecation: loading local custom code without <code>trust_remote_code</code> (<a href="https://redirect.github.com/huggingface/sentence-transformers/issues/3807">#3807</a>)</h2> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/huggingface/sentence-transformers/commit/9c73df3143e97598938a1640d737d3f0f11878e5"><code>9c73df3</code></a> Release v5.6.0</li> <li><a href="https://github.com/huggingface/sentence-transformers/commit/222b0529b93b15f191b6f86b25350be4d226361e"><code>222b052</code></a> [fix] Don't override device_map placement with the device argument (<a href="https://redirect.github.com/huggingface/sentence-transformers/issues/3823">#3823</a>)</li> <li><a href="https://github.com/huggingface/sentence-transformers/commit/a38a6bf16f50347c100c515fed64e2d8e75bf290"><code>a38a6bf</code></a> Fix causal LM reranker scoring when max_length truncates chat-template suffix...</li> <li><a href="https://github.com/huggingface/sentence-transformers/commit/18121031ece5ad8f4676127c6693f517c113782a"><code>1812103</code></a> [fix] Make relative margin sign-independent in mining and GIST losses (<a href="https://redirect.github.com/huggingface/sentence-transformers/issues/3821">#3821</a>)</li> <li><a href="https://github.com/huggingface/sentence-transformers/commit/ae1acc3fb2aa2004577b297eb4a915ce7a03316a"><code>ae1acc3</code></a> Warn when loading local custom code without trust_remote_code (<a href="https://redirect.github.com/huggingface/sentence-transformers/issues/3807">#3807</a>)</li> <li><a href="https://github.com/huggingface/sentence-transformers/commit/429cf5d424869c7aba629ded61e93b2788921677"><code>429cf5d</code></a> [fix] Support MPS in the cached losses' RandContext (<a href="https://redirect.github.com/huggingface/sentence-transformers/issues/3812">#3812</a>)</li> <li><a href="https://github.com/huggingface/sentence-transformers/commit/77fdbfff17c476190f3bb09436e91280fe27b247"><code>77fdbff</code></a> [<code>fix</code>] fix <code>MPS</code> errors (<a href="https://redirect.github.com/huggingface/sentence-transformers/issues/3818">#3818</a>)</li> <li><a href="https://github.com/huggingface/sentence-transformers/commit/bfba988a1ebc5717b7c52af597e43dba86b4a590"><code>bfba988</code></a> [fix] Fix positive masking in GIST losses with multi-GPU + gather_across_devi...</li> <li><a href="https://github.com/huggingface/sentence-transformers/commit/29e382b56077f5ade739737d14878357345b4e7e"><code>29e382b</code></a> [<code>docs</code>] Fix doc build problems (part 1) (<a href="https://redirect.github.com/huggingface/sentence-transformers/issues/3811">#3811</a>)</li> <li><a href="https://github.com/huggingface/sentence-transformers/commit/d16e6bfacf5b00143a93d007fbb711d8095b297b"><code>d16e6bf</code></a> [fix] Avoid materializing the full similarity matrix in mine_hard_negatives w...</li> <li>Additional commits viewable in <a href="https://github.com/huggingface/sentence-transformers/compare/v5.2.3...v5.6.0">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/langchain-ai/langchain/network/alerts). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
The agent engineering platform.
LangChain is a framework for building agents and LLM-powered applications. It helps you chain together interoperable components and third-party integrations to simplify AI application development — all while future-proofing decisions as the underlying technology evolves.
Tip
Just getting started? Check out Deep Agents — a higher-level package built on LangChain for agents that have built-in capabilities for common usage patterns such as planning, subagents, file system usage, and more.
Quickstart
uv add langchain
from langchain.chat_models import init_chat_model
model = init_chat_model("openai:gpt-5.5")
result = model.invoke("Hello, world!")
If you're looking for more advanced customization or agent orchestration, check out LangGraph, our framework for building controllable agent workflows.
For an equivalent JS/TS library, check out LangChain.js.
Tip
For developing, debugging, and deploying AI agents and LLM applications, see LangSmith.
LangChain ecosystem
While the LangChain framework can be used standalone, it also integrates seamlessly with any LangChain product, giving developers a full suite of tools when building LLM applications.
- Deep Agents — Build agents that can plan, use subagents, and leverage file systems for complex tasks
- LangGraph — Build agents that can reliably handle complex tasks with our low-level agent orchestration framework
- Integrations — Chat & embedding models, tools & toolkits, and more
- LangSmith — Agent evals, observability, and debugging for LLM apps
- LangSmith Deployment — Deploy and scale agents with a purpose-built platform for long-running, stateful workflows
Why use LangChain?
LangChain helps developers build applications powered by LLMs through a standard interface for models, embeddings, vector stores, and more.
- Real-time data augmentation — Easily connect LLMs to diverse data sources and external/internal systems, drawing from LangChain's vast library of integrations with model providers, tools, vector stores, retrievers, and more
- Model interoperability — Swap models in and out as your engineering team experiments to find the best choice for your application's needs. As the industry frontier evolves, adapt quickly — LangChain's abstractions keep you moving without losing momentum
- Rapid prototyping — Quickly build and iterate on LLM applications with LangChain's modular, component-based architecture. Test different approaches and workflows without rebuilding from scratch, accelerating your development cycle
- Production-ready features — Deploy reliable applications with built-in support for monitoring, evaluation, and debugging through integrations like LangSmith. Scale with confidence using battle-tested patterns and best practices
- Vibrant community and ecosystem — Leverage a rich ecosystem of integrations, templates, and community-contributed components. Benefit from continuous improvements and stay up-to-date with the latest AI developments through an active open-source community
- Flexible abstraction layers — Work at the level of abstraction that suits your needs — from high-level chains for quick starts to low-level components for fine-grained control. LangChain grows with your application's complexity
Resources
- Documentation — conceptual overviews and guides
- LangChain ecosystem overview — how LangChain, LangGraph, and Deep Agents fit together
- API reference — complete reference for all public classes, functions, and types
- Discussions — community forum for technical questions, ideas, and feedback
- LangChain Academy — comprehensive, free courses on LangChain libraries and products, made by the LangChain team
- Contributing Guide — how to contribute and find good first issues
- Code of Conduct — community guidelines and standards