SurrealDB
SurrealDB Docs Logo

Enter a search query

🐍 Embeddings

SurrealDB offers comprehensive support for vector embeddings, enabling powerful semantic search and machine learning capabilities across your data. Through integrations with leading embedding providers, you can easily store, index and query high-dimensional vectors alongside your regular data.

More details and providers in LangChain Embedding models documentation.

Ollama

from langchain_ollama import OllamaEmbeddings vector_store = SurrealDBVectorStore( OllamaEmbeddings(model="all-minilm:22m"), conn )

More Ollama embedding models in their documentation.


Then, to query the vector store using similarity search:

doc1 = Document( page_content="SurrealDB is the ultimate multi-model database for AI applications", metadata={"key": "sdb"}, ) doc2 = Document( page_content="Surrealism is an artistic and cultural movement that emerged in the early 20th century", metadata={"key": "surrealism"}, ) vector_store.add_documents(documents=[doc1, doc2], ids=["1", "2"]) results = vector_store.similarity_search_with_score(query=q, k=2) for doc, score in results: print(f"• [{score:.0%}]: {doc.page_content}") top_match = results[0][0]

Find an example in Minimal LangChain chatbot example with vector and graph.


Examples above assume you have a DB connection like this:

conn = Surreal("localhost") conn.signin({"username": "root", "password": "secret"}) conn.use("test_ns", "test_db")
Edit this page on GitHub