Skip to main content

QMEM

Memory library for seamless data ingestion, storage, and retrieval with customizable embedding models.

QMem is a toolkit for vector search. It provides a command-line interface (CLI) and a Python library for interacting with a Qdrant database. It is designed for directness and utility, offering a guided CLI for interactive tasks and a minimal Python API for programmatic control..


Features

  • Store documents in a vector database (Qdrant(cloud) or Chroma(local))
  • Search text by semantic meaning, not just exact words
  • Apply filters to narrow search results
  • Choose embeddings from OpenAI, Gemini, Voyage, or MiniLM
  • MongoDB integration for analytics

Installation

pip install qmem

Getting Started

Step 1: Setup

Run once to configure qmem:

qmem init

You will be asked to select:

  • Database backend: Qdrant (cloud) or Chroma (local)
  • Embedding provider: OpenAI, Gemini, Voyage, or MiniLM
  • API keys and embedding model

Configuration is saved in .qmem/config.toml.


Step 2: Prepare Your Data

qmem expects a .jsonl file (one JSON object per line).

Example:

{"query": "What is the plot of Inception?", "response": "A thief enters dreams to steal secrets.", "summary": "Dream heist story.", "title": "Inception", "description": "A skilled thief enters people's dreams to steal corporate secrets.", "genre": "Sci-Fi", "year": 2010}
{"query": "Who is the main character in The Godfather?", "response": "Michael Corleone, son of Vito.", "summary": "Mafia family saga.", "title": "The Godfather", "description": "The patriarch of a crime dynasty hands control to his reluctant son.", "genre": "Crime", "year": 1972}
{"query": "What challenge does Batman face in The Dark Knight?", "response": "He must stop the Joker.", "summary": "Hero vs chaos.", "title": "The Dark Knight", "description": "Batman faces the Joker, a criminal mastermind terrorizing Gotham.", "genre": "Action", "year": 2008}
{"query": "What is Parasite about?", "response": "A poor family cons its way into a rich household.", "summary": "Class divide thriller.", "title": "Parasite", "description": "A poor family infiltrates a wealthy household with dire consequences.", "genre": "Thriller", "year": 2019}
{"query": "What is Interstellar about?", "response": "Explorers travel through a wormhole to save humanity.", "summary": "Space odyssey.", "title": "Interstellar", "description": "A group of explorers journey through a wormhole to find a new home.", "genre": "Adventure", "year": 2014}
  • query: main text to search on
  • response:response to the query
  • others: extra information

Step 3: Add Data

import qmem as qm

# Create a collection
qm.create(collection_name="testing", dim=1024, distance_metric="cosine")

# Ingest data from file
qm.ingest(file="data.jsonl", embed_field="query",payload_field="x,y,z") #what to put in payload , not added then everything goes in payload

results = qm.retrieve(
    query="who is batman",
    top_k=5,
    show=["description", "title"]
)
print(results)

Results are returned in a table showing similarity scores and payload fields.


Step 5: Use Filters

Build filters interactively (CLI):

qmem filter

Filters are saved under .qmem/filters/.

Apply a filter in Python:

filtered = qm.retrieve_filter(
    query="who is batman",
    filter_json=".qmem/filters/latest.json",
    top_k=5,
    show=["description", "title"]
)
print(filtered)

Step 6: Mirror Data to MongoDB

qm.mongo(
    collection_name="testing",
    mongo_db="final_test_db",
    mongo_collection="final_test",
    fields=["description", "title"]
)

This copies your Qdrant collection into MongoDB for downstream use.


CLI Commands

qmem init      # configure qmem
qmem filter    # create filters interactively
qmem index     # (only for Qdrant) build indices for faster filtering

Python API

  • qm.create() → Create a new collection
  • qm.ingest() → Add documents from a file
  • qm.retrieve() → Search documents by meaning
  • qm.retrieve_filter() → Search with filters
  • qm.mongo() → Copy a collection into MongoDB

Why use qmem?

  • Simple to set up and use
  • Works with both local (Chroma) and cloud (Qdrant) databases
  • AI embeddings understand meaning, not just exact words
  • Filters allow more precise retrieval
  • MongoDB integration enables analytics pipelines

Example Workflow

  1. qmem init → configure backend and embeddings
  2. qm.create(...) → create a collection
  3. qm.ingest(...) → add data from JSONL
  4. qm.retrieve(...) → search data by meaning
  5. qmem filter + qm.retrieve_filter(...) → apply filters
  6. qm.mongo(...) → mirror to MongoDB if needed

qmem makes it easy to:

  • Store your documents
  • Search them intelligently
  • Filter results by properties
  • Extend usage with MongoDB integration

Searching for “car” may also return results for “automobile” or “vehicle.”

Metadata

Release files for qmem 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qmem 0.2.1
File Size Uploaded
qmem-0.2.1.tar.gz 34.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for qmem 0.2.1
File Interpreter ABI Platform
qmem-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 70.2 kB

Release files / qmem-0.2.1.tar.gz

Download URL qmem-0.2.1.tar.gz
Size 34.2 kB
Tags Source
SHA-256 checksum
How to use checksums
dd5f4021ba4081541704d235853d73935e7fab80e320d8481d0e0426239afb34
BLAKE2b-256 checksum
How to use checksums
a4e1962542d21bf1feb915eed3ad06d102b9231f57b8d166a73ebb510a3d2b3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.7

Release files / qmem-0.2.1-py3-none-any.whl

Download URL qmem-0.2.1-py3-none-any.whl
Size 36.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6d8c10a8897f5f5248d09ab8c586cee68d07f9d1224932de8b522b8e1aff6d8
BLAKE2b-256 checksum
How to use checksums
3861d1fc77bc976e4b62033201191945080bf1838980c9c0856316d1002cd7f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page