StopOnTokens Class — langchain Architecture
Architecture documentation for the StopOnTokens class in huggingface_pipeline.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 65a467c6_81d2_7b58_16ac_fb96150d6b19["StopOnTokens"] b87ebf28_5f26_0280_8cb7_68afdab14557["huggingface_pipeline.py"] 65a467c6_81d2_7b58_16ac_fb96150d6b19 -->|defined in| b87ebf28_5f26_0280_8cb7_68afdab14557 d950c92b_ea43_8b18_33f7_f6c6d4765d9e["__call__()"] 65a467c6_81d2_7b58_16ac_fb96150d6b19 -->|method| d950c92b_ea43_8b18_33f7_f6c6d4765d9e
Relationship Graph
Source Code
libs/partners/huggingface/langchain_huggingface/llms/huggingface_pipeline.py lines 391–398
class StopOnTokens(StoppingCriteria):
def __call__(
self,
input_ids: torch.LongTensor,
scores: torch.FloatTensor,
**kwargs: Any,
) -> bool:
return any(input_ids[0][-1] == stop_id for stop_id in stopping_ids_list)
Source
Frequently Asked Questions
What is the StopOnTokens class?
StopOnTokens is a class in the langchain codebase, defined in libs/partners/huggingface/langchain_huggingface/llms/huggingface_pipeline.py.
Where is StopOnTokens defined?
StopOnTokens is defined in libs/partners/huggingface/langchain_huggingface/llms/huggingface_pipeline.py at line 391.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free