SiliconFlow
SiliconFlow is a cloud platform that hosts multiple open-source foundation models. Its embedding service offers semantic embedding models for RAG, search, recommendation, and similar workloads. Models such as the BGE series and Qwen Embedding series provide strong semantic representation; some (for example, Qwen3-Embedding) support configurable output dimensions to trade off accuracy and storage.
Using SiliconFlow service requires you to follow SiliconFlow's pricing rules and may incur corresponding fees. Before proceeding, please visit their official website or refer to relevant documentation to confirm and accept their pricing standards. If you do not agree, please do not proceed.
Dependencies and authentication
- Install the
pyseekdbpackage. - Register on the SiliconFlow platform and create an API key in the API management section for authentication and billing.
Example: create a SiliconFlow embedding function
Import and initialize SiliconflowEmbeddingFunction. API keys are usually provided via environment variables.
-
Basic usage
Specify the model name; the function uses the default environment variable
SILICONFLOW_API_KEY.from pyseekdb.utils.embedding_functions import SiliconflowEmbeddingFunction
ef = SiliconflowEmbeddingFunction(
model_name="BAAI/bge-large-zh-v1.5"
)- Advanced usage
Override the API key environment variable and set
dimensionsandtimeoutas needed.from pyseekdb.utils.embedding_functions import SiliconflowEmbeddingFunction
# BGE-M3 with custom env var
ef = SiliconflowEmbeddingFunction(
model_name="BAAI/bge-m3",
api_key_env="SILICONFLOW_API_KEY",
timeout=30
)
# Qwen3-Embedding with output dimension 1024
ef = SiliconflowEmbeddingFunction(
model_name="Qwen/Qwen3-Embedding-8B",
dimensions=1024 # Reduce from default 4096 to 1024
)
Parameters:
model_name: SiliconFlow embedding model name (for example,BAAI/bge-large-zh-v1.5,Qwen/Qwen3-Embedding-0.6B).api_key_env: Environment variable name for the API key (default:SILICONFLOW_API_KEY).timeout: Request timeout (seconds), optional.dimensions: Output vector dimension (only effective when the model supports dynamic dimensions, such asQwen/Qwen3-Embedding-8Bcan be adjusted from the default 4096 to a smaller value), optional.