Skip to main content
Weaviate Docs (migrated from docs.weaviate.io) Docs

Search documentation

Type to search this documentation.

On this pageOverview

Quickstart: Locally hosted with Docker

Weaviate is an open-source vector database built to power AI applications. This quickstart guide will show you how to:

  1. Set up a collection - Create a collection and import data into it.
  2. Search - Perform a similarity (vector) search on your data.
  3. RAG - Perform Retrieval Augmented Generation (RAG) with a generative model.

If you encounter any issues along the way or have additional questions, use the Ask AI feature.

Before we get started, install Docker on your machine. We will be running Weaviate and Ollama language models locally. We recommend that you use a modern computer with at least 8GB of RAM, preferably 16GB or more.


Start Weaviate and Ollama with Docker Compose

Section titled “Start Weaviate and Ollama with Docker Compose”

Save the following code to a file named docker-compose.yml in your project directory.

YAML
services:
  weaviate:
    command:
    - --host
    - 0.0.0.0
    - --port
    - '8080'
    - --scheme
    - http
    image: cr.weaviate.io/semitechnologies/weaviate:1.38.2
    ports:
    - 8080:8080
    - 50051:50051
    volumes:
    - weaviate_data:/var/lib/weaviate
    restart: on-failure:0
    environment:
      AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
      PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
      ENABLE_MODULES: 'text2vec-ollama,generative-ollama'
      CLUSTER_HOSTNAME: 'node1'
      OLLAMA_API_ENDPOINT: 'http://ollama:11434'
    depends_on:
      - ollama

  ollama:
    image: ollama/ollama:0.12.9
    ports:
      - "11434:11434"
    volumes:
      - ollama_data:/root/.ollama

volumes:
  weaviate_data:
  ollama_data:

Run the following command to start a Weaviate instance and the Ollama server inside Docker containers:

Bash
docker-compose up -d

Once the Ollama service starts, you can pull the required embedding model (nomic-embed-text) and generative model (llama3.2) in the ollama container:

Bash
docker compose exec ollama ollama pull nomic-embed-text
docker compose exec ollama ollama pull llama3.2

Follow the instructions below to install one of the official client libraries, available in Python, JavaScript/TypeScript, Go, and Java.

Python
pip install -U "weaviate-client[agents]"
JavaScript/TypeScript
npm install weaviate-client weaviate-agents
Go
go get github.com/weaviate/weaviate-go-client/v5
Java
<dependency>
  <groupId>io.weaviate</groupId>
  <artifactId>client6</artifactId>
  <version>6.2.0</version> <!-- Check latest version: https://github.com/weaviate/java-client  -->
</dependency>
C#
<PackageReference Include="Weaviate.Client" Version="1.0.0" />

There are two paths you can choose from when importing data:

The following example creates a collection called Movie with the Ollama embedding model provider (text2vec-ollama) for vectorizing data during import and for querying. You are also free to use any other available embedding model provider.

Python
import weaviate
from weaviate.classes.config import Configure

# Step 1.1: Connect to your local Weaviate instance
with weaviate.connect_to_local() as client:
TypeScript
import weaviate, { WeaviateClient, vectors } from 'weaviate-client';

// Step 1.1: Connect to your local Weaviate instance
const client: WeaviateClient = await weaviate.connectToLocal();

The collection also contains a configuration for the generative (RAG) integration:

goraw
import (
  "context"
  "fmt"

  "github.com/weaviate/weaviate-go-client/v5/weaviate"
  "github.com/weaviate/weaviate/entities/models"
)

