langchain.embeddings.ollama.OllamaEmbeddings¶
class langchain.embeddings.ollama.OllamaEmbeddings[source]¶
Bases: BaseModel, Embeddings
Ollama locally runs large language models.
To use, follow the instructions at https://ollama.ai/.
Example
from langchain.embeddings import OllamaEmbeddings
ollama_emb = OllamaEmbeddings(
    model="llama:7b",
)
r1 = ollama_emb.embed_documents(
    [
        "Alpha is the first letter of Greek alphabet",
        "Beta is the second letter of Greek alphabet",
    ]
)
r2 = ollama_emb.embed_query(
    "What is the second letter of Greek alphabet"
)
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param base_url: str = 'http://localhost:11434'¶
Base url the model is hosted under.
param embed_instruction: str = 'passage: '¶
Instruction used to embed documents.
param mirostat: Optional[int] = None¶
Enable Mirostat sampling for controlling perplexity.
(default: 0, 0 = disabled, 1 = Mirostat, 2 = Mirostat 2.0)
param mirostat_eta: Optional[float] = None¶
Influences how quickly the algorithm responds to feedback
from the generated text. A lower learning rate will result in
slower adjustments, while a higher learning rate will make
the algorithm more responsive. (Default: 0.1)
param mirostat_tau: Optional[float] = None¶
Controls the balance between coherence and diversity
of the output. A lower value will result in more focused and