Skip to main contentğŸ¦œï¸�ğŸ”— LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKProvidersAnthropicAWSGoogleMicrosoftOpenAIMoreComponentsLLMsChat modelsDocument loadersDocument transformersText embedding modelsVector storesRetrieversAmazon KendraArcee RetrieverArxivAzure Cognitive SearchBM25ChaindeskChatGPT PluginCohere RerankerDocArrayElasticSearch BM25Google Cloud Enterprise SearchGoogle DriveGoogle Vertex AI SearchKay.aikNNLOTR (Merger Retriever)MetalPinecone Hybrid SearchPubMedRePhraseQuerySEC filingSelf-querying retrieverSVMTavily Search APITF-IDFVespaWeaviate Hybrid SearchWikipediayou-retrieverZepToolsAgents and toolkitsMemoryCallbacksChat loadersComponentsRetrieversSVMOn this pageSVMSupport vector machines (SVMs) are a set of supervised learning methods used for classification, regression and outliers detection.This notebook goes over how to use a retriever that under the hood uses an SVM using scikit-learn package.Largely based on https://github.com/karpathy/randomfun/blob/master/knn_vs_svm.html#!pip install scikit-learn#!pip install larkWe want to use OpenAIEmbeddings so we have to get the OpenAI API Key.import osimport getpassos.environ["OPENAI_API_KEY"] = getpass.getpass("OpenAI API Key:")    OpenAI API Key: Â·Â·Â·Â·Â·Â·Â·Â·from langchain.retrievers import SVMRetrieverfrom langchain.embeddings import OpenAIEmbeddingsCreate New Retriever with Textsâ€‹retriever = SVMRetriever.from_texts(    ["foo", "bar", "world", "hello", "foo bar"], OpenAIEmbeddings())Use Retrieverâ€‹We can now use the retriever!result = retriever.get_relevant_documents("foo")result    [Document(page_content='foo', metadata={}),     Document(page_content='foo bar', metadata={}),     Document(page_content='hello', metadata={}),     Document(page_content='world', metadata={})]PreviousWeaviateNextTavily Search APICreate New Retriever with TextsUse RetrieverCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.
Support vector machines (SVMs) are a set of supervised learning methods used for classification, regression and outliers detection.
Support vector machines (SVMs) are a set of supervised learning methods used for classification, regression and outliers detection. ->: Skip to main contentğŸ¦œï¸�ğŸ”— LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKProvidersAnthropicAWSGoogleMicrosoftOpenAIMoreComponentsLLMsChat modelsDocument loadersDocument transformersText embedding modelsVector storesRetrieversAmazon KendraArcee RetrieverArxivAzure Cognitive SearchBM25ChaindeskChatGPT PluginCohere RerankerDocArrayElasticSearch BM25Google Cloud Enterprise SearchGoogle DriveGoogle Vertex AI SearchKay.aikNNLOTR (Merger Retriever)MetalPinecone Hybrid SearchPubMedRePhraseQuerySEC filingSelf-querying retrieverSVMTavily Search APITF-IDFVespaWeaviate Hybrid SearchWikipediayou-retrieverZepToolsAgents and toolkitsMemoryCallbacksChat loadersComponentsRetrieversSVMOn this pageSVMSupport vector machines (SVMs) are a set of supervised learning methods used for classification, regression and outliers detection.This notebook goes over how to use a retriever that under the hood uses an SVM using scikit-learn package.Largely based on https://github.com/karpathy/randomfun/blob/master/knn_vs_svm.html#!pip install scikit-learn#!pip install larkWe want to use OpenAIEmbeddings so we have to get the OpenAI API Key.import osimport getpassos.environ["OPENAI_API_KEY"] = getpass.getpass("OpenAI API Key:")    OpenAI API Key: Â·Â·Â·Â·Â·Â·Â·Â·from langchain.retrievers import SVMRetrieverfrom langchain.embeddings import OpenAIEmbeddingsCreate New Retriever with Textsâ€‹retriever = SVMRetriever.from_texts(    ["foo", "bar", "world", "hello", "foo bar"], OpenAIEmbeddings())Use Retrieverâ€‹We can now use the retriever!result = retriever.get_relevant_documents("foo")result    [Document(page_content='foo', metadata={}),     Document(page_content='foo bar', metadata={}),     Document(page_content='hello', metadata={}),     Document(page_content='world', metadata={})]PreviousWeaviateNextTavily Search APICreate New Retriever with TextsUse RetrieverCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.