test_fastembed_sparse.py — langchain Source File
Architecture documentation for test_fastembed_sparse.py, a python file in the langchain codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 8a55d7e8_859f_b007_4df4_366e6c54c004["test_fastembed_sparse.py"] cd17727f_b882_7f06_aadc_71fbf75bebb0["numpy"] 8a55d7e8_859f_b007_4df4_366e6c54c004 --> cd17727f_b882_7f06_aadc_71fbf75bebb0 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] 8a55d7e8_859f_b007_4df4_366e6c54c004 --> 120e2591_3e15_b895_72b6_cb26195e40a6 77801658_6b3a_bc26_7e54_388e5c04807d["langchain_qdrant"] 8a55d7e8_859f_b007_4df4_366e6c54c004 --> 77801658_6b3a_bc26_7e54_388e5c04807d style 8a55d7e8_859f_b007_4df4_366e6c54c004 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import numpy as np
import pytest
from langchain_qdrant import FastEmbedSparse
pytest.importorskip("fastembed", reason="'fastembed' package is not installed")
@pytest.mark.parametrize(
"model_name", ["Qdrant/bm25", "Qdrant/bm42-all-minilm-l6-v2-attentions"]
)
def test_attention_embeddings(model_name: str) -> None:
model = FastEmbedSparse(model_name=model_name)
query_output = model.embed_query("Stay, steady and sprint.")
assert len(query_output.indices) == len(query_output.values)
assert np.allclose(query_output.values, np.ones(len(query_output.values)))
texts = [
"The journey of a thousand miles begins with a single step.",
"Be yourself in a world that is constantly trying to make you something else",
"In the end, we only regret the chances we didn't take.",
"Every moment is a fresh beginning.",
"Not all those who wander are lost.",
"Do not go where the path may lead, go elsewhere and leave a trail.",
"Life is what happens when you're busy making other plans.",
"The only limit to our realization of tomorrow is our doubts of today.",
]
output = model.embed_documents(texts)
assert len(output) == len(texts)
for result in output:
assert len(result.indices) == len(result.values)
assert len(result.indices) > 0
Domain
Subdomains
Functions
Dependencies
- langchain_qdrant
- numpy
- pytest
Source
Frequently Asked Questions
What does test_fastembed_sparse.py do?
test_fastembed_sparse.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in test_fastembed_sparse.py?
test_fastembed_sparse.py defines 1 function(s): test_attention_embeddings.
What does test_fastembed_sparse.py depend on?
test_fastembed_sparse.py imports 3 module(s): langchain_qdrant, numpy, pytest.
Where is test_fastembed_sparse.py in the architecture?
test_fastembed_sparse.py is located at libs/partners/qdrant/tests/integration_tests/fastembed/test_fastembed_sparse.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/partners/qdrant/tests/integration_tests/fastembed).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free