Skip to main content

Transform short prompts into detailed, structured instructions using context-aware retrieval

Project description

Prompt Amplifier

Prompt Amplifier Logo

Transform short prompts into detailed, structured instructions using context-aware retrieval.

PyPI version Python 3.9+ License


๐ŸŽฏ What is Prompt Amplifier?

Prompt Amplifier is a library for Prompt Amplification โ€” the process of transforming short, ambiguous user intents into comprehensive, well-structured prompts that LLMs can execute effectively.

from prompt_amplifier import PromptForge

forge = PromptForge()
forge.load_documents("./company_docs/")

# Short, vague input
short_prompt = "How's the deal going?"

# Detailed, structured output
detailed = forge.expand(short_prompt)

Before (user input):

"How's the deal going?"

After (expanded prompt):

"Generate a Deal Health Assessment report with the following structure:

1. Executive Summary - Overall health status (Healthy/Warning/Critical)

2. Key Metrics Table

Metric Current Target Status
Winscore ... ... ...
POC Progress ... ... ...

3. Risk Factors - List blocking issues from Success Plan

4. Recommended Actions - Prioritized next steps

Use data from: Deal Profile, Success Plan, Activity Log..."


โœจ Features

  • ๐Ÿ“„ Multi-format Document Loading โ€” PDF, DOCX, Excel, CSV, TXT, Markdown, HTML
  • ๐Ÿ”ข Pluggable Embedders โ€” TF-IDF, BM25, Sentence Transformers, OpenAI, Cohere, Google
  • ๐Ÿ’พ Vector Store Support โ€” In-memory, ChromaDB, FAISS, Pinecone, Qdrant, Weaviate
  • ๐Ÿ” Smart Retrieval โ€” Vector search, hybrid (BM25 + Vector), reranking
  • ๐Ÿค– LLM Backends โ€” OpenAI, Anthropic, Google Gemini, Ollama (local)
  • ๐Ÿ“‹ Domain Schemas โ€” Define field structures for your domain
  • ๐Ÿ”Œ Extensible โ€” Easy to add custom loaders, embedders, and vector stores

๐Ÿš€ Quick Start

Installation

# Core library
pip install prompt-amplifier

# With common extras
pip install prompt-amplifier[loaders,embeddings-local,vectorstore-chroma]

# Everything
pip install prompt-amplifier[all]

API Key Setup

โš ๏ธ Required for expand(): The prompt expansion feature requires an LLM API key.

import os

# Option 1: Google Gemini (has free tier!)
os.environ["GOOGLE_API_KEY"] = "your-key-from-aistudio.google.com"

# Option 2: OpenAI
os.environ["OPENAI_API_KEY"] = "sk-your-key"

# Option 3: Anthropic
os.environ["ANTHROPIC_API_KEY"] = "sk-ant-your-key"

Basic Usage

import os
os.environ["GOOGLE_API_KEY"] = "your-key"  # Required for expand()

from prompt_amplifier import PromptForge
from prompt_amplifier.generators import GoogleGenerator

# Initialize with Google Gemini (free tier available)
forge = PromptForge(generator=GoogleGenerator())

# Add your documents
forge.add_texts([
    "POC Health: Healthy means all milestones on track.",
    "Winscore ranges from 0-100, measuring deal probability.",
])

# Expand a short prompt
result = forge.expand("Give me a POC health check")

print(result.prompt)      # The expanded prompt
print(result.expansion_ratio)  # How much longer it got

Search Without API Key

from prompt_amplifier import PromptForge

# No API key needed for search!
forge = PromptForge()
forge.add_texts(["doc1", "doc2", "doc3"])

# Search works without LLM
results = forge.search("my query")
for r in results.results:
    print(r.chunk.content)

With Persistent Vector Store

from prompt_amplifier import PromptForge
from prompt_amplifier.vectorstores import ChromaStore
from prompt_amplifier.embedders import SentenceTransformerEmbedder

forge = PromptForge(
    embedder=SentenceTransformerEmbedder("all-MiniLM-L6-v2"),
    vectorstore=ChromaStore(
        collection_name="my_docs",
        persist_directory="./chroma_db"
    )
)

# First run: embeds and stores
forge.load_documents("./docs/")

# Subsequent runs: uses existing embeddings
result = forge.expand("Summarize the project status")