func main() {
  // Step 1.1: Connect to your local Weaviate instance
  cfg := weaviate.Config{
    Host:   "localhost:8080",
    Scheme: "http",
  }
  client, err := weaviate.NewClient(cfg)
  if err != nil {
    panic(err)
  }
javaraw
import io.weaviate.client6.v1.api.WeaviateClient;
import io.weaviate.client6.v1.api.collections.CollectionHandle;
import io.weaviate.client6.v1.api.collections.Property;
import io.weaviate.client6.v1.api.collections.VectorConfig;
import io.weaviate.client6.v1.api.collections.WeaviateObject;
import io.weaviate.client6.v1.api.collections.batch.BatchContext;

import java.util.List;
import java.util.Map;

public class QuickstartLocalCreate {

  public static void main(String[] args) throws Exception {
    WeaviateClient client = null;
    String collectionName = "Movie";

    try {
      // Step 1.1: Connect to your local Weaviate instance
      client = WeaviateClient.connectToLocal();
C#
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Weaviate.Client;
using Weaviate.Client.Models;

namespace WeaviateProject.Examples
{
    public class QuickstartLocalCreate
    {
        public static async Task Run()
        {
            string collectionName = "Movie";

            // Step 1.1: Connect to your local Weaviate instance
            var client = await Connect.Local();

The following example creates a collection called Movie. The data should already contain the pre-computed vector embeddingsVector embeddings generated by an embedding model (from a provider like OpenAI, Anthropic, etc.).. This option is useful for when you are migrating data from a different vector database.

Python
import weaviate
from weaviate.classes.config import Configure
from weaviate.classes.data import DataObject

# Step 1.1: Connect to your local Weaviate instance
with weaviate.connect_to_local() as client:
TypeScript
import weaviate, { WeaviateClient, vectors } from 'weaviate-client';

// Step 1.1: Connect to your local Weaviate instance
const client: WeaviateClient = await weaviate.connectToLocal();

The collection also contains a configuration for the generative (RAG) integration:

goraw
import (
  "context"
  "fmt"

  "github.com/weaviate/weaviate-go-client/v5/weaviate"
  "github.com/weaviate/weaviate/entities/models"
)

func main() {
  // Step 1.1: Connect to your local Weaviate instance
  cfg := weaviate.Config{
    Host:   "localhost:8080",
    Scheme: "http",
  }
  client, err := weaviate.NewClient(cfg)
  if err != nil {
    panic(err)
  }
javaraw
import io.weaviate.client6.v1.api.WeaviateClient;
import io.weaviate.client6.v1.api.collections.CollectionHandle;
import io.weaviate.client6.v1.api.collections.Property;
import io.weaviate.client6.v1.api.collections.VectorConfig;
import io.weaviate.client6.v1.api.collections.Vectors;
import io.weaviate.client6.v1.api.collections.WeaviateObject;
import io.weaviate.client6.v1.api.collections.batch.BatchContext;
import java.util.List;
import java.util.Map;

public class QuickstartLocalCreateVectors {

  public static void main(String[] args) throws Exception {
    WeaviateClient client = null;
    String collectionName = "Movie";

    try {
      // Step 1.1: Connect to your local Weaviate instance
      client = WeaviateClient.connectToLocal();
C#
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Weaviate.Client;
using Weaviate.Client.Models;

namespace WeaviateProject.Examples
{
    public class QuickstartLocalCreateVectors
    {
        public static async Task Run()
        {
            string collectionName = "Movie";

            // Step 1.1: Connect to your local Weaviate instance
            var client = await Connect.Local();

Semantic search finds results based on meaning. This is called nearText in Weaviate. The following example searches for 2 objects (limit) whose meaning is most similar to that of sci-fi.

Python
import weaviate
import json

# Step 2.1: Connect to your local Weaviate instance
with weaviate.connect_to_local() as client:

    # Step 2.2: Use this collection
    movies = client.collections.use("Movie")

    # Step 2.3: Perform a semantic search with NearText
    # highlight-start
JavaScript/TypeScript
import weaviate, { WeaviateClient } from 'weaviate-client';// Step 2.1: Connect to your local Weaviate instanceconst client: WeaviateClient = await weaviate.connectToLocal();// Step 2.2: Use this collectionconst movies = client.collections.get('Movie');// Step 2.3: Perform a semantic search with NearTextconst response = await movies.query.nearText(  'sci-fi',  {    limit: 2,  });for (const obj of response.objects) {  console.log(JSON.stringify(obj.properties, null, 2)); // Inspect the results}await client.close(); // Free up resources
Go
import (  "context"  "encoding/json"  "fmt"  "github.com/weaviate/weaviate-go-client/v5/weaviate"  "github.com/weaviate/weaviate-go-client/v5/weaviate/graphql")func main() {  // Step 1.1: Connect to your local Weaviate instance  cfg := weaviate.Config{    Host:   "localhost:8080",    Scheme: "http",  }  client, err := weaviate.NewClient(cfg)  if err != nil {    panic(err)  }  // Step 2.2: Perform a semantic search with NearText  title := graphql.Field{Name: "title"}  description := graphql.Field{Name: "description"}  genre := graphql.Field{Name: "genre"}  nearText := client.GraphQL().NearTextArgBuilder().    WithConcepts([]string{"sci-fi"})  result, err := client.GraphQL().Get().    WithClassName("Movie").    WithNearText(nearText).    WithLimit(2).    WithFields(title, description, genre).    Do(context.Background())  if err != nil {    panic(err)  }  // Inspect the results  if result.Errors != nil {    fmt.Printf("Error: %v\n", result.Errors)    return  }  data := result.Data["Get"].(map[string]interface{})  movies := data["Movie"].([]interface{})  for _, movie := range movies {    jsonData, err := json.MarshalIndent(movie, "", "  ")    if err != nil {      panic(err)    }    fmt.Println(string(jsonData))  }
Java
import io.weaviate.client6.v1.api.WeaviateClient;import io.weaviate.client6.v1.api.collections.CollectionHandle;import com.fasterxml.jackson.databind.ObjectMapper; // For pretty-printing JSONimport java.util.Map;public class QuickstartLocalQueryNearText {  public static void main(String[] args) throws Exception {    WeaviateClient client = null;    try {      // Step 2.1: Connect to your local Weaviate instance      client = WeaviateClient.connectToLocal();      // Step 2.2: Perform a semantic search with NearText      CollectionHandle<Map<String, Object>> movies =          client.collections.use("Movie");      ObjectMapper objectMapper = new ObjectMapper();      var response = movies.query.nearText("sci-fi",          q -> q.limit(2).returnProperties("title", "description", "genre"));      // Inspect the results      System.out.println("--- Query Results ---");      for (var obj : response.objects()) {        System.out.println(objectMapper.writerWithDefaultPrettyPrinter()            .writeValueAsString(obj.properties()));      }    } finally {      if (client != null) {        client.close(); // Free up resources      }    }  }}
C#
using System;using System.Text.Json;using System.Threading;using System.Threading.Tasks;using Weaviate.Client;namespace WeaviateProject.Examples{    public class QuickstartLocalQueryNearText    {        public static async Task Run()        {            // Step 2.1: Connect to your local Weaviate instance            var client = await Connect.Local();            // Step 2.2: Perform a semantic search with NearText            var movies = client.Collections.Use("Movie");            var response = await movies.Query.NearText(                "sci-fi",                limit: 2,                returnProperties: ["title", "description", "genre"]            );            // Inspect the results            Console.WriteLine("--- Query Results ---");            foreach (var obj in response.Objects)            {                Console.WriteLine(                    JsonSerializer.Serialize(                        obj.Properties,                        new JsonSerializerOptions { WriteIndented = true }                    )                );            }        }    }}

Semantic search finds results based on meaning. This is called nearVector in Weaviate. The following example searches for 2 objects (limit) whose vector is most similar to the query vector.

Python
import weaviate
import json

# Step 2.1: Connect to your local Weaviate instance
with weaviate.connect_to_local() as client:

    # Step 2.2: Use this collection
    movies = client.collections.use("Movie")

    # Step 2.3: Perform a vector search with NearVector
    # highlight-start
JavaScript/TypeScript
import weaviate, { WeaviateClient } from 'weaviate-client';// Step 2.1: Connect to your local Weaviate instanceconst client: WeaviateClient = await weaviate.connectToLocal();// Step 2.2: Use this collectionconst movies = client.collections.get('Movie');// Step 2.3: Perform a vector search with NearVectorconst response = await movies.query.nearVector(  [0.11, 0.21, 0.31, 0.41, 0.51, 0.61, 0.71, 0.81],  {    limit: 2,  });for (const obj of response.objects) {  console.log(JSON.stringify(obj.properties, null, 2)); // Inspect the results}await client.close(); // Free up resources
Go
import (  "context"  "encoding/json"  "fmt"  "github.com/weaviate/weaviate-go-client/v5/weaviate"  "github.com/weaviate/weaviate-go-client/v5/weaviate/graphql")func main() {  // Step 1.1: Connect to your local Weaviate instance  cfg := weaviate.Config{    Host:   "localhost:8080",    Scheme: "http",  }  client, err := weaviate.NewClient(cfg)  if err != nil {    panic(err)  }  // Step 2.2: Perform a vector search with NearVector  title := graphql.Field{Name: "title"}  description := graphql.Field{Name: "description"}  genre := graphql.Field{Name: "genre"}  nearVector := client.GraphQL().NearVectorArgBuilder().    WithVector([]float32{0.11, 0.21, 0.31, 0.41, 0.51, 0.61, 0.71, 0.81})  result, err := client.GraphQL().Get().    WithClassName("Movie").    WithNearVector(nearVector).    WithLimit(2).    WithFields(title, description, genre).    Do(context.Background())  if err != nil {    panic(err)  }  // Inspect the results  if result.Errors != nil {    fmt.Printf("Error: %v\n", result.Errors)    return  }  data := result.Data["Get"].(map[string]interface{})  movies := data["Movie"].([]interface{})  for _, movie := range movies {    jsonData, err := json.MarshalIndent(movie, "", "  ")    if err != nil {      panic(err)    }    fmt.Println(string(jsonData))  }
Java
import io.weaviate.client6.v1.api.WeaviateClient;import io.weaviate.client6.v1.api.collections.CollectionHandle;import com.fasterxml.jackson.databind.ObjectMapper; // For pretty-printing JSONimport java.util.Map;public class QuickstartLocalQueryNearVector {  public static void main(String[] args) throws Exception {    WeaviateClient client = null;    try {      // Step 2.1: Connect to your local Weaviate instance      client = WeaviateClient.connectToLocal();      // Step 2.2: Perform a vector search with NearVector      CollectionHandle<Map<String, Object>> movies =          client.collections.use("Movie");      ObjectMapper objectMapper = new ObjectMapper();      // Use primitive float[] for v6      float[] queryVector =          new float[] {0.11f, 0.21f, 0.31f, 0.41f, 0.51f, 0.61f, 0.71f, 0.81f};      var response = movies.query.nearVector(queryVector,          q -> q.limit(2).returnProperties("title", "description", "genre"));      // Inspect the results      System.out.println("--- Query Results ---");      for (var obj : response.objects()) {        System.out.println(objectMapper.writerWithDefaultPrettyPrinter()            .writeValueAsString(obj.properties()));      }    } finally {      if (client != null) {        client.close(); // Free up resources      }    }  }}
C#
using System;using System.Text.Json;using System.Threading.Tasks;using Weaviate.Client;namespace WeaviateProject.Examples{    public class QuickstartLocalQueryNearVector    {        public static async Task Run()        {            // Step 2.1: Connect to your local Weaviate instance            var client = await Connect.Local();            // Step 2.2: Perform a vector search with NearVector            var movies = client.Collections.Use("Movie");            float[] queryVector = [0.11f, 0.21f, 0.31f, 0.41f, 0.51f, 0.61f, 0.71f, 0.81f];            var response = await movies.Query.NearVector(                queryVector,                limit: 2,                returnProperties: ["title", "description", "genre"]            );            // Inspect the results            Console.WriteLine("--- Query Results ---");            foreach (var obj in response.Objects)            {                Console.WriteLine(                    JsonSerializer.Serialize(                        obj.Properties,                        new JsonSerializerOptions { WriteIndented = true }                    )                );            }        }    }}
Example response
JSON
{
  "genre": "Science Fiction",
  "title": "The Matrix",
  "description": "A computer hacker learns about the true nature of reality and his role in the war against its controllers."
}
{
  "genre": "Fantasy",
  "title": "The Lord of the Rings: The Fellowship of the Ring",
  "description": "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth."
}

Step 3: Retrieval augmented generation (RAG)

Section titled “Step 3: Retrieval augmented generation (RAG)”

Retrieval augmented generation (RAG), also called generative search, works by prompting a large language model (LLM) with a combination of a user query and data retrieved from a database.

The following example combines the semantic search for the query sci-fi with a prompt to generate a tweet using the Ollama generative model (generative-ollama).

Python
import weaviate
from weaviate.classes.generate import GenerativeConfig

# Step 2.1: Connect to your local Weaviate instance
with weaviate.connect_to_local() as client:
JavaScript/TypeScript
import weaviate, { WeaviateClient, generativeParameters } from 'weaviate-client';// Step 2.1: Connect to your local Weaviate instanceconst client: WeaviateClient = await weaviate.connectToLocal();// Step 2.2: Use this collectionconst movies = client.collections.get('Movie');// Step 2.3: Perform RAG with on NearText resultsconst response = await movies.generate.nearText(  'sci-fi',  {    groupedTask: 'Write a tweet with emojis about this movie.',    config: generativeParameters.ollama({      apiEndpoint: 'http://ollama:11434',  // If using Docker you might need: http://host.docker.internal:11434      model: 'llama3.2',                   // The model to use    }),  },  {    limit: 1,  });console.log(response.generative); // Inspect the resultsawait client.close(); // Free up resources
Go
import (  "context"  "fmt"  "github.com/weaviate/weaviate-go-client/v5/weaviate"  "github.com/weaviate/weaviate-go-client/v5/weaviate/graphql")func main() {  // Step 2.1: Connect to your local Weaviate instance  cfg := weaviate.Config{    Host:   "localhost:8080",    Scheme: "http",  }  client, err := weaviate.NewClient(cfg)  if err != nil {    panic(err)  }  // Step 2.2: Perform RAG with NearText results  title := graphql.Field{Name: "title"}  description := graphql.Field{Name: "description"}  genre := graphql.Field{Name: "genre"}  nearText := client.GraphQL().NearTextArgBuilder().    WithConcepts([]string{"sci-fi"})  generate := graphql.NewGenerativeSearch().GroupedResult("Write a tweet with emojis about this movie.")  result, err := client.GraphQL().Get().    WithClassName("Movie").    WithNearText(nearText).    WithLimit(1).    WithFields(title, description, genre).    WithGenerativeSearch(generate).    Do(context.Background())  if err != nil {    panic(err)  }  // Inspect the results  if result.Errors != nil {    fmt.Printf("Error: %v\n", result.Errors)    return  }  fmt.Printf("%v", result)
Java
import io.weaviate.client6.v1.api.WeaviateClient;import io.weaviate.client6.v1.api.collections.CollectionHandle;import io.weaviate.client6.v1.api.collections.generate.GenerativeProvider;import java.util.Map;public class QuickstartLocalQueryNearTextRAG {  public static void main(String[] args) throws Exception {    WeaviateClient client = null;    try {      // Step 2.1: Connect to your local Weaviate instance      client = WeaviateClient.connectToLocal();      // Step 2.2: Perform RAG with nearText results      CollectionHandle<Map<String, Object>> movies =          client.collections.use("Movie");      var response = movies.generate.nearText("sci-fi",          q -> q.limit(1).returnProperties("title", "description", "genre"),          // Generative configuration (RAG task)          g -> g.groupedTask("Write a tweet with emojis about this movie.",              p -> p.generativeProvider(                  GenerativeProvider.ollama(o -> o.apiEndpoint("http://ollama:11434")// If using Docker you might need: http://host.docker.internal:11434                      .model("llama3.2") // The model to use                  ))));      // Inspect the results      System.out.println(response.generative().text());    } finally {      if (client != null) {        client.close(); // Free up resources      }    }  }}
C#
using System;using System.Text.Json;using System.Threading.Tasks;using Weaviate.Client;using Weaviate.Client.Models;using Weaviate.Client.Models.Generative;namespace WeaviateProject.Examples{    public class QuickstartLocalQueryNearTextRAG    {        public static async Task Run()        {            // Step 3.1: Connect to your local Weaviate instance            var client = await Connect.Local();            // Step 3.2: Perform RAG with nearText results            var movies = client.Collections.Use("Movie");            var response = await movies.Generate.NearText(                "sci-fi",                limit: 1,                returnProperties: ["title", "description", "genre"],                groupedTask: new GroupedTask("Write a tweet with emojis about this movie."),                provider: new Providers.Ollama                {                    ApiEndpoint = "http://ollama:11434", // If using Docker you might need: http://host.docker.internal:11434                    Model = "llama3.2", // The model to use                }            );            // Inspect the results            Console.WriteLine(JsonSerializer.Serialize(response.Generative.Values));        }    }}

Retrieval augmented generation (RAG), also called generative search, works by prompting a large language model (LLM) with a combination of a user query and data retrieved from a database.

The following example combines the vector similarity search with a prompt to generate a tweet using the Ollama generative model (generative-ollama).

Python
import weaviate
from weaviate.classes.generate import GenerativeConfig

# Step 2.1: Connect to your local Weaviate instance
with weaviate.connect_to_local() as client:
JavaScript/TypeScript
import weaviate, { WeaviateClient, generativeParameters } from 'weaviate-client';// Step 2.1: Connect to your local Weaviate instanceconst client: WeaviateClient = await weaviate.connectToLocal();// Step 2.2: Use this collectionconst movies = client.collections.get('Movie');// Step 2.3: Perform RAG with on NearVector resultsconst response = await movies.generate.nearVector(  [0.11, 0.21, 0.31, 0.41, 0.51, 0.61, 0.71, 0.81],  {    groupedTask: 'Write a tweet with emojis about this movie.',    config: generativeParameters.ollama({      apiEndpoint: 'http://ollama:11434',  // If using Docker you might need: http://host.docker.internal:11434      model: 'llama3.2',                   // The model to use    }),  },  {    limit: 1,  });console.log(response.generative); // Inspect the resultsawait client.close(); // Free up resources
Go
import (  "context"  "fmt"  "github.com/weaviate/weaviate-go-client/v5/weaviate"  "github.com/weaviate/weaviate-go-client/v5/weaviate/graphql")func main() {  // Step 2.1: Connect to your local Weaviate instance  cfg := weaviate.Config{    Host:   "localhost:8080",    Scheme: "http",  }  client, err := weaviate.NewClient(cfg)  if err != nil {    panic(err)  }  // Step 2.2: Perform RAG with NearText results  title := graphql.Field{Name: "title"}  description := graphql.Field{Name: "description"}  genre := graphql.Field{Name: "genre"}  nearVector := client.GraphQL().NearVectorArgBuilder().    WithVector([]float32{0.11, 0.21, 0.31, 0.41, 0.51, 0.61, 0.71, 0.81})  generate := graphql.NewGenerativeSearch().GroupedResult("Write a tweet with emojis about this movie.")  result, err := client.GraphQL().Get().    WithClassName("Movie").    WithNearVector(nearVector).    WithLimit(1).    WithFields(title, description, genre).    WithGenerativeSearch(generate).    Do(context.Background())  if err != nil {    panic(err)  }  // Inspect the results  if result.Errors != nil {    fmt.Printf("Error: %v\n", result.Errors)    return  }  fmt.Printf("%v", result)
Java
import io.weaviate.client6.v1.api.WeaviateClient;import io.weaviate.client6.v1.api.collections.CollectionHandle;import io.weaviate.client6.v1.api.collections.generate.GenerativeProvider;import java.util.Map;public class QuickstartLocalQueryNearVectorRAG {  public static void main(String[] args) throws Exception {    WeaviateClient client = null;    try {      // Step 2.1: Connect to your local Weaviate instance      client = WeaviateClient.connectToLocal();      // Step 2.2: Perform RAG with NearVector results      CollectionHandle<Map<String, Object>> movies =          client.collections.use("Movie");      // Use primitive float[] for v6      float[] queryVector =          new float[] {0.11f, 0.21f, 0.31f, 0.41f, 0.51f, 0.61f, 0.71f, 0.81f};      var response = movies.generate.nearVector(queryVector,          q -> q.limit(1).returnProperties("title", "description", "genre"),          // Generative configuration (RAG task)          g -> g.groupedTask("Write a tweet with emojis about this movie.",              p -> p.generativeProvider(                  GenerativeProvider.ollama(o -> o.apiEndpoint("http://ollama:11434")// If using Docker you might need: http://host.docker.internal:11434                      .model("llama3.2") // The model to use                  ))));      // Inspect the results      // Use .generative() to access the generative result      System.out.println(response.generative().text());    } finally {      if (client != null) {        client.close(); // Free up resources      }    }  }}
C#
using System;using System.Text.Json;using System.Threading.Tasks;using Weaviate.Client;using Weaviate.Client.Models;using Weaviate.Client.Models.Generative;namespace WeaviateProject.Examples{    public class QuickstartLocalQueryNearVectorRAG    {        public static async Task Run()        {            // Step 3.1: Connect to your local Weaviate instance            var client = await Connect.Local();            // Step 3.2: Perform RAG with NearVector results            var movies = client.Collections.Use("Movie");            float[] queryVector = [0.11f, 0.21f, 0.31f, 0.41f, 0.51f, 0.61f, 0.71f, 0.81f];            var response = await movies.Generate.NearVector(                vectors: queryVector,                limit: 1,                returnProperties: ["title", "description", "genre"],                groupedTask: new GroupedTask("Write a tweet with emojis about this movie."),                provider: new Providers.Ollama                {                    ApiEndpoint = "http://ollama:11434", // If using Docker you might need: http://host.docker.internal:11434                    Model = "llama3.2", // The model to use                }            );            // Inspect the results            Console.WriteLine(JsonSerializer.Serialize(response.Generative.Values));        }    }}
Example response
JSON
🕶️ Unplug from the system & join Neo's journey 💊🐰

"The Matrix" will blow your mind 🤯 as reality unravels 🌀

Kung-fu, slow-mo & mind-bending sci-fi 🥋🕴️

Are you ready to see how deep the rabbit hole goes? 🔴🔵 #TheMatrix #WakeUp

We recommend you check out the following resources to continue learning about Weaviate.

Have a question or feedback? Here's how to reach us.

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu