{"record":{"id":"b76082b85c159380","repo":"stanford-oval/storm","slug":"please-provide-an-embedding-model","errorCode":null,"errorMessage":"Please provide an embedding model.","messagePattern":"Please provide an embedding model\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"knowledge_storm/rm.py","lineNumber":214,"sourceCode":"        k: int = 3,\n    ):\n        from langchain_huggingface import HuggingFaceEmbeddings\n\n        \"\"\"\n        Params:\n            collection_name: Name of the Qdrant collection.\n            embedding_model: Name of the Hugging Face embedding model.\n            device: Device to run the embeddings model on, can be \"mps\", \"cuda\", \"cpu\".\n            k: Number of top chunks to retrieve.\n        \"\"\"\n        super().__init__(k=k)\n        self.usage = 0\n        # check if the collection is provided\n        if not collection_name:\n            raise ValueError(\"Please provide a collection name.\")\n        # check if the embedding model is provided\n        if not embedding_model:\n            raise ValueError(\"Please provide an embedding model.\")\n\n        model_kwargs = {\"device\": device}\n        encode_kwargs = {\"normalize_embeddings\": True}\n        self.model = HuggingFaceEmbeddings(\n            model_name=embedding_model,\n            model_kwargs=model_kwargs,\n            encode_kwargs=encode_kwargs,\n        )\n\n        self.collection_name = collection_name\n        self.client = None\n        self.qdrant = None\n\n    def _check_collection(self):\n        from langchain_qdrant import Qdrant\n\n        \"\"\"\n        Check if the Qdrant collection exists and create it if it does not.","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/stanford-oval/storm/blob/fb951af7744dab086e34962e9bc6fe878e145f83/knowledge_storm/rm.py#L196-L232","documentation":"VectorRM's __init__ requires an embedding model because it builds a langchain HuggingFaceEmbeddings instance (self.model) used to embed queries against the Qdrant vector store. Without an embedding model, vectors cannot be compared to stored embeddings. The check raises ValueError immediately at construction time.","triggerScenarios":"Constructing VectorRM(...) without passing embedding_model (e.g. VectorRM(collection_name='docs', source='offline', vector_store_path='./qdrant')). The parameter defaults to None, so any call omitting it fails.","commonSituations":"Copying a minimal example that only sets collection_name and vector_store_path; upgrading knowledge-storm where older examples omitted embedding_model; assuming the model is stored in the vector store and not needed at query time.","solutions":["Pass embedding_model explicitly, e.g. embedding_model='sentence-transformers/all-MiniLM-L6-v2'","Ensure the same embedding model was used to build the stored collection, otherwise retrieval quality degrades","Pre-download the model (huggingface) if running in an offline/sandboxed environment"],"exampleFix":"// before\nrm = VectorRM(collection_name='my_docs', source='offline', vector_store_path='./qdrant')\n// after\nrm = VectorRM(collection_name='my_docs', source='offline', vector_store_path='./qdrant', embedding_model='sentence-transformers/all-MiniLM-L6-v2')","handlingStrategy":"validation","validationCode":"from knowledge_storm.rm import VectorRM\nEMBED_MODEL = 'sentence-transformers/all-MiniLM-L6-v2'\nif not EMBED_MODEL:\n    raise SystemExit('embedding_model is required')\nrm = VectorRM(collection_name='docs', source='offline', vector_store_path='./qdrant', embedding_model=EMBED_MODEL)","typeGuard":"def valid_vectorrm_config(collection_name: str, embedding_model: str | None) -> bool:\n    return bool(collection_name) and bool(embedding_model)","tryCatchPattern":"try:\n    rm = VectorRM(collection_name='docs', source='offline', vector_store_path='./qdrant', embedding_model=MODEL)\nexcept ValueError as e:\n    if 'embedding model' in str(e):\n        raise SystemExit(f'Config error: {e}')\n    raise","preventionTips":["Centralize the embedding model name in one config constant used for both ingestion and retrieval","Pin the same model that built the collection to avoid dimension mismatches"],"tags":["python","vector-database","embeddings","configuration"],"backgroundTag":"missing-required-parameter","analyzedSha":"fb951af7744dab086e34962e9bc6fe878e145f83","analyzedAt":"2026-08-28T11:56:54.780Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}