With Cloud Vector Store (Pinecone)

from prompt_amplifier import PromptForge
from prompt_amplifier.vectorstores import PineconeStore
from prompt_amplifier.embedders import OpenAIEmbedder

forge = PromptForge(
    embedder=OpenAIEmbedder(model="text-embedding-3-small"),
    vectorstore=PineconeStore(
        api_key="your-api-key",
        index_name="prompt-amplifier-prod"
    ),
    generator="gpt-4o"
)

๐Ÿ“– Documentation


๐Ÿงฉ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     Prompt Amplifier                         โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                              โ”‚
โ”‚   Documents    โ†’   Chunker   โ†’   Embedder   โ†’   VectorStore โ”‚
โ”‚   (PDF, DOCX)      (split)       (encode)       (persist)   โ”‚
โ”‚                                                              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                              โ”‚
โ”‚   User Query   โ†’   Embedder  โ†’   Retriever  โ†’   Generator   โ”‚
โ”‚   "short"          (encode)      (search)       (expand)    โ”‚
โ”‚                                                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”Œ Supported Integrations

Document Loaders

Format Loader
PDF PDFLoader
Word DocxLoader
Excel ExcelLoader
CSV CSVLoader
Text TxtLoader
Markdown MarkdownLoader
HTML HTMLLoader
JSON JSONLoader

Embedders

Provider Class Type
TF-IDF TFIDFEmbedder Free, Local
BM25 BM25Embedder Free, Local
Sentence Transformers SentenceTransformerEmbedder Free, Local
OpenAI OpenAIEmbedder Paid API
Cohere CohereEmbedder Paid API
Google GoogleEmbedder Paid API
Voyage AI VoyageEmbedder Paid API

Vector Stores

Store Class Type
In-Memory MemoryStore Local
ChromaDB ChromaStore Local
FAISS FAISSStore Local
LanceDB LanceDBStore Local
Pinecone PineconeStore Cloud
Qdrant QdrantStore Local/Cloud
Weaviate WeaviateStore Cloud
pgvector PGVectorStore Self-host

LLM Generators

Provider Class
OpenAI OpenAIGenerator
Anthropic AnthropicGenerator
Google Gemini GoogleGenerator
Ollama OllamaGenerator
HuggingFace HuggingFaceGenerator

๐Ÿงช Research

Prompt Amplifier was developed as part of research into Prompt Amplification โ€” systematically transforming short user intents into detailed, structured prompts.

Key contributions:

  • Formalization of the prompt expansion problem
  • Comparison of embedding strategies for prompt enhancement
  • Evaluation metrics for prompt quality
  • Benchmark datasets across multiple domains

๐Ÿ“„ Paper: [Coming Soon]


๐Ÿค Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

# Clone the repo
git clone https://github.com/DeccanX/Prompt-Amplifier.git
cd Prompt-Amplifier

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run linting
ruff check src/
black src/

๐Ÿ“œ License

Apache 2.0 โ€” See LICENSE for details.


๐Ÿ™ Acknowledgments

Built with inspiration from:


Made with โค๏ธ by Rajesh More for the AI community

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

prompt_amplifier-0.2.2.tar.gz (85.5 kB view details)

Uploaded Source

Built Distribution

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

prompt_amplifier-0.2.2-py3-none-any.whl (101.2 kB view details)

Uploaded Python 3

File details

Details for the file prompt_amplifier-0.2.2.tar.gz.

File metadata

  • Download URL: prompt_amplifier-0.2.2.tar.gz
  • Upload date:
  • Size: 85.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for prompt_amplifier-0.2.2.tar.gz
Algorithm Hash digest
SHA256 2cddae049ac75592923cc00441b4dc54633ca2425dafa2302cafca52d239d76e
MD5 cfb03cd21faeeffc18beaa33c7a8c61c
BLAKE2b-256 bf692e3a30492685da88c981e608b40922cda9443ba8952e34529188b78705ce

See more details on using hashes here.

File details

Details for the file prompt_amplifier-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for prompt_amplifier-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 63f46a386525910a76354cc81fa3eef592dd903c02891732e379f9878f4f8a87
MD5 92b29eb8b6fc9741345d0e72cf79dd0d
BLAKE2b-256 c41daecd819040f080c1e59a4d4edb8c032c082e815fd51dd10511372a89a0d0

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