A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://python.langchain.com/docs/integrations/retrievers/svm/ below:

SVM | 🦜️🔗 LangChain

SVM

Support 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 --upgrade --quiet  scikit-learn
%pip install --upgrade --quiet  lark

We want to use OpenAIEmbeddings so we have to get the OpenAI API Key.

import getpass
import os

if "OPENAI_API_KEY" not in os.environ:
os.environ["OPENAI_API_KEY"] = getpass.getpass("OpenAI API Key:")
from langchain_community.retrievers import SVMRetriever
from langchain_openai import OpenAIEmbeddings
Create 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.invoke("foo")
[Document(page_content='foo', metadata={}),
Document(page_content='foo bar', metadata={}),
Document(page_content='hello', metadata={}),
Document(page_content='world', metadata={})]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4