_low_confidence_spans() — langchain Function Reference
Architecture documentation for the _low_confidence_spans() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD df7d80eb_6d6e_6bee_cb9e_b4eda380e41a["_low_confidence_spans()"] 4c01b940_b202_29af_2ff5_d0dfa5e5e804["base.py"] df7d80eb_6d6e_6bee_cb9e_b4eda380e41a -->|defined in| 4c01b940_b202_29af_2ff5_d0dfa5e5e804 193d32b1_2740_febf_5c97_eebfa1726864["_call()"] 193d32b1_2740_febf_5c97_eebfa1726864 -->|calls| df7d80eb_6d6e_6bee_cb9e_b4eda380e41a style df7d80eb_6d6e_6bee_cb9e_b4eda380e41a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/chains/flare/base.py lines 58–94
def _low_confidence_spans(
tokens: Sequence[str],
log_probs: Sequence[float],
min_prob: float,
min_token_gap: int,
num_pad_tokens: int,
) -> list[str]:
try:
import numpy as np
_low_idx = np.where(np.exp(log_probs) < min_prob)[0]
except ImportError:
logger.warning(
"NumPy not found in the current Python environment. FlareChain will use a "
"pure Python implementation for internal calculations, which may "
"significantly impact performance, especially for large datasets. For "
"optimal speed and efficiency, consider installing NumPy: pip install "
"numpy",
)
import math
_low_idx = [ # type: ignore[assignment]
idx
for idx, log_prob in enumerate(log_probs)
if math.exp(log_prob) < min_prob
]
low_idx = [i for i in _low_idx if re.search(r"\w", tokens[i])]
if len(low_idx) == 0:
return []
spans = [[low_idx[0], low_idx[0] + num_pad_tokens + 1]]
for i, idx in enumerate(low_idx[1:]):
end = idx + num_pad_tokens + 1
if idx - low_idx[i] < min_token_gap:
spans[-1][1] = end
else:
spans.append([idx, end])
return ["".join(tokens[start:end]) for start, end in spans]
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _low_confidence_spans() do?
_low_confidence_spans() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/flare/base.py.
Where is _low_confidence_spans() defined?
_low_confidence_spans() is defined in libs/langchain/langchain_classic/chains/flare/base.py at line 58.
What calls _low_confidence_spans()?
_low_confidence_spans() is called by 1 function(s): _call.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free