Skip to main content

helper functions for Ollama with Langchain

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Yollama

what is this ?

This repo holds the code for helper functions for Ollama with Langchain.

prerequisites

This has been tested on a Ubuntu 24 server. You'll need:

  • Ollama installed
  • the Ollama models you'll need to install are:
default_llm_model_name = "llama3.1"
default_long_context_llm_model_name = "mistral-nemo"
default_reasoning_llm_model_name = "gemma2:9b"
default_sql_llm_model_name = "qwen2.5-coder"

The num_ctx parameter is the size of the context window used to generate the next token, here we use values for a 20GB VRAM GPU.

  • Python 3 with venv and pip installed

basic usage

pip install yollama

get_llm()

1st parameter is the use case (Literal["default", "long-context", "reasoning", "sql"]), which determines the model and context size.

2nd parameter is a boolean to determine if the LLM should return a JSON object or a string.

from yollama import get_llm

llm = get_llm()

# invoke default model (Llama3.1) in JSON mode
print(llm.invoke({"input_query": some_user_input}))
# invoke Mistral-Nemo model in text mode with some lengthy context
print(get_llm("long-context", False).invoke({"document": some_big_text}))
# invoke Gemma2 model in text mode, to get answers requiring more reasoning abilities
print(get_llm("reasoning", False).invoke({"question": """Owen left a tray of lemon cakes unattended in the staff room for an hour and one of the cakes went missing. Three people are suspects, and here are the facts:
Person A is allergic to citrus but was seen in the area
Person B loves lemon cake but wasn't near the location
Person C has stolen food before and similar incidents increased after they arrived
Who is most likely responsible and why?"""}))
# invoke Qwen2.5-Coder model in text mode, to get a raw SQL query
print(get_llm("sql", False).invoke({"query": "create a SQL query to get the latest headlines"}))

philosophy

fully local models

I've decided to let go of OpenAI to:

  • preserve my privacy
  • save money

As local models are getting better and better, I'm confident that I'll be able to have a greater experience in the future, even with my small 20GB VRAM GPU. 🤔 Of course, it's not fast, but hey everything comes with tradeoffs right? 💪

contributions guidelines

🤝 I haven't made up my mind on contribution guidelines yet. I guess we'll update them as you contribute!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yollama-1.3.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yollama-1.3.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file yollama-1.3.0.tar.gz.

File metadata

  • Download URL: yollama-1.3.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for yollama-1.3.0.tar.gz
Algorithm Hash digest
SHA256 be3786223916137bc94e36be90251b49a6ace67d9e5c8f4b6ff4fd6ef9994328
MD5 529d64ad1d5a677a878606fa446cf0c3
BLAKE2b-256 73ff8c7c84cd5a8a62847e20f8aa575686cfc3ef3b023582359fc9fc5b286479

See more details on using hashes here.

File details

Details for the file yollama-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: yollama-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for yollama-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d57cdb43f52f6d6b44fd32cb779e3f34425c270433cdacad32e30cfaae3ea6f3
MD5 2e21107f13c9b6fcbdc3d11ce911f9a7
BLAKE2b-256 a1554701b8fa381efd9e4fabfd3ec6a159a7b56bb3327f6a0308623314fea6bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